mirror of
https://github.com/sipeed/Maixduino.git
synced 2026-03-03 17:14:00 +01:00
add maixduino board.
This commit is contained in:
@@ -165,16 +165,14 @@ mduino.menu.clksrc.500.build.f_cpu=500000000L
|
||||
mduino.menu.clksrc.600.build.f_cpu=600000000L
|
||||
|
||||
## Burn baud rate
|
||||
mduino.menu.burn_baudrate.2000000=2 Mbps
|
||||
mduino.menu.burn_baudrate.1500000=1.5 Mbps
|
||||
mduino.menu.burn_baudrate.1000000=1 Mbps
|
||||
mduino.menu.burn_baudrate.2000000.build.burn_baudrate=2000000
|
||||
mduino.menu.burn_baudrate.1500000.build.burn_baudrate=1500000
|
||||
mduino.menu.burn_baudrate.1000000.build.burn_baudrate=1000000
|
||||
|
||||
## Burn tool firmware
|
||||
mduino.menu.burn_tool_firmware.dan=Default
|
||||
mduino.menu.burn_tool_firmware.dan.build.burn_tool_firmware=dan
|
||||
mduino.menu.burn_tool_firmware.dan.build.burn_tool_firmware=goE
|
||||
|
||||
## Point to the file for ./variants/<variant>/pins_arduino.h
|
||||
mduino.build.variant=sipeed_maixduino
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <string.h>
|
||||
#include "UARTClass.h"
|
||||
|
||||
#include "pins_arduino.h"
|
||||
#include "Arduino.h"
|
||||
#include "uarths.h"
|
||||
#include "fpioa.h"
|
||||
#include "sysctl.h"
|
||||
@@ -63,6 +63,12 @@ UARTClass::UARTClass(uart_device_number_t device_select)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UARTClass::begin(uint32_t dwBaudRate)
|
||||
{
|
||||
begin(dwBaudRate, RX1, TX1);
|
||||
}
|
||||
|
||||
void
|
||||
UARTClass::begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx)
|
||||
{
|
||||
@@ -141,6 +147,12 @@ UARTHSClass::UARTHSClass()
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
UARTHSClass::begin(uint32_t dwBaudRate)
|
||||
{
|
||||
begin(dwBaudRate, RX0, TX0);
|
||||
}
|
||||
|
||||
void
|
||||
UARTHSClass::begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx)
|
||||
{
|
||||
|
||||
@@ -27,12 +27,15 @@
|
||||
#include "pins_arduino.h"
|
||||
#include "RingBuffer.h"
|
||||
|
||||
|
||||
|
||||
class UARTClass : public HardwareSerial
|
||||
{
|
||||
public:
|
||||
UARTClass();
|
||||
UARTClass(uart_device_number_t device_select);
|
||||
void begin(uint32_t dwBaudRate, uint8_t _rx = 6, uint8_t _tx = 7);
|
||||
void begin(uint32_t dwBaudRate);
|
||||
void begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx);
|
||||
void end(void);
|
||||
int available(void);
|
||||
int availableForWrite(void);
|
||||
@@ -57,7 +60,8 @@ class UARTHSClass : public UARTClass
|
||||
{
|
||||
public:
|
||||
UARTHSClass();
|
||||
void begin(uint32_t dwBaudRate, uint8_t _rx = 4, uint8_t _tx = 5);
|
||||
void begin(uint32_t dwBaudRate);
|
||||
void begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx);
|
||||
void end(void);
|
||||
size_t write(const uint8_t c);
|
||||
using Print::write;
|
||||
|
||||
@@ -26,26 +26,28 @@ void pinMode(uint8_t dwPin, uint8_t dwMode){
|
||||
}
|
||||
|
||||
void digitalWrite(uint8_t dwPin, uint8_t dwVal){
|
||||
if(_fpio_to_gpio_table[MD_PIN_MAP(dwPin)] >= 0){
|
||||
gpiohs_set_pin((uint8_t)_fpio_to_gpio_table[MD_PIN_MAP(dwPin)], (gpio_pin_value_t)dwVal);
|
||||
int8_t gpio_pin = _fpio_to_gpio_table[MD_PIN_MAP(dwPin)];
|
||||
if( gpio_pin >= 0){
|
||||
gpiohs_set_pin((uint8_t)gpio_pin, (gpio_pin_value_t)dwVal);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
int digitalRead(uint8_t dwPin){
|
||||
if(_fpio_to_gpio_table[MD_PIN_MAP(dwPin)] >= 0){
|
||||
return (int)gpiohs_get_pin((uint8_t)_fpio_to_gpio_table[MD_PIN_MAP(dwPin)]);
|
||||
int8_t gpio_pin = _fpio_to_gpio_table[MD_PIN_MAP(dwPin)];
|
||||
if(gpio_pin >= 0){
|
||||
return (int)gpiohs_get_pin((uint8_t)gpio_pin);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int get_gpio(uint8_t fpio_pin)
|
||||
{
|
||||
if(_fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)] > -1){
|
||||
return _fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)];
|
||||
if(_fpio_to_gpio_table[fpio_pin] >= 0){
|
||||
return (int)_fpio_to_gpio_table[fpio_pin];
|
||||
}else{
|
||||
_fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)] = find_unused_gpiohs_io();
|
||||
return _fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)];
|
||||
_fpio_to_gpio_table[fpio_pin] = (int8_t)find_unused_gpiohs_io();
|
||||
return (int)_fpio_to_gpio_table[fpio_pin];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +69,11 @@ int find_unused_gpiohs_io(void) //返回一个未使用的gpio ,失败返回-1
|
||||
return -1;
|
||||
}
|
||||
|
||||
int read_fpio_to_gpio_table(int number)
|
||||
{
|
||||
return _fpio_to_gpio_table[number];
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -56,6 +56,7 @@ extern int digitalRead( uint8_t dwPin ) ;
|
||||
int get_gpio(uint8_t fpio_pin) ;
|
||||
fpioa_function_t fpioa_get_function_by_io(uint8_t fpioPin) ;
|
||||
int find_unused_gpiohs_io(void) ;
|
||||
int read_fpio_to_gpio_table(int number);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@@ -59,6 +59,7 @@ extern class UARTClass Serial3;
|
||||
#define SCL 30
|
||||
|
||||
#define MD_PIN_MAP(fpio) (fpio)
|
||||
#define ORG_PIN_MAP(org_pin) (org_pin)
|
||||
|
||||
static const uint8_t SS = SPI0_CS0 ;
|
||||
static const uint8_t MOSI = SPI0_MOSI;
|
||||
|
||||
@@ -66,6 +66,7 @@ extern class UARTClass Serial3;
|
||||
#define SCL 30
|
||||
|
||||
#define MD_PIN_MAP(fpio) (fpio)
|
||||
#define ORG_PIN_MAP(org_pin) (org_pin)
|
||||
|
||||
static const uint8_t SS = SPI0_CS0 ;
|
||||
static const uint8_t MOSI = SPI0_MOSI;
|
||||
|
||||
@@ -66,6 +66,7 @@ extern class UARTClass Serial3;
|
||||
#define SCL 30
|
||||
|
||||
#define MD_PIN_MAP(fpio) (fpio)
|
||||
#define ORG_PIN_MAP(org_pin) (org_pin)
|
||||
|
||||
static const uint8_t SS = SPI0_CS0 ;
|
||||
static const uint8_t MOSI = SPI0_MOSI;
|
||||
|
||||
@@ -78,11 +78,15 @@ typedef struct _pwm_fpio_set_t{
|
||||
|
||||
#define MD_PIN_MAP(fpio) _maixduino_pin_map[(fpio)]
|
||||
|
||||
uint8_t _maixduino_pin_map[14] = {4, 5, 21, 22, 23, 24, 32, 15, 14, 13, 12, 11, 10, 3};
|
||||
static const uint8_t _maixduino_pin_map[14] = {4, 5, 21, 22, 23, 24, 32, 15, 14, 13, 12, 11, 10, 3};
|
||||
|
||||
#define ORG_PIN_MAP(org_pin) _original_pin_map[(org_pin)]
|
||||
|
||||
uint8_t pinToFpio(uint8_t pin){ return MD_PIN_MAP(pin); }
|
||||
|
||||
static const uint8_t _original_pin_map[48] = {255, 255, 255, 3, 0, 1, 255, 255, 255, 255,
|
||||
12, 11, 10, 9, 8, 7, 255, 255, 255, 255,
|
||||
255, 2, 3, 4, 5, 255, 255, 255, 255, 255,
|
||||
255, 255, 6, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255};
|
||||
|
||||
typedef enum _analog_output_pin_t{
|
||||
A0,
|
||||
|
||||
Reference in New Issue
Block a user