mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-12 05:05:39 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
48
Living_SDK/include/hal/soc/adc.h
Normal file
48
Living_SDK/include/hal/soc/adc.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_ADC_H
|
||||
#define HAL_ADC_H
|
||||
|
||||
typedef struct {
|
||||
uint32_t sampling_cycle; /* sampling period in number of ADC clock cycles */
|
||||
} adc_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* adc port */
|
||||
adc_config_t config; /* adc config */
|
||||
void *priv; /* priv data */
|
||||
} adc_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises an ADC interface, Prepares an ADC hardware interface for sampling
|
||||
*
|
||||
* @param[in] adc the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_adc_init(adc_dev_t *adc);
|
||||
|
||||
/**
|
||||
* Takes a single sample from an ADC interface
|
||||
*
|
||||
* @param[in] adc the interface which should be sampled
|
||||
* @param[out] output pointer to a variable which will receive the sample
|
||||
* @param[in] timeout ms timeout
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_adc_value_get(adc_dev_t *adc, void *output, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* De-initialises an ADC interface, Turns off an ADC hardware interface
|
||||
*
|
||||
* @param[in] adc the interface which should be de-initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_adc_finalize(adc_dev_t *adc);
|
||||
|
||||
#endif /* HAL_ADC_H */
|
||||
|
||||
157
Living_SDK/include/hal/soc/flash.h
Normal file
157
Living_SDK/include/hal/soc/flash.h
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_FLASH_H
|
||||
#define HAL_FLASH_H
|
||||
|
||||
#define PAR_OPT_READ_POS ( 0 )
|
||||
#define PAR_OPT_WRITE_POS ( 1 )
|
||||
|
||||
#define PAR_OPT_READ_MASK ( 0x1u << PAR_OPT_READ_POS )
|
||||
#define PAR_OPT_WRITE_MASK ( 0x1u << PAR_OPT_WRITE_POS )
|
||||
|
||||
#define PAR_OPT_READ_DIS ( 0x0u << PAR_OPT_READ_POS )
|
||||
#define PAR_OPT_READ_EN ( 0x1u << PAR_OPT_READ_POS )
|
||||
#define PAR_OPT_WRITE_DIS ( 0x0u << PAR_OPT_WRITE_POS )
|
||||
#define PAR_OPT_WRITE_EN ( 0x1u << PAR_OPT_WRITE_POS )
|
||||
|
||||
typedef enum {
|
||||
HAL_PARTITION_ERROR = -1,
|
||||
HAL_PARTITION_BOOTLOADER,
|
||||
HAL_PARTITION_APPLICATION,
|
||||
HAL_PARTITION_ATE,
|
||||
HAL_PARTITION_OTA_TEMP,
|
||||
HAL_PARTITION_RF_FIRMWARE,
|
||||
HAL_PARTITION_PARAMETER_1,
|
||||
HAL_PARTITION_PARAMETER_2,
|
||||
HAL_PARTITION_PARAMETER_3,
|
||||
HAL_PARTITION_PARAMETER_4,
|
||||
HAL_PARTITION_BT_FIRMWARE,
|
||||
HAL_PARTITION_SPIFFS,
|
||||
HAL_PARTITION_SYS_DATA,
|
||||
HAL_PARTITION_HFILOP,
|
||||
HAL_PARTITION_META_DATA,
|
||||
HAL_PARTITION_MAX,
|
||||
HAL_PARTITION_NONE,
|
||||
} hal_partition_t;
|
||||
|
||||
typedef enum {
|
||||
HAL_FLASH_EMBEDDED,
|
||||
HAL_FLASH_SPI,
|
||||
HAL_FLASH_QSPI,
|
||||
HAL_FLASH_MAX,
|
||||
HAL_FLASH_NONE,
|
||||
} hal_flash_t;
|
||||
|
||||
typedef struct {
|
||||
hal_flash_t partition_owner;
|
||||
const char *partition_description;
|
||||
uint32_t partition_start_addr;
|
||||
uint32_t partition_length;
|
||||
uint32_t partition_options;
|
||||
} hal_logic_partition_t;
|
||||
|
||||
/**
|
||||
* Get the infomation of the specified flash area
|
||||
*
|
||||
* @param[in] in_partition The target flash logical partition
|
||||
*
|
||||
* @return HAL_logi_partition struct
|
||||
*/
|
||||
hal_logic_partition_t *hal_flash_get_info(hal_partition_t in_partition);
|
||||
|
||||
/**
|
||||
* Erase an area on a Flash logical partition
|
||||
*
|
||||
* @note Erase on an address will erase all data on a sector that the
|
||||
* address is belonged to, this function does not save data that
|
||||
* beyond the address area but in the affected sector, the data
|
||||
* will be lost.
|
||||
*
|
||||
* @param[in] in_partition The target flash logical partition which should be erased
|
||||
* @param[in] off_set Start address of the erased flash area
|
||||
* @param[in] size Size of the erased flash area
|
||||
*
|
||||
* @return 0 : On success, EIO : If an error occurred with any step
|
||||
*/
|
||||
int32_t hal_flash_erase(hal_partition_t in_partition, uint32_t off_set, uint32_t size);
|
||||
|
||||
/**
|
||||
* Write data to an area on a flash logical partition without erase
|
||||
*
|
||||
* @param[in] in_partition The target flash logical partition which should be read which should be written
|
||||
* @param[in] off_set Point to the start address that the data is written to, and
|
||||
* point to the last unwritten address after this function is
|
||||
* returned, so you can call this function serval times without
|
||||
* update this start address.
|
||||
* @param[in] inBuffer point to the data buffer that will be written to flash
|
||||
* @param[in] inBufferLength The length of the buffer
|
||||
*
|
||||
* @return 0 : On success, EIO : If an error occurred with any step
|
||||
*/
|
||||
int32_t hal_flash_write(hal_partition_t in_partition, uint32_t *off_set,
|
||||
const void *in_buf, uint32_t in_buf_len);
|
||||
|
||||
/**
|
||||
* Write data to an area on a flash logical partition with erase first
|
||||
*
|
||||
* @param[in] in_partition The target flash logical partition which should be read which should be written
|
||||
* @param[in] off_set Point to the start address that the data is written to, and
|
||||
* point to the last unwritten address after this function is
|
||||
* returned, so you can call this function serval times without
|
||||
* update this start address.
|
||||
* @param[in] inBuffer point to the data buffer that will be written to flash
|
||||
* @param[in] inBufferLength The length of the buffer
|
||||
*
|
||||
* @return 0 : On success, EIO : If an error occurred with any step
|
||||
*/
|
||||
int32_t hal_flash_erase_write(hal_partition_t in_partition, uint32_t *off_set,
|
||||
const void *in_buf, uint32_t in_buf_len);
|
||||
|
||||
/**
|
||||
* Read data from an area on a Flash to data buffer in RAM
|
||||
*
|
||||
* @param[in] in_partition The target flash logical partition which should be read
|
||||
* @param[in] off_set Point to the start address that the data is read, and
|
||||
* point to the last unread address after this function is
|
||||
* returned, so you can call this function serval times without
|
||||
* update this start address.
|
||||
* @param[in] outBuffer Point to the data buffer that stores the data read from flash
|
||||
* @param[in] inBufferLength The length of the buffer
|
||||
*
|
||||
* @return 0 : On success, EIO : If an error occurred with any step
|
||||
*/
|
||||
int32_t hal_flash_read(hal_partition_t in_partition, uint32_t *off_set,
|
||||
void *out_buf, uint32_t in_buf_len);
|
||||
|
||||
/**
|
||||
* Set security options on a logical partition
|
||||
*
|
||||
* @param[in] partition The target flash logical partition
|
||||
* @param[in] offset Point to the start address that the data is read, and
|
||||
* point to the last unread address after this function is
|
||||
* returned, so you can call this function serval times without
|
||||
* update this start address.
|
||||
* @param[in] size Size of enabled flash area
|
||||
*
|
||||
* @return 0 : On success, EIO : If an error occurred with any step
|
||||
*/
|
||||
int32_t hal_flash_enable_secure(hal_partition_t partition, uint32_t off_set, uint32_t size);
|
||||
|
||||
/**
|
||||
* Disable security options on a logical partition
|
||||
*
|
||||
* @param[in] partition The target flash logical partition
|
||||
* @param[in] offset Point to the start address that the data is read, and
|
||||
* point to the last unread address after this function is
|
||||
* returned, so you can call this function serval times without
|
||||
* update this start address.
|
||||
* @param[in] size Size of disabled flash area
|
||||
*
|
||||
* @return 0 : On success, EIO : If an error occurred with any step
|
||||
*/
|
||||
int32_t hal_flash_dis_secure(hal_partition_t partition, uint32_t off_set, uint32_t size);
|
||||
|
||||
#endif /* HAL_FLASH_H */
|
||||
|
||||
154
Living_SDK/include/hal/soc/gpio.h
Executable file
154
Living_SDK/include/hal/soc/gpio.h
Executable file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_GPIO_H
|
||||
#define HAL_GPIO_H
|
||||
|
||||
/*
|
||||
* Pin configuration
|
||||
*/
|
||||
typedef enum {
|
||||
ANALOG_MODE, /* Used as a function pin, input and output analog */
|
||||
IRQ_MODE, /* Used to trigger interrupt */
|
||||
INPUT_PULL_UP, /* Input with an internal pull-up resistor - use with devices
|
||||
that actively drive the signal low - e.g. button connected to ground */
|
||||
INPUT_PULL_DOWN, /* Input with an internal pull-down resistor - use with devices
|
||||
that actively drive the signal high - e.g. button connected to a power rail */
|
||||
INPUT_HIGH_IMPEDANCE, /* Input - must always be driven, either actively or by an external pullup resistor */
|
||||
OUTPUT_PUSH_PULL, /* Output actively driven high and actively driven low -
|
||||
must not be connected to other active outputs - e.g. LED output */
|
||||
OUTPUT_OPEN_DRAIN_NO_PULL, /* Output actively driven low but is high-impedance when set high -
|
||||
can be connected to other open-drain/open-collector outputs.
|
||||
Needs an external pull-up resistor */
|
||||
OUTPUT_OPEN_DRAIN_PULL_UP, /* Output actively driven low and is pulled high
|
||||
with an internal resistor when set high -
|
||||
can be connected to other open-drain/open-collector outputs. */
|
||||
} gpio_config_t;
|
||||
|
||||
/*
|
||||
* GPIO dev struct
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t port; /* gpio port */
|
||||
gpio_config_t config; /* gpio config */
|
||||
void *priv; /* priv data */
|
||||
} gpio_dev_t;
|
||||
|
||||
/*
|
||||
* GPIO interrupt trigger
|
||||
*/
|
||||
typedef enum {
|
||||
IRQ_TRIGGER_RISING_EDGE = 0x1, /* Interrupt triggered at input signal's rising edge */
|
||||
IRQ_TRIGGER_FALLING_EDGE = 0x2, /* Interrupt triggered at input signal's falling edge */
|
||||
IRQ_TRIGGER_BOTH_EDGES = IRQ_TRIGGER_RISING_EDGE | IRQ_TRIGGER_FALLING_EDGE,
|
||||
} gpio_irq_trigger_t;
|
||||
|
||||
/*
|
||||
* GPIO interrupt callback handler
|
||||
*/
|
||||
typedef void (*gpio_irq_handler_t)(void *arg);
|
||||
|
||||
/**
|
||||
* Initialises a GPIO pin
|
||||
*
|
||||
* @note Prepares a GPIO pin for use.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which should be initialised
|
||||
* @param[in] configuration A structure containing the required gpio configuration
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_init(gpio_dev_t *gpio);
|
||||
|
||||
/**
|
||||
* Sets an output GPIO pin high
|
||||
*
|
||||
* @note Using this function on a gpio pin which is set to input mode is undefined.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which should be set high
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_output_high(gpio_dev_t *gpio);
|
||||
|
||||
/**
|
||||
* Sets an output GPIO pin low
|
||||
*
|
||||
* @note Using this function on a gpio pin which is set to input mode is undefined.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which should be set low
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_output_low(gpio_dev_t *gpio);
|
||||
|
||||
/**
|
||||
* Trigger an output GPIO pin's output. Using this function on a
|
||||
* gpio pin which is set to input mode is undefined.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which should be set low
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_output_toggle(gpio_dev_t *gpio);
|
||||
|
||||
/**
|
||||
* Get the state of an input GPIO pin. Using this function on a
|
||||
* gpio pin which is set to output mode will return an undefined value.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which should be read
|
||||
* @param[in] value gpio value
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_input_get(gpio_dev_t *gpio, uint32_t *value);
|
||||
|
||||
/**
|
||||
* Enables an interrupt trigger for an input GPIO pin.
|
||||
* Using this function on a gpio pin which is set to
|
||||
* output mode is undefined.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which will provide the interrupt trigger
|
||||
* @param[in] trigger the type of trigger (rising/falling edge)
|
||||
* @param[in] handler a function pointer to the interrupt handler
|
||||
* @param[in] arg an argument that will be passed to the interrupt handler
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_enable_irq(gpio_dev_t *gpio, gpio_irq_trigger_t trigger,
|
||||
gpio_irq_handler_t handler, void *arg);
|
||||
|
||||
/**
|
||||
* Disables an interrupt trigger for an input GPIO pin.
|
||||
* Using this function on a gpio pin which has not been set up
|
||||
* using @ref hal_gpio_input_irq_enable is undefined.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which provided the interrupt trigger
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_disable_irq(gpio_dev_t *gpio);
|
||||
|
||||
/**
|
||||
* Disables an interrupt trigger for an input GPIO pin.
|
||||
* Using this function on a gpio pin which has not been set up
|
||||
* using @ref hal_gpio_input_irq_enable is undefined.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which provided the interrupt trigger
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_clear_irq(gpio_dev_t *gpio);
|
||||
|
||||
/**
|
||||
* Set a GPIO pin in default state.
|
||||
*
|
||||
* @param[in] gpio the gpio pin which should be deinitialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_gpio_finalize(gpio_dev_t *gpio);
|
||||
|
||||
#endif /* HAL_GPIO_H */
|
||||
|
||||
134
Living_SDK/include/hal/soc/i2c.h
Executable file
134
Living_SDK/include/hal/soc/i2c.h
Executable file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_I2C_H
|
||||
#define HAL_I2C_H
|
||||
|
||||
|
||||
#define I2C_MODE_MASTER 1 /* i2c communication is master mode */
|
||||
#define I2C_MODE_SLAVE 2 /* i2c communication is slave mode */
|
||||
|
||||
#define I2C_MEM_ADDR_SIZE_8BIT 1 /* i2c menory address size 8bit */
|
||||
#define I2C_MEM_ADDR_SIZE_16BIT 2 /* i2c menory address size 16bit */
|
||||
|
||||
typedef struct {
|
||||
uint32_t address_width;
|
||||
uint32_t freq;
|
||||
uint8_t mode;
|
||||
uint16_t dev_addr;
|
||||
} i2c_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* i2c port */
|
||||
i2c_config_t config; /* i2c config */
|
||||
void *priv; /* priv data */
|
||||
} i2c_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises an I2C interface
|
||||
* Prepares an I2C hardware interface for communication as a master or slave
|
||||
*
|
||||
* @param[in] i2c the device for which the i2c port should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during initialisation
|
||||
*/
|
||||
int32_t hal_i2c_init(i2c_dev_t *i2c);
|
||||
|
||||
/**
|
||||
* I2c master send
|
||||
*
|
||||
* @param[in] i2c the i2c device
|
||||
* @param[in] dev_addr device address
|
||||
* @param[in] data i2c send data
|
||||
* @param[in] size i2c send data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during initialisation
|
||||
*/
|
||||
int32_t hal_i2c_master_send(i2c_dev_t *i2c, uint16_t dev_addr, const uint8_t *data,
|
||||
uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* I2c master recv
|
||||
*
|
||||
* @param[in] i2c the i2c device
|
||||
* @param[in] dev_addr device address
|
||||
* @param[out] data i2c receive data
|
||||
* @param[in] size i2c receive data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during initialisation
|
||||
*/
|
||||
int32_t hal_i2c_master_recv(i2c_dev_t *i2c, uint16_t dev_addr, uint8_t *data,
|
||||
uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* I2c slave send
|
||||
*
|
||||
* @param[in] i2c the i2c device
|
||||
* @param[in] data i2c slave send data
|
||||
* @param[in] size i2c slave send data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during initialisation
|
||||
*/
|
||||
int32_t hal_i2c_slave_send(i2c_dev_t *i2c, const uint8_t *data, uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* I2c slave receive
|
||||
*
|
||||
* @param[in] i2c tthe i2c device
|
||||
* @param[out] data i2c slave receive data
|
||||
* @param[in] size i2c slave receive data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during initialisation
|
||||
*/
|
||||
int32_t hal_i2c_slave_recv(i2c_dev_t *i2c, uint8_t *data, uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* I2c mem write
|
||||
*
|
||||
* @param[in] i2c the i2c device
|
||||
* @param[in] dev_addr device address
|
||||
* @param[in] mem_addr mem address
|
||||
* @param[in] mem_addr_size mem address
|
||||
* @param[in] data i2c master send data
|
||||
* @param[in] size i2c master send data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during initialisation
|
||||
*/
|
||||
int32_t hal_i2c_mem_write(i2c_dev_t *i2c, uint16_t dev_addr, uint16_t mem_addr,
|
||||
uint16_t mem_addr_size, const uint8_t *data, uint16_t size,
|
||||
uint32_t timeout);
|
||||
|
||||
/**
|
||||
* I2c master mem read
|
||||
*
|
||||
* @param[in] i2c the i2c device
|
||||
* @param[in] dev_addr device address
|
||||
* @param[in] mem_addr mem address
|
||||
* @param[in] mem_addr_size mem address
|
||||
* @param[out] data i2c master send data
|
||||
* @param[in] size i2c master send data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during initialisation
|
||||
*/
|
||||
int32_t hal_i2c_mem_read(i2c_dev_t *i2c, uint16_t dev_addr, uint16_t mem_addr,
|
||||
uint16_t mem_addr_size, uint8_t *data, uint16_t size,
|
||||
uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Deinitialises an I2C device
|
||||
*
|
||||
* @param[in] i2c the i2c device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred during deinitialisation
|
||||
*/
|
||||
int32_t hal_i2c_finalize(i2c_dev_t *i2c);
|
||||
|
||||
#endif /* HAL_I2C_H */
|
||||
|
||||
54
Living_SDK/include/hal/soc/interpt.h
Normal file
54
Living_SDK/include/hal/soc/interpt.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_INTERPT_H
|
||||
#define HAL_INTERPT_H
|
||||
|
||||
typedef void (*hal_interpt_t)(int32_t vec, void *para);
|
||||
|
||||
typedef struct {
|
||||
hal_interpt_t fun;
|
||||
void *para;
|
||||
} hal_interpt_desc_t;
|
||||
|
||||
|
||||
/**
|
||||
* Interrupt vector init
|
||||
*
|
||||
* @return 0 : on success, -1 : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_interpt_init(void);
|
||||
|
||||
/**
|
||||
* Mask specified interrupt vector
|
||||
*
|
||||
*
|
||||
* @param[in] vec specified interrupt vector
|
||||
*
|
||||
* @return 0 : on success, -1 : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_interpt_mask(int32_t vec);
|
||||
|
||||
/**
|
||||
* Unmask specified interrupt vector
|
||||
*
|
||||
*
|
||||
* @param[in] vec specified interrupt vector
|
||||
*
|
||||
* @return 0 : on success, -1 : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_interpt_umask(int32_t vec);
|
||||
|
||||
/**
|
||||
* Install specified interrupt vector
|
||||
*
|
||||
*
|
||||
* @param[in] vec specified interrupt vector
|
||||
*
|
||||
* @return 0 : on success, -1 : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_interpt_install(int32_t vec, hal_interpt_t handler,
|
||||
void *para, char *name);
|
||||
#endif
|
||||
|
||||
105
Living_SDK/include/hal/soc/nand.h
Normal file
105
Living_SDK/include/hal/soc/nand.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_NAND_H
|
||||
#define HAL_NAND_H
|
||||
|
||||
typedef struct {
|
||||
uint32_t page_size; /* NAND memory page size w/o spare area */
|
||||
uint32_t spare_area_size; /* NAND memory spare area size */
|
||||
uint32_t block_size; /* NAND memory block size number of pages */
|
||||
uint32_t zone_size; /* NAND memory zone size measured in number of blocks */
|
||||
uint32_t zone_number; /* NAND memory number of zones */
|
||||
} nand_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t page; /* NAND memory Page address */
|
||||
uint16_t block; /* NAND memory Block address */
|
||||
uint16_t zone; /* NAND memory Zone address */
|
||||
} nand_addr_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t base_addr;
|
||||
nand_config_t config;
|
||||
void *priv;
|
||||
} nand_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises a nand flash interface
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nand_init(nand_dev_t *nand);
|
||||
|
||||
/**
|
||||
* Deinitialises a nand flash interface
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nand_finalize(nand_dev_t *nand);
|
||||
|
||||
/**
|
||||
* Read nand page(s)
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
* @param[out] data pointer to the buffer which will store incoming data
|
||||
* @param[in] addr nand address
|
||||
* @param[in] page_count the number of pages to read
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nand_read_page(nand_dev_t *nand, nand_addr_t *addr, uint8_t *data, uint32_t page_count);
|
||||
|
||||
|
||||
/**
|
||||
* Write nand page(s)
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
* @param[in] data pointer to source buffer to write
|
||||
* @param[in] addr nand address
|
||||
* @param[in] page_count the number of pages to write
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nand_write_page(nand_dev_t *nand, nand_addr_t *addr, uint8_t *data, uint32_t page_count);
|
||||
|
||||
/**
|
||||
* Read nand spare area
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
* @param[out] data pointer to the buffer which will store incoming data
|
||||
* @param[in] addr nand address
|
||||
* @param[in] data_len the number of spares to read
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nand_read_spare(nand_dev_t *nand, nand_addr_t *addr, uint8_t *data, uint32_t data_len);
|
||||
|
||||
|
||||
/**
|
||||
* Write nand spare area
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
* @param[in] data pointer to source buffer to write
|
||||
* @param[in] addr nand address
|
||||
* @param[in] data_len the number of spares to write
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nand_write_spare(nand_dev_t *nand, nand_addr_t *addr, uint8_t *data, uint32_t data_len);
|
||||
|
||||
/**
|
||||
* Erase nand block
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
* @param[in] addr nand address
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nand_erase_block(nand_dev_t *nand, nand_addr_t *addr);
|
||||
#endif
|
||||
83
Living_SDK/include/hal/soc/nor.h
Normal file
83
Living_SDK/include/hal/soc/nor.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_NOR_H
|
||||
#define HAL_NOR_H
|
||||
|
||||
typedef struct {
|
||||
uint32_t block_size; /* NOR memory block size number of bytes */
|
||||
uint32_t chip_size; /* NOR memory chip size measured in number of blocks */
|
||||
} nor_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t base_addr;
|
||||
nor_config_t config;
|
||||
void *priv;
|
||||
} nor_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises a nor flash interface
|
||||
*
|
||||
* @param[in] nor the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nor_init(nor_dev_t *nor);
|
||||
|
||||
/**
|
||||
* Deinitialises a nor flash interface
|
||||
*
|
||||
* @param[in] nand the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nor_finalize(nor_dev_t *nor);
|
||||
|
||||
/**
|
||||
* Read data from NOR memory
|
||||
*
|
||||
* @param[in] nor the interface which should be initialised
|
||||
* @param[out] data pointer to the buffer which will store incoming data
|
||||
* @param[in] addr nor memory address
|
||||
* @param[in] len the number of bytes to read
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nor_read(nor_dev_t *nor, uint32_t *addr, uint8_t *data, uint32_t len);
|
||||
|
||||
|
||||
/**
|
||||
* Write data to NOR memory
|
||||
*
|
||||
* @param[in] nor the interface which should be initialised
|
||||
* @param[in] data pointer to source buffer to write
|
||||
* @param[in] addr nor memory address
|
||||
* @param[in] len the number of bytes to write
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nor_write(nor_dev_t *nor, uint32_t *addr, uint8_t *data, uint32_t len);
|
||||
|
||||
/*
|
||||
* Erase the blocks of the NOR memory
|
||||
*
|
||||
* @param[in] nor the interface which should be initialised
|
||||
* @param[in] addr nor memory address
|
||||
* @param[in] block_count the number of block to erase
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nor_erase_block(nor_dev_t *nor, uint32_t *addr, uint32_t block_count);
|
||||
|
||||
/*
|
||||
* Erase the entire NOR chip
|
||||
*
|
||||
* @param[in] nor the interface which should be initialised
|
||||
* @param[in] addr nor memory address
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_nor_erase_chip(nor_dev_t *nor, uint32_t *addr);
|
||||
|
||||
#endif
|
||||
56
Living_SDK/include/hal/soc/pwm.h
Normal file
56
Living_SDK/include/hal/soc/pwm.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_PWM_H
|
||||
#define HAL_PWM_H
|
||||
|
||||
typedef struct {
|
||||
float duty_cycle; /* the pwm duty_cycle */
|
||||
uint32_t freq; /* the pwm freq */
|
||||
} pwm_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* pwm port */
|
||||
pwm_config_t config; /* spi config */
|
||||
void *priv; /* priv data */
|
||||
} pwm_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises a PWM pin
|
||||
*
|
||||
*
|
||||
* @param[in] pwm the PWM device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_pwm_init(pwm_dev_t *pwm);
|
||||
|
||||
/**
|
||||
* Starts Pulse-Width Modulation signal output on a PWM pin
|
||||
*
|
||||
* @param[in] pwm the PWM device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_pwm_start(pwm_dev_t *pwm);
|
||||
|
||||
/**
|
||||
* Stops output on a PWM pin
|
||||
*
|
||||
* @param[in] pwm the PWM device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_pwm_stop(pwm_dev_t *pwm);
|
||||
|
||||
/**
|
||||
* De-initialises an PWM interface, Turns off an PWM hardware interface
|
||||
*
|
||||
* @param[in] pwm the interface which should be de-initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_pwm_finalize(pwm_dev_t *pwm);
|
||||
|
||||
#endif /* HAL_PWM_H */
|
||||
89
Living_SDK/include/hal/soc/qspi.h
Normal file
89
Living_SDK/include/hal/soc/qspi.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_QSPI_H
|
||||
#define HAL_QSPI_H
|
||||
|
||||
typedef struct {
|
||||
uint32_t freq; /* communication frequency Hz */
|
||||
} qspi_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* qspi port */
|
||||
qspi_config_t config; /* qspi config */
|
||||
void *priv; /* priv data */
|
||||
} qspi_dev_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t instruction; /* qspi instruction */
|
||||
uint32_t address; /* qspi cmd address */
|
||||
uint32_t size; /* qspi cmd size */
|
||||
} qspi_cmd_t;
|
||||
|
||||
/**
|
||||
* Initialises the QSPI interface for a given QSPI device
|
||||
*
|
||||
* @param[in] qspi the spi device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_qspi_init(qspi_dev_t *qspi);
|
||||
|
||||
/**
|
||||
* Qspi send
|
||||
*
|
||||
* @param[in] qspi the qspi device
|
||||
* @param[in] data spi send data
|
||||
* @param[in] size spi send data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_qspi_send(qspi_dev_t *qspi, const uint8_t *data, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Qspi recv
|
||||
*
|
||||
* @param[in] qspi the qspi device
|
||||
* @param[out] data qspi recv data
|
||||
* @param[in] size qspi recv data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_qspi_recv(qspi_dev_t *qspi, uint8_t *data, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Set qspi command
|
||||
*
|
||||
* @param[in] qspi the qspi device
|
||||
* @param[out] cmd qspi cmd
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_qspi_command(qspi_dev_t *qspi, qspi_cmd_t *cmd, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Configure automatic polling mode to wait for processing
|
||||
*
|
||||
* @param[in] qspi the qspi device
|
||||
* @param[out] cmd qspi cmd
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_qspi_auto_polling(qspi_dev_t *qspi, uint32_t cmd, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* De-initialises a QSPI interface
|
||||
*
|
||||
* @param[in] qspi the QSPI device to be de-initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_qspi_finalize(qspi_dev_t *qspi);
|
||||
|
||||
#endif /* HAL_QSPI_H */
|
||||
|
||||
26
Living_SDK/include/hal/soc/rng.h
Normal file
26
Living_SDK/include/hal/soc/rng.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_RNG_H
|
||||
#define HAL_RNG_H
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* random device port */
|
||||
void *priv; /* priv data */
|
||||
} random_dev_t;
|
||||
|
||||
/**
|
||||
* Fill in a memory buffer with random data
|
||||
*
|
||||
* @param[in] random the random device
|
||||
* @param[out] inBuffer Point to a valid memory buffer, this function will fill
|
||||
* in this memory with random numbers after executed
|
||||
* @param[in] inByteCount Length of the memory buffer (bytes)
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_random_num_read(random_dev_t random, void *buf, int32_t bytes);
|
||||
|
||||
#endif /* HAL_RNG_H */
|
||||
|
||||
74
Living_SDK/include/hal/soc/rtc.h
Normal file
74
Living_SDK/include/hal/soc/rtc.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_RTC_H
|
||||
#define HAL_RTC_H
|
||||
|
||||
#define HAL_RTC_FORMAT_DEC 1
|
||||
#define HAL_RTC_FORMAT_BCD 2
|
||||
|
||||
typedef struct {
|
||||
uint8_t format; /* time formart DEC or BCD */
|
||||
} rtc_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* rtc port */
|
||||
rtc_config_t config; /* rtc config */
|
||||
void *priv; /* priv data */
|
||||
} rtc_dev_t;
|
||||
|
||||
/*
|
||||
* RTC time
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t sec; /* DEC format:value range from 0 to 59, BCD format:value range from 0x00 to 0x59 */
|
||||
uint8_t min; /* DEC format:value range from 0 to 59, BCD format:value range from 0x00 to 0x59 */
|
||||
uint8_t hr; /* DEC format:value range from 0 to 23, BCD format:value range from 0x00 to 0x23 */
|
||||
uint8_t weekday; /* DEC format:value range from 1 to 7, BCD format:value range from 0x01 to 0x07 */
|
||||
uint8_t date; /* DEC format:value range from 1 to 31, BCD format:value range from 0x01 to 0x31 */
|
||||
uint8_t month; /* DEC format:value range from 1 to 12, BCD format:value range from 0x01 to 0x12 */
|
||||
uint8_t year; /* DEC format:value range from 0 to 99, BCD format:value range from 0x00 to 0x99 */
|
||||
} rtc_time_t;
|
||||
|
||||
/**
|
||||
* This function will initialize the on board CPU real time clock
|
||||
*
|
||||
*
|
||||
* @param[in] rtc rtc device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_rtc_init(rtc_dev_t *rtc);
|
||||
|
||||
/**
|
||||
* This function will return the value of time read from the on board CPU real time clock.
|
||||
*
|
||||
* @param[in] rtc rtc device
|
||||
* @param[out] time pointer to a time structure
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_rtc_get_time(rtc_dev_t *rtc, rtc_time_t *time);
|
||||
|
||||
/**
|
||||
* This function will set MCU RTC time to a new value.
|
||||
*
|
||||
* @param[in] rtc rtc device
|
||||
* @param[out] time pointer to a time structure
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_rtc_set_time(rtc_dev_t *rtc, const rtc_time_t *time);
|
||||
|
||||
/**
|
||||
* De-initialises an RTC interface, Turns off an RTC hardware interface
|
||||
*
|
||||
* @param[in] RTC the interface which should be de-initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_rtc_finalize(rtc_dev_t *rtc);
|
||||
|
||||
#endif /* HAL_RTC_H */
|
||||
|
||||
116
Living_SDK/include/hal/soc/sd.h
Normal file
116
Living_SDK/include/hal/soc/sd.h
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_SD_H
|
||||
#define HAL_SD_H
|
||||
|
||||
typedef enum {
|
||||
SD_STAT_RESET,
|
||||
SD_STAT_READY,
|
||||
SD_STAT_TIMEOUT,
|
||||
SD_STAT_BUSY,
|
||||
SD_STAT_PROGRAMMING,
|
||||
SD_STAT_RECEIVING,
|
||||
SD_STAT_TRANSFER,
|
||||
SD_STAT_ERR
|
||||
} hal_sd_stat;
|
||||
|
||||
typedef struct {
|
||||
uint32_t blk_nums; /* sd total block nums */
|
||||
uint32_t blk_size; /* sd block size */
|
||||
} hal_sd_info_t;
|
||||
|
||||
/*
|
||||
* UART configuration
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t bus_wide; /* sd bus wide */
|
||||
uint32_t freq; /* sd freq */
|
||||
} sd_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* sd port */
|
||||
sd_config_t config; /* sd config */
|
||||
void *priv; /* priv data */
|
||||
} sd_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises a sd interface
|
||||
*
|
||||
* @param[in] sd the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_sd_init(sd_dev_t *sd);
|
||||
|
||||
/**
|
||||
* Read sd blocks
|
||||
*
|
||||
* @param[in] sd the interface which should be initialised
|
||||
* @param[out] data pointer to the buffer which will store incoming data
|
||||
* @param[in] blk_addr sd blk addr
|
||||
* @param[in] blks sd blks
|
||||
* @param[in] timeout timeout in milisecond
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_sd_blks_read(sd_dev_t *sd, uint8_t *data, uint32_t blk_addr,
|
||||
uint32_t blks, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Write sd blocks
|
||||
*
|
||||
* @param[in] sd the interface which should be initialised
|
||||
* @param[in] data pointer to the buffer which will store incoming data
|
||||
* @param[in] blk_addr sd blk addr
|
||||
* @param[in] blks sd blks
|
||||
* @param[in] timeout timeout in milisecond
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_sd_blks_write(sd_dev_t *sd, uint8_t *data, uint32_t blk_addr,
|
||||
uint32_t blks, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Erase sd blocks
|
||||
*
|
||||
* @param[in] sd the interface which should be initialised
|
||||
* @param[in] blk_start_addr sd blocks start addr
|
||||
* @param[in] blk_end_addr sd blocks end addr
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_sd_erase(sd_dev_t *sd, uint32_t blk_start_addr, uint32_t blk_end_addr);
|
||||
|
||||
/**
|
||||
* Get sd state
|
||||
*
|
||||
* @param[in] sd the interface which should be initialised
|
||||
* @param[out] stat pointer to the buffer which will store incoming data
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_sd_stat_get(sd_dev_t *sd, hal_sd_stat *stat);
|
||||
|
||||
/**
|
||||
* Get sd info
|
||||
*
|
||||
* @param[in] sd the interface which should be initialised
|
||||
* @param[out] stat pointer to the buffer which will store incoming data
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_sd_info_get(sd_dev_t *sd, hal_sd_info_t *info);
|
||||
|
||||
/**
|
||||
* Deinitialises a sd interface
|
||||
*
|
||||
* @param[in] sd the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_sd_finalize(sd_dev_t *sd);
|
||||
|
||||
#endif /* HAL_SD_H */
|
||||
|
||||
31
Living_SDK/include/hal/soc/soc.h
Normal file
31
Living_SDK/include/hal/soc/soc.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_SOC_H
|
||||
#define HAL_SOC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <hal/soc/adc.h>
|
||||
#include <hal/soc/flash.h>
|
||||
#include <hal/soc/gpio.h>
|
||||
#include <hal/soc/i2c.h>
|
||||
#include <hal/soc/nand.h>
|
||||
#include <hal/soc/nor.h>
|
||||
#include <hal/soc/pwm.h>
|
||||
#include <hal/soc/qspi.h>
|
||||
#include <hal/soc/rng.h>
|
||||
#include <hal/soc/rtc.h>
|
||||
#include <hal/soc/sd.h>
|
||||
#include <hal/soc/spi.h>
|
||||
#include <hal/soc/timer.h>
|
||||
#include <hal/soc/uart.h>
|
||||
#include <hal/soc/wdg.h>
|
||||
#include <hal/soc/interpt.h>
|
||||
|
||||
#define HAL_WAIT_FOREVER 0xFFFFFFFFU
|
||||
|
||||
#endif /* HAL_SOC_H */
|
||||
|
||||
80
Living_SDK/include/hal/soc/spi.h
Normal file
80
Living_SDK/include/hal/soc/spi.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_SPI_H
|
||||
#define HAL_SPI_H
|
||||
|
||||
#define HAL_SPI_MODE_MASTER 1 /* spi communication is master mode */
|
||||
#define HAL_SPI_MODE_SLAVE 2 /* spi communication is slave mode */
|
||||
|
||||
typedef struct {
|
||||
uint32_t mode; /* spi communication mode */
|
||||
uint32_t freq; /* communication frequency Hz */
|
||||
} spi_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* spi port */
|
||||
spi_config_t config; /* spi config */
|
||||
void *priv; /* priv data */
|
||||
} spi_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises the SPI interface for a given SPI device
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
*
|
||||
* @return 0 : on success, EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_init(spi_dev_t *spi);
|
||||
|
||||
/**
|
||||
* Spi send
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
* @param[in] data spi send data
|
||||
* @param[in] size spi send data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_send(spi_dev_t *spi, const uint8_t *data, uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* spi_recv
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
* @param[out] data spi recv data
|
||||
* @param[in] size spi recv data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_recv(spi_dev_t *spi, uint8_t *data, uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* spi send data and recv
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
* @param[in] tx_data spi send data
|
||||
* @param[in] rx_data spi recv data
|
||||
* @param[in] size spi data to be sent and recived
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0, on success; EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_send_recv(spi_dev_t *spi, uint8_t *tx_data, uint8_t *rx_data,
|
||||
uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* De-initialises a SPI interface
|
||||
*
|
||||
*
|
||||
* @param[in] spi the SPI device to be de-initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_spi_finalize(spi_dev_t *spi);
|
||||
|
||||
#endif /* HAL_SPI_H */
|
||||
|
||||
64
Living_SDK/include/hal/soc/timer.h
Normal file
64
Living_SDK/include/hal/soc/timer.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_TIMER_H
|
||||
#define HAL_TIMER_H
|
||||
|
||||
#define TIMER_RELOAD_AUTO 1 /* timer reload automatic */
|
||||
#define TIMER_RELOAD_MANU 2 /* timer reload manual */
|
||||
|
||||
typedef void (*hal_timer_cb_t)(void *arg);
|
||||
|
||||
typedef struct {
|
||||
uint32_t period;
|
||||
uint8_t reload_mode;
|
||||
hal_timer_cb_t cb;
|
||||
void *arg;
|
||||
} timer_config_t;
|
||||
|
||||
typedef struct {
|
||||
int8_t port; /* timer port */
|
||||
timer_config_t config; /* timer config */
|
||||
void *priv; /* priv data */
|
||||
} timer_dev_t;
|
||||
|
||||
/**
|
||||
* init a hardware timer
|
||||
*
|
||||
* @param[in] tmr timer struct
|
||||
* @param[in] period micro seconds for repeat timer trigger
|
||||
* @param[in] auto_reoad set to 0, if you just need oneshot timer
|
||||
* @param[in] cb callback to be triggered after useconds
|
||||
* @param[in] ch timer channel
|
||||
* @param[in] arg passed to cb
|
||||
*/
|
||||
int32_t hal_timer_init(timer_dev_t *tim);
|
||||
|
||||
/**
|
||||
* start a hardware timer
|
||||
*
|
||||
* @return 0 == success, EIO == failure
|
||||
*/
|
||||
int32_t hal_timer_start(timer_dev_t *tim);
|
||||
|
||||
/**
|
||||
* stop a hardware timer
|
||||
*
|
||||
* @param[in] tmr timer struct
|
||||
* @param[in] cb callback to be triggered after useconds
|
||||
* @param[in] arg passed to cb
|
||||
*/
|
||||
void hal_timer_stop(timer_dev_t *tim);
|
||||
|
||||
/**
|
||||
* De-initialises an TIMER interface, Turns off an TIMER hardware interface
|
||||
*
|
||||
* @param[in] timer the interface which should be de-initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_timer_finalize(timer_dev_t *tim);
|
||||
|
||||
#endif /* HAL_TIMER_H*/
|
||||
|
||||
132
Living_SDK/include/hal/soc/uart.h
Executable file
132
Living_SDK/include/hal/soc/uart.h
Executable file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_UART_H
|
||||
#define HAL_UART_H
|
||||
|
||||
/*
|
||||
* UART data width
|
||||
*/
|
||||
typedef enum {
|
||||
DATA_WIDTH_5BIT,
|
||||
DATA_WIDTH_6BIT,
|
||||
DATA_WIDTH_7BIT,
|
||||
DATA_WIDTH_8BIT,
|
||||
DATA_WIDTH_9BIT
|
||||
} hal_uart_data_width_t;
|
||||
|
||||
/*
|
||||
* UART stop bits
|
||||
*/
|
||||
typedef enum {
|
||||
STOP_BITS_1,
|
||||
STOP_BITS_2
|
||||
} hal_uart_stop_bits_t;
|
||||
|
||||
/*
|
||||
* UART flow control
|
||||
*/
|
||||
typedef enum {
|
||||
FLOW_CONTROL_DISABLED,
|
||||
FLOW_CONTROL_CTS,
|
||||
FLOW_CONTROL_RTS,
|
||||
FLOW_CONTROL_CTS_RTS
|
||||
} hal_uart_flow_control_t;
|
||||
|
||||
/*
|
||||
* UART parity
|
||||
*/
|
||||
typedef enum {
|
||||
NO_PARITY,
|
||||
ODD_PARITY,
|
||||
EVEN_PARITY
|
||||
} hal_uart_parity_t;
|
||||
|
||||
/*
|
||||
* UART mode
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_TX,
|
||||
MODE_RX,
|
||||
MODE_TX_RX
|
||||
} hal_uart_mode_t;
|
||||
|
||||
/*
|
||||
* UART configuration
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t baud_rate;
|
||||
hal_uart_data_width_t data_width;
|
||||
hal_uart_parity_t parity;
|
||||
hal_uart_stop_bits_t stop_bits;
|
||||
hal_uart_flow_control_t flow_control;
|
||||
hal_uart_mode_t mode;
|
||||
} uart_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* uart port */
|
||||
uart_config_t config; /* uart config */
|
||||
void *priv; /* priv data */
|
||||
} uart_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises a UART interface
|
||||
*
|
||||
*
|
||||
* @param[in] uart the interface which should be initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_uart_init(uart_dev_t *uart);
|
||||
|
||||
/**
|
||||
* Transmit data on a UART interface
|
||||
*
|
||||
* @param[in] uart the UART interface
|
||||
* @param[in] data pointer to the start of data
|
||||
* @param[in] size number of bytes to transmit
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_uart_send(uart_dev_t *uart, const void *data, uint32_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Receive data on a UART interface
|
||||
*
|
||||
* @param[in] uart the UART interface
|
||||
* @param[out] data pointer to the buffer which will store incoming data
|
||||
* @param[in] expect_size number of bytes to receive
|
||||
* @param[in] timeout timeout in milisecond, set this value to HAL_WAIT_FOREVER
|
||||
* if you want to wait forever
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_uart_recv(uart_dev_t *uart, void *data, uint32_t expect_size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Receive data on a UART interface
|
||||
*
|
||||
* @param[in] uart the UART interface
|
||||
* @param[out] data pointer to the buffer which will store incoming data
|
||||
* @param[in] expect_size number of bytes to receive
|
||||
* @param[out] recv_size number of bytes received
|
||||
* @param[in] timeout timeout in milisecond, set this value to HAL_WAIT_FOREVER
|
||||
* if you want to wait forever
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_uart_recv_II(uart_dev_t *uart, void *data, uint32_t expect_size,
|
||||
uint32_t *recv_size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Deinitialises a UART interface
|
||||
*
|
||||
* @param[in] uart the interface which should be deinitialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_uart_finalize(uart_dev_t *uart);
|
||||
|
||||
#endif /* HAL_UART_H */
|
||||
|
||||
46
Living_SDK/include/hal/soc/wdg.h
Normal file
46
Living_SDK/include/hal/soc/wdg.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_WDG_H
|
||||
#define HAL_WDG_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t timeout; /* Watchdag timeout */
|
||||
} wdg_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* wdg port */
|
||||
wdg_config_t config; /* wdg config */
|
||||
void *priv; /* priv data */
|
||||
} wdg_dev_t;
|
||||
|
||||
/**
|
||||
* This function will initialize the on board CPU hardware watch dog
|
||||
*
|
||||
* @param[in] wdg the watch dog device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_wdg_init(wdg_dev_t *wdg);
|
||||
|
||||
/**
|
||||
* Reload watchdog counter.
|
||||
*
|
||||
* @param[in] wdg the watch dog device
|
||||
*/
|
||||
void hal_wdg_reload(wdg_dev_t *wdg);
|
||||
|
||||
/**
|
||||
* This function performs any platform-specific cleanup needed for hardware watch dog.
|
||||
*
|
||||
* @param[in] wdg the watch dog device
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred with any step
|
||||
*/
|
||||
int32_t hal_wdg_finalize(wdg_dev_t *wdg);
|
||||
|
||||
#endif /* HAL_WDG_H */
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue