【HaaS征文】上新开源HaaS100扩展板

在这里插入图片描述

 在这里插入图片描述

板载硬件资源:

  • 24V转12V模块接口        x1
  • 12V非隔离开关              x1   
  • 24V非隔离开关              x1
  • 12V/24V可选的隔离继电器       x1
  • 兼容SPI和I2C的OLED接口       x1
  • 3.5mm音频接口                         x1
  • 微动按键                                    x3
  • 5.5mmx2.1mm DC接口             x1
  • 自恢复保险丝                             x1
  • 接线柱                                        x2
  • PH2.54插座                                x3
     


注:实物Rev1.2 丝印SCL(I2C)和CLK(SPI)位置错误,应该互换。(项目文件已修复此问题)

正确丝印如下:

在这里插入图片描述

注:使用SPI0接口,只需短接CLK和MOSI两处即可。使用I2C需要短接SCL和SDA并焊接I2C上拉电阻R12/R13。

完整PCB预览

在这里插入图片描述

 
下图是使用SPI0点亮OLED的演示:

如题所示,项目软硬件全部开源,请遵循GPL 3.0协议。
 

#!/usr/bin/env python
# -*- coding:utf-8 -*-
###
# Filename: /Users/simonliu/Documents/Haas/pythonprojects/solutions/haas100_oled/main.py
# Path: /Users/simonliu/Documents/Haas/pythonprojects/solutions/haas100_oled
# Created Date: Tuesday, October 26th 2021, 11:33:39 am
# Author: Simon Liu
# 
# Copyright (C) <2021>  <刘知海> <[email protected]> GPLv3
 
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
 
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
 
#     You should have received a copy of the GNU General Public License
#     along with this program.  If not, see <https://www.gnu.org/licenses/>.
###
# -*- coding: UTF-8 -*-
import time
from driver import SPI
from driver import GPIO
import sh1106

# OLED屏幕实例
oled = None

def oled_init():
    oled_spi = SPI()
    oled_spi.open("SPI0")

    oled_res = GPIO()
    oled_res.open("oled_res")

    oled_dc = GPIO()
    oled_dc.open("oled_dc")
    global oled
    oled = sh1106.SH1106_SPI(128, 64, oled_spi, oled_dc, oled_res)

def hello():
    global oled
    oled.fill(0)
    oled.text(' Hello HaaS100!', 2, 16, 1)
    oled.text('    Simon Liu', 2, 32, 1)
    oled.show()
    

def main():
    print("---=== OLED example ===---")
    oled_init()
    hello()
    

if __name__ == '__main__':
    main()


注意要配合board.json文件

{
  "name": "haas100",
  "version": "1.0.0",
  "io": {
    "ADC0": {
      "type": "ADC",
      "port": 0,
      "sampling": 12000000
    },
    "oled_i2c": {
      "type": "I2C",
      "port": 2,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 120
    },
    "pca9544": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 8,
      "freq": 100000,
      "mode": "master",
      "devAddr": 112
    },
    "mpu6050": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 100000,
      "mode": "master",
      "devAddr": 105
    },
    "ap3216c": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 100000,
      "mode": "master",
      "devAddr": 30
    },
    "si7006": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 64
    },
    "spl06": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 119
    },
    "qmc5883": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 13
    },
    "KEY1": {
      "type": "GPIO",
      "port": 21,
      "dir": "irq",
      "pull": "opendrain",
      "intMode": "falling"
    },
    "KEY2": {
      "type": "GPIO",
      "port": 20,
      "dir": "irq",
      "pull": "opendrain",
      "intMode": "falling"
    },
    "KEY3": {
      "type": "GPIO",
      "port": 39,
      "dir": "irq",
      "pull": "opendrain",
      "intMode": "falling"
    },
    "CTRL1": {
      "type": "GPIO",
      "port": 22,
      "dir": "output",
      "pull": "pullup"
    },
    "CTRL2": {
      "type": "GPIO",
      "port": 38,
      "dir": "output",
      "pull": "pullup"
    },
    "CTRL3": {
      "type": "GPIO",
      "port": 23,
      "dir": "output",
      "pull": "pullup"
    },
    "led1": {
      "type": "GPIO",
      "port": 34,
      "dir": "output",
      "pull": "pullup"
    },
    "led2": {
      "type": "GPIO",
      "port": 35,
      "dir": "output",
      "pull": "pullup"
    },
    "led3": {
      "type": "GPIO",
      "port": 36,
      "dir": "output",
      "pull": "pullup"
    },
    "led_r": {
      "type": "GPIO",
      "port": 36,
      "dir": "output",
      "pull": "pullup"
    },
    "led_g": {
      "type": "GPIO",
      "port": 35,
      "dir": "output",
      "pull": "pullup"
    },
    "led_b": {
      "type": "GPIO",
      "port": 34,
      "dir": "output",
      "pull": "pullup"
    },
    "SPI0": {
      "type": "SPI",
      "port": 0,
      "mode": "master",
      "freq": 2000000
    },
    "oled_dc": {
      "type": "GPIO",
      "port": 33,
      "dir": "output",
      "pull": "pullup"
    },
    "oled_res": {
      "type": "GPIO",
      "port": 32,
      "dir": "output",
      "pull": "pullup"
    },
    "serial1": {
      "type": "UART",
      "port": 0,
      "dataWidth": 8,
      "baudRate": 9600,
      "stopBits": 1,
      "flowControl": "disable",
      "parity": "none"
    },
    "port485": {
      "type": "UART",
      "port": 1,
      "dataWidth": 8,
      "baudRate": 38400,
      "stopBits": 1,
      "flowControl": "disable",
      "parity": "none"
    },
    "serial2": {
      "type": "UART",
      "port": 2,
      "dataWidth": 8,
      "baudRate": 115200,
      "stopBits": 1,
      "flowControl": "disable",
      "parity": "none"
    }
  },
  "debugLevel": "ERROR",
  "repl": "disable"
}


开源地址:

项目硬件开源地址

项目代码开源地址
 

猜你喜欢

转载自blog.csdn.net/HaaSTech/article/details/121263688