Skip to content

Commit 2a83d6d

Browse files
committed
add maixduino board.
1 parent 314c278 commit 2a83d6d

File tree

9 files changed

+46
-17
lines changed

9 files changed

+46
-17
lines changed

boards.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,14 @@ mduino.menu.clksrc.500.build.f_cpu=500000000L
165165
mduino.menu.clksrc.600.build.f_cpu=600000000L
166166

167167
## Burn baud rate
168-
mduino.menu.burn_baudrate.2000000=2 Mbps
169168
mduino.menu.burn_baudrate.1500000=1.5 Mbps
170169
mduino.menu.burn_baudrate.1000000=1 Mbps
171-
mduino.menu.burn_baudrate.2000000.build.burn_baudrate=2000000
172170
mduino.menu.burn_baudrate.1500000.build.burn_baudrate=1500000
173171
mduino.menu.burn_baudrate.1000000.build.burn_baudrate=1000000
174172

175173
## Burn tool firmware
176174
mduino.menu.burn_tool_firmware.dan=Default
177-
mduino.menu.burn_tool_firmware.dan.build.burn_tool_firmware=dan
175+
mduino.menu.burn_tool_firmware.dan.build.burn_tool_firmware=goE
178176

179177
## Point to the file for ./variants/<variant>/pins_arduino.h
180178
mduino.build.variant=sipeed_maixduino

cores/arduino/UARTClass.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <string.h>
2222
#include "UARTClass.h"
2323

24-
#include "pins_arduino.h"
24+
#include "Arduino.h"
2525
#include "uarths.h"
2626
#include "fpioa.h"
2727
#include "sysctl.h"
@@ -63,6 +63,12 @@ UARTClass::UARTClass(uart_device_number_t device_select)
6363
}
6464
}
6565

66+
void
67+
UARTClass::begin(uint32_t dwBaudRate)
68+
{
69+
begin(dwBaudRate, RX1, TX1);
70+
}
71+
6672
void
6773
UARTClass::begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx)
6874
{
@@ -141,6 +147,12 @@ UARTHSClass::UARTHSClass()
141147

142148
}
143149

150+
void
151+
UARTHSClass::begin(uint32_t dwBaudRate)
152+
{
153+
begin(dwBaudRate, RX0, TX0);
154+
}
155+
144156
void
145157
UARTHSClass::begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx)
146158
{

cores/arduino/UARTClass.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727
#include "pins_arduino.h"
2828
#include "RingBuffer.h"
2929

30+
31+
3032
class UARTClass : public HardwareSerial
3133
{
3234
public:
3335
UARTClass();
3436
UARTClass(uart_device_number_t device_select);
35-
void begin(uint32_t dwBaudRate, uint8_t _rx = 6, uint8_t _tx = 7);
37+
void begin(uint32_t dwBaudRate);
38+
void begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx);
3639
void end(void);
3740
int available(void);
3841
int availableForWrite(void);
@@ -57,7 +60,8 @@ class UARTHSClass : public UARTClass
5760
{
5861
public:
5962
UARTHSClass();
60-
void begin(uint32_t dwBaudRate, uint8_t _rx = 4, uint8_t _tx = 5);
63+
void begin(uint32_t dwBaudRate);
64+
void begin(uint32_t dwBaudRate, uint8_t _rx, uint8_t _tx);
6165
void end(void);
6266
size_t write(const uint8_t c);
6367
using Print::write;

cores/arduino/wiring_digital.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,28 @@ void pinMode(uint8_t dwPin, uint8_t dwMode){
2626
}
2727

2828
void digitalWrite(uint8_t dwPin, uint8_t dwVal){
29-
if(_fpio_to_gpio_table[MD_PIN_MAP(dwPin)] >= 0){
30-
gpiohs_set_pin((uint8_t)_fpio_to_gpio_table[MD_PIN_MAP(dwPin)], (gpio_pin_value_t)dwVal);
29+
int8_t gpio_pin = _fpio_to_gpio_table[MD_PIN_MAP(dwPin)];
30+
if( gpio_pin >= 0){
31+
gpiohs_set_pin((uint8_t)gpio_pin, (gpio_pin_value_t)dwVal);
3132
}
3233
return ;
3334
}
3435

3536
int digitalRead(uint8_t dwPin){
36-
if(_fpio_to_gpio_table[MD_PIN_MAP(dwPin)] >= 0){
37-
return (int)gpiohs_get_pin((uint8_t)_fpio_to_gpio_table[MD_PIN_MAP(dwPin)]);
37+
int8_t gpio_pin = _fpio_to_gpio_table[MD_PIN_MAP(dwPin)];
38+
if(gpio_pin >= 0){
39+
return (int)gpiohs_get_pin((uint8_t)gpio_pin);
3840
}
3941
return -1;
4042
}
4143

4244
int get_gpio(uint8_t fpio_pin)
4345
{
44-
if(_fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)] > -1){
45-
return _fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)];
46+
if(_fpio_to_gpio_table[fpio_pin] >= 0){
47+
return (int)_fpio_to_gpio_table[fpio_pin];
4648
}else{
47-
_fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)] = find_unused_gpiohs_io();
48-
return _fpio_to_gpio_table[MD_PIN_MAP(fpio_pin)];
49+
_fpio_to_gpio_table[fpio_pin] = (int8_t)find_unused_gpiohs_io();
50+
return (int)_fpio_to_gpio_table[fpio_pin];
4951
}
5052
}
5153

@@ -67,6 +69,11 @@ int find_unused_gpiohs_io(void) //返回一个未使用的gpio ,失败返回-1
6769
return -1;
6870
}
6971

72+
int read_fpio_to_gpio_table(int number)
73+
{
74+
return _fpio_to_gpio_table[number];
75+
}
76+
7077
#ifdef __cplusplus
7178
} // extern "C"
7279
#endif // __cplusplus

cores/arduino/wiring_digital.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern int digitalRead( uint8_t dwPin ) ;
5656
int get_gpio(uint8_t fpio_pin) ;
5757
fpioa_function_t fpioa_get_function_by_io(uint8_t fpioPin) ;
5858
int find_unused_gpiohs_io(void) ;
59+
int read_fpio_to_gpio_table(int number);
5960

6061
#ifdef __cplusplus
6162
} // extern "C"

variants/sipeed_maix_bit/pins_arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern class UARTClass Serial3;
5959
#define SCL 30
6060

6161
#define MD_PIN_MAP(fpio) (fpio)
62+
#define ORG_PIN_MAP(org_pin) (org_pin)
6263

6364
static const uint8_t SS = SPI0_CS0 ;
6465
static const uint8_t MOSI = SPI0_MOSI;

variants/sipeed_maix_go/pins_arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ extern class UARTClass Serial3;
6666
#define SCL 30
6767

6868
#define MD_PIN_MAP(fpio) (fpio)
69+
#define ORG_PIN_MAP(org_pin) (org_pin)
6970

7071
static const uint8_t SS = SPI0_CS0 ;
7172
static const uint8_t MOSI = SPI0_MOSI;

variants/sipeed_maix_one_dock/pins_arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ extern class UARTClass Serial3;
6666
#define SCL 30
6767

6868
#define MD_PIN_MAP(fpio) (fpio)
69+
#define ORG_PIN_MAP(org_pin) (org_pin)
6970

7071
static const uint8_t SS = SPI0_CS0 ;
7172
static const uint8_t MOSI = SPI0_MOSI;

variants/sipeed_maixduino/pins_arduino.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ typedef struct _pwm_fpio_set_t{
7878

7979
#define MD_PIN_MAP(fpio) _maixduino_pin_map[(fpio)]
8080

81-
uint8_t _maixduino_pin_map[14] = {4, 5, 21, 22, 23, 24, 32, 15, 14, 13, 12, 11, 10, 3};
81+
static const uint8_t _maixduino_pin_map[14] = {4, 5, 21, 22, 23, 24, 32, 15, 14, 13, 12, 11, 10, 3};
8282

83+
#define ORG_PIN_MAP(org_pin) _original_pin_map[(org_pin)]
8384

84-
uint8_t pinToFpio(uint8_t pin){ return MD_PIN_MAP(pin); }
85-
85+
static const uint8_t _original_pin_map[48] = {255, 255, 255, 3, 0, 1, 255, 255, 255, 255,
86+
12, 11, 10, 9, 8, 7, 255, 255, 255, 255,
87+
255, 2, 3, 4, 5, 255, 255, 255, 255, 255,
88+
255, 255, 6, 255, 255, 255, 255, 255, 255, 255,
89+
255, 255, 255, 255, 255, 255, 255, 255};
8690

8791
typedef enum _analog_output_pin_t{
8892
A0,

0 commit comments

Comments
 (0)