GD32F303을 Arduino로 사용하기위해 보드파일을 하기 링크를 이용하였다.
https://github.com/keyboardio/ArduinoCore-GD32-Keyboardio
Arduino IDE 에서 Board 파일을 등록 해 주고 GD32로 검색해서 설치 할 수 있다.
https://raw.githubusercontent.com/CommunityGD32Cores/GD32Core-New/main/package_gd32_index.json
보드를 GD32F30x Generic series 로선택하고 Board part number를 GD32F303를 선택 해 주면 된다.
GD32 GPIO 레지스터 제어 함수
#define GPIO_BOP(gpiox) REG32((gpiox) + 0x00000018U) /*!< GPIO port bit operation register */
void gpio_bit_set(uint32_t gpio_periph, uint32_t pin)
{
GPIO_BOP(gpio_periph) = (uint32_t)pin;
}
/*!
\brief reset GPIO pin bit
\param[in] gpio_periph: GPIOx(x = A,B,C,D,F)
only one parameter can be selected which is shown as below:
\arg GPIOx(x = A,B,C,D,F)
\param[in] pin: GPIO pin
one or more parameters can be selected which are shown as below:
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
\param[out] none
\retval none
*/
void gpio_bit_reset(uint32_t gpio_periph, uint32_t pin)
{
GPIO_BC(gpio_periph) = (uint32_t)pin;
}
GD32 Arduino variants 파일
/* SPI definitions */
#define PIN_SPI_SS PA8
#define PIN_SPI_MOSI PB15
#define PIN_SPI_MISO PB14
#define PIN_SPI_SCK PB13
/* I2C definitions */
#define PIN_WIRE_SDA PB9
#define PIN_WIRE_SCL PB8
/* TIMER or PWM definitions */
#define TIMER_TONE TIMER5
#define TIMER_SERVO TIMER6
#define PWM0 PA8
#define PWM1 PA0
#define PWM2 PA1
#define PWM3 PA2
#define PWM4 PB6
#define PWM5 PB7
/* USART definitions */
#define SERIAL_HOWMANY 1
/* by default now, use PA9 for TX. To get the old behavior for PA3, define the USE_USART1_SERIAL macro. */
#if !defined(USE_USART0_SERIAL) && !defined(USE_USART1_SERIAL)
#define USE_USART0_SERIAL
#endif
#ifdef USE_USART0_SERIAL
#define PIN_SERIAL_RX PA10
#define PIN_SERIAL_TX PA9
#define SERIAL0_RX PIN_SERIAL_RX
#define SERIAL0_TX PIN_SERIAL_TX
#elif defined(USE_USART1_SERIAL)
#define PIN_SERIAL_RX PA3
#define PIN_SERIAL_TX PA2
#define SERIAL1_RX PIN_SERIAL_RX
#define SERIAL1_TX PIN_SERIAL_TX
#endif
반응형