RUI Interface General Format
This part support all module with BSP API.
General Format
rui_"Interface Type"_xxx()
General Definition
RUI_UART_DEF
typedef enum RUI_UART_DEF
{
RUI_UART0 = 0,
RUI_UART1 = 1,
RUI_UART2 = 2,
RUI_UART3 = 3
}RUI_UART_DEF;
RUI_IF_READ_WRITE
typedef enum RUI_IF_READ_WRITE
{
RUI_IF_READ = 0,
RUI_IF_WRITE = 1
}RUI_IF_READ_WRITE;
RUI_I2C_ST
typedef struct RUI_I2C_ST
{
uint32_t INSTANCE_ID;
uint32_t PIN_SDA; // SDA pin num
uint32_t PIN_SCL; // SCL pin num
uint32_t FREQUENCY;
uint32_t REG_NULL; // if no reg , should be 0xAA
}RUI_I2C_ST;
RUI_I2C_FREQ_ST
typedef enum RUI_I2C_FREQ_ST
{
RUI_I2C_FREQ_100K,
RUI_I2C_FREQ_400K
}RUI_I2C_FREQ_ST;
RUI_SPI_ST
typedef struct
{
uint32_t INSTANCE_ID;
uint32_t PIN_CS; //
uint32_t PIN_SCL; //
uint32_t PIN_MISO; //
uint32_t PIN_MOSI; //
uint32_t FREQUENCY;
} RUI_SPI_ST;
RUI_SPI_FREQ_ST
typedef enum RUI_SPI_FREQ_ST
{
RUI_I2C_FREQ_125K,
RUI_I2C_FREQ_250K,
RUI_I2C_FREQ_500K,
RUI_I2C_FREQ_1M,
RUI_I2C_FREQ_2M,
RUI_I2C_FREQ_4M,
RUI_I2C_FREQ_8M
}RUI_SPI_FREQ_ST;
RUI_GPIO_PIN_DIR_ST
typedef enum
{
RUI_GPIO_PIN_DIR_INPUT, // Input.
RUI_GPIO_PIN_DIR_OUTPUT // Output.
} RUI_GPIO_PIN_DIR_ST;
RUI_GPIO_PIN_PULL_ST
typedef enum
{
RUI_GPIO_PIN_NOPULL, // Pin pull-up resistor disabled.
RUI_GPIO_PIN_PULLDOWN, // Pin pull-down resistor enabled.
RUI_GPIO_PIN_PULLUP // Pin pull-up resistor enabled.
} RUI_GPIO_PIN_PULL_ST;
RUI_GPIO_INTERRUPT_EDGE
typedef enum
{
RUI_GPIO_EDGE_RAISE,
RUI_GPIO_EDGE_FALL,
RUI_GPIO_EDGE_FALL_RAISE
} RUI_GPIO_INTERRUPT_EDGE;
RUI_GPIO_INTERRUPT_PRIORITY
typedef enum
{
RUI_GPIO_IRQ_HIGH_PRIORITY,
RUI_GPIO_IRQ_NORMAL_PRIORITY,
RUI_GPIO_IRQ_LOW_PRIORITY,
} RUI_GPIO_INTERRUPT_PRIORITY;
RUI_GPIO_ST
typedef struct
{
uint32_t pin_num;
RUI_GPIO_PIN_DIR_ST dir;
RUI_GPIO_PIN_PULL_ST pull;
}RUI_GPIO_ST;
RUI_TIMER_MODE_ST
typedef enum
{
RUI_TIMER_MODE_SINGLE_SHOT, /**< The timer will expire only once. */
RUI_TIMER_MODE_REPEATED /**< The timer will restart each time it expires. */
} RUI_TIMER_MODE_ST;
RUI_TIMER_ST
typedef void (* TIMER_CALLBACK) (void);
typedef struct{
uint32_t timeout_ms;
RUI_TIMER_MODE_ST timer_mode;
TIMER_CALLBACK timer_callback;
}RUI_TIMER_ST;
RUI_FLASH_MOD
typedef enum
{
RUI_FLASH_USER = 0, // a region for user , less than 128 bytes
RUI_FLASH_ORIGIN //inner struct region , advise not modify it
}RUI_FLASH_MODE;
RUI UART Initialize
RUI_RETURN_STATUS rui_uart_init(RUI_UART_DEF uart_def,RUI_UART_BAUDRATE baudrate);
| @brief | This API is used to configure the parameters for UART. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_UART_DEF uart_def:the instance of UART. RUI_UART_BAUDRATE baudrate: UART baudrate value |
| @module | RAK811, RAK4200, RAK4400, RAK4600, and RAK5010. |
RUI UART Uninitialize
RUI_RETURN_STATUS rui_uart_unint(RUI_UART_DEF uart_def);
| @brief | This API is used to uninitialize UART. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_UART_DEF uart_def: the instance of UART. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, and RAK5010. |
RUI UART Send
RUI_RETURN_STATUS rui_uart_send(RUI_UART_DEF uart_def, uint8_t *pdata, uint16_t len)
| @brief | This API is used to send data via UART. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_UART_DEF uart_def : the instance of UART. uint8t *pdata : the pointer of data you want to send. uint16_t len : the length of the data. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, and RAK5010. |
RUI UART Receive
void rui_uart_recv(RUI_UART_DEF uart_def, uint8_t *pdata, uint16_t len)
| @brief | This API is used to receive data from UART. |
|---|---|
| @return | NULL |
| @param | RUI_UART_DEF uart_def : the instance of UART. uint8_t *pdata : the pointer of data. uint16_t len : the length of data. This value is always 1. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, and RAK5010. |
RUI UART Configure Mode
RUI_RETURN_STATUS rui_uart_mode_config(RUI_UART_DEF uart_def,RUI_UART_MODE uart_mode);
| @brief | This API is used to configure uart work mode. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_UART_DEF uart_def: the instance of UART. RUI_UART_MODE uart_mode: value for RUI_UART_NORMAL, RUI_UART_UNVARNISHED. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, and RAK5010. |
RUI GPIO Initialize
RUI_RETURN_STATUS rui_gpio_init(RUI_GPIO_ST *rui_gpio);
| @brief | This API is used to configure GPIO. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_GPIO_ST*rui_gpio: the instance of GPIO. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI GPIO Uninitialize
void rui_gpio_uninit(RUI_GPIO_ST *rui_gpio);
| @brief | This API is used to deinitialize GPIO. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_GPIO_ST *rui_gpio: the instance of gpio. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI GPIO Read/Write
RUI_RETURN_STATUS rui_gpio_rw(RUI_IF_READ_WRITE rw_status,RUI_GPIO_ST *rui_gpio,uint8_t* status);
| @brief | This API is used to read or set a certain GPIO's Status. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_IF_READ_WRITE *rui_gpio: the pin number of the GPIO which you want to read or set. uint8_t* status: the pointer of GPIO Value. 0 : low level, 1: high Level. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI GPIO Interrupt
typedef void (*interrupt_callback)(void);
RUI_RETURN_STATUS rui_gpio_interrupt(bool control, RUI_GPIO_ST st, RUI_GPIO_INTERRUPT_EDGE edge, RUI_GPIO_INTERRUPT_PRIORITY pro,calback callback);
| @brief | This API is used to register external GPIO, it may lead to power current increase. e.g 130 µA in Nordic platform. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | bool control: true or false, use it or not. RUI_GPIO_ST pro: priority for interrupt calback callback: interrupt callback. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI Timer Initialize
RUI_RETURN_STATUS rui_timer_init(void *obj, void ( *callback )( void ));
| @brief | This API is used to create/initialize a timer. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | void *obj : timer instance void (*callback)(void): timer event callback function |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI Timer Uninitialize
RUI_RETURN_STATUS rui_timer_uninit(void *obj);
| @brief | This API is used to uninitialize a timer. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | void *obj: timer instance. |
| @module | RAK4600, RAK5010 and RAK8212-M. |
RUI Timer Set Value
RUI_RETURN_STATUS rui_timer_setvalue(void *obj, uint32_t value );
| @brief | This API is used to set the interval value for timer. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | void *obj: timer instance uint32_t value: timer value |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI Timer Start
RUI_RETURN_STATUS rui_timer_start(void *obj);
| @brief | This API is used to start the timer |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | void *obj: timer instance |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI Timer Stop
RUI_RETURN_STATUS rui_timer_stop(void *obj);
| @brief | This API is used to stop the timer. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | void *obj: timer instance |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI ADC Initialize
RUI_RETURN_STATUS rui_adc_init(RUI_GPIO_ST *rui_gpio);
| @brief | This API is used to initialize ADC |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_GPIO_ST *rui_gpio: the instance of GPIO. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI ADC Uninitialize
RUI_RETURN_STATUS rui_adc_uninit(RUI_GPIO_ST *rui_gpio);
| @brief | This API is used to uninitialize ADC |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_GPIO_ST *rui_gpio: the instance of GPIO. |
| @support | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI ADC Read
RUI_RETURN_STATUS rui_adc_get(RUI_GPIO_ST *rui_gpio, uint16_t* value);
| @brief | This API is used to read the value of the ADC Pin |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | uint8_t* value: the value which is read from ADC. RUI_GPIO_ST *rui_gpio : GPIO struct |
| @module | RAK811, RAK4200, RAK4400, RAK4600, RAK5010 and RAK8212-M. |
RUI I2C Initialization
RUI_RETURN_STATUS rui_i2c_init(RUI_I2C_ST *rui_i2c);
| @brief | This API is used to init I2C. |
|---|---|
| @return | RUI_RETURN_STATUS |
| @param | RUI_I2C_ST *rui_i2c: initialize parameters struct. |
| @module | RAK811, RAK4200, RAK4400, RAK4600, and RAK5010. |