feat(driver): Use astyle to format the code

This commit is contained in:
Wu Jian Gang
2018-05-19 22:55:14 +08:00
parent ae6c134ec4
commit a08d0711a4
11 changed files with 305 additions and 290 deletions

View File

@ -18,6 +18,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "esp8266/gpio_register.h"
#define ETS_GPIO_INTR_ENABLE() _xt_isr_unmask(1 << ETS_GPIO_INUM)
@ -95,8 +96,8 @@ typedef enum {
typedef enum {
GPIO_Mode_Input = 0x0, /**< GPIO mode : Input */
GPIO_Mode_Out_OD, /**< GPIO mode : Output_OD */
GPIO_Mode_Output , /**< GPIO mode : Output */
GPIO_Mode_Sigma_Delta , /**< GPIO mode : Sigma_Delta */
GPIO_Mode_Output, /**< GPIO mode : Output */
GPIO_Mode_Sigma_Delta, /**< GPIO mode : Sigma_Delta */
} GPIOMode_TypeDef;
typedef enum {
@ -127,104 +128,104 @@ typedef struct {
* @{
*/
/**
/**
* @brief Set GPIO pin output level.
*
*
* @param gpio_no : The GPIO sequence number.
* @param bit_value : GPIO pin output level.
*
* @param bit_value : GPIO pin output level.
*
* @return null
*/
#define GPIO_OUTPUT_SET(gpio_no, bit_value) \
gpio_output_conf(bit_value<<gpio_no, ((~bit_value)&0x01)<<gpio_no, 1<<gpio_no, 0)
/**
/**
* @brief Set GPIO pin output level.
*
*
* @param gpio_bits : The GPIO bit number.
* @param bit_value : GPIO pin output level.
*
* @param bit_value : GPIO pin output level.
*
* @return null
*/
#define GPIO_OUTPUT(gpio_bits, bit_value) \
if(bit_value) gpio_output_conf(gpio_bits, 0, gpio_bits, 0);\
else gpio_output_conf(0, gpio_bits, gpio_bits, 0)
/**
/**
* @brief Disable GPIO pin output.
*
*
* @param gpio_no : The GPIO sequence number.
*
*
* @return null
*/
#define GPIO_DIS_OUTPUT(gpio_no) gpio_output_conf(0, 0, 0, 1<<gpio_no)
/**
/**
* @brief Enable GPIO pin intput.
*
*
* @param gpio_bits : The GPIO bit number.
*
*
* @return null
*/
#define GPIO_AS_INPUT(gpio_bits) gpio_output_conf(0, 0, 0, gpio_bits)
/**
/**
* @brief Enable GPIO pin output.
*
*
* @param gpio_bits : The GPIO bit number.
*
*
* @return null
*/
#define GPIO_AS_OUTPUT(gpio_bits) gpio_output_conf(0, 0, gpio_bits, 0)
/**
/**
* @brief Sample the level of GPIO input.
*
*
* @param gpio_no : The GPIO sequence number.
*
* @return the level of GPIO input
*
* @return the level of GPIO input
*/
#define GPIO_INPUT_GET(gpio_no) ((gpio_input_get()>>gpio_no)&BIT(0))
/**
/**
* @brief Enable GPIO16 output.
*
*
* @param null
*
*
* @return null
*/
void gpio16_output_conf(void);
/**
/**
* @brief Set GPIO16 output level.
*
*
* @param uint8 value : GPIO16 output level.
*
*
* @return null
*/
void gpio16_output_set(uint8 value);
/**
/**
* @brief Enable GPIO pin intput.
*
*
* @param null
*
*
* @return null
*/
void gpio16_input_conf(void);
/**
/**
* @brief Sample the value of GPIO16 input.
*
*
* @param null
*
*
* @return the level of GPIO16 input.
*/
uint8 gpio16_input_get(void);
/**
/**
* @brief Configure Gpio pins out or input.
*
*
* @param uint32 set_mask : Set the output for the high bit, the
* corresponding bit is 1, the output of high,
* the corresponding bit is 0, do not change the state.
@ -238,51 +239,51 @@ uint8 gpio16_input_get(void);
*/
void gpio_output_conf(uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32 disable_mask);
/**
/**
* @brief Register an application-specific interrupt handler for GPIO pin interrupts.
*
*
* @param void *fn:interrupt handler for GPIO pin interrupts.
* @param void *arg:interrupt handler's arg
*
*
* @return null
*/
void gpio_intr_handler_register(void *fn, void *arg);
void gpio_intr_handler_register(void* fn, void* arg);
/**
/**
* @brief Configure GPIO wake up to light sleep,Only level way is effective.
*
*
* @param uint32 i : Gpio sequence number
* @param GPIO_INT_TYPE intr_state : the level of wake up to light sleep
*
*
* @return null
*/
void gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state);
/**
/**
* @brief Disable GPIO wake up to light sleep.
*
*
* @param null
*
*
* @return null
*/
void gpio_pin_wakeup_disable();
/**
/**
* @brief Config interrupt types of GPIO pin.
*
*
* @param uint32 i : The GPIO sequence number.
* @param GPIO_INT_TYPE intr_state : GPIO interrupt types.
*
*
* @return null
*/
void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state);
/**
/**
* @brief Sample the value of GPIO input pins and returns a bitmask.
*
*
* @param null
*
* @return bitmask of GPIO pins input
*
* @return bitmask of GPIO pins input
*/
uint32 gpio_input_get(void);

View File

@ -43,12 +43,12 @@ void hw_timer_init(void);
/**
* @brief Set a trigger timer delay to enable this timer.
*
* @param uint32 val : Timing
* @param uint32 val : Timing
* - In autoload mode, range : 50 ~ 0x7fffff
* - In non-autoload mode, range : 10 ~ 0x7fffff
*
* @param uint8 req : 0, not autoload; 1, autoload mode.
*
*
* @return null
*/
void hw_timer_arm(uint32 val, bool req);
@ -57,7 +57,7 @@ void hw_timer_arm(uint32 val, bool req);
* @brief disable this timer.
*
* @param null
*
*
* @return null
*/
void hw_timer_disarm(void);
@ -67,7 +67,7 @@ void hw_timer_disarm(void);
*
* For enabled timer, timer callback has to be set.
*
* @param uint32 val : Timing
* @param uint32 val : Timing
* - In autoload mode, range : 50 ~ 0x7fffff
* - In non-autoload mode, range : 10 ~ 0x7fffff
*

View File

@ -16,6 +16,7 @@
#define __I2C_MASTER_H__
#include "esp8266/pin_mux_register.h"
#define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO2_U
#define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_GPIO4_U
#define I2C_MASTER_SDA_GPIO 2
@ -70,20 +71,20 @@
* @{
*/
/**
/**
* @brief i2c_master_gpio_init,config SDA and SCL gpio to open-drain output mode.
*
*
* @param null
*
*
* @return null
*/
void i2c_master_gpio_init(void);
/**
/**
* @brief i2c_master_gpio_init,config SDA and SCL gpio to open-drain output mode.
*
*
* @param initilize I2C bus to enable i2c operations.
*
*
* @return null
*/
void i2c_master_init(void);
@ -91,83 +92,83 @@ void i2c_master_init(void);
#define i2c_master_wait os_delay_us
/**
/**
* @brief i2c_master_gpio_init,config SDA and SCL gpio to open-drain output mode.
*
*
* @param set i2c to stop sending state.
*
*
* @return null
*/
void i2c_master_stop(void);
/**
/**
* @brief i2c_master_gpio_init,config SDA and SCL gpio to open-drain output mode.
*
*
* @param set i2c to start sending state.
*
*
* @return null
*/
void i2c_master_start(void);
/**
/**
* @brief i2c_master_gpio_init,config SDA and SCL gpio to open-drain output mode.
*
*
* @param set ack to i2c bus as level value.
*
*
* @return null
*/
void i2c_master_setAck(uint8 level);
/**
/**
* @brief confirm if peer send ack.
*
*
* @param null
*
*
* @return null
*/
uint8 i2c_master_getAck(void);
/**
/**
* @brief read Byte from i2c bus.
*
*
* @param null
*
*
* @return the byte which read from i2c bus.
*/
uint8 i2c_master_readByte(void);
/**
/**
* @brief write wrdata value(one byte) into i2c.
*
*
* @param uint8 wrdata:write value
*
*
* @return null
*/
void i2c_master_writeByte(uint8 wrdata);
/**
/**
* @brief i2c_master_checkAck.
*
*
* @param null
*
*
* @return the result of check ack
*/
bool i2c_master_checkAck(void);
/**
/**
* @brief i2c master send Ack.
*
*
* @param null
*
*
* @return null
*/
void i2c_master_send_ack(void);
/**
/**
* @brief i2c master send Nack.
*
*
* @param null
*
*
* @return null
*/
void i2c_master_send_nack(void);

View File

@ -47,8 +47,7 @@ extern "C"
* @brief Support HSPI and SPI module.
*
*/
typedef enum
{
typedef enum {
SpiNum_SPI = 0,
SpiNum_HSPI = 1,
} SpiNum;
@ -57,8 +56,7 @@ typedef enum
* @brief The SPI module can work in either master or slave mode.
*
*/
typedef enum
{
typedef enum {
SpiMode_Master = 0,
SpiMode_Slave = 1,
} SpiMode;
@ -73,8 +71,7 @@ typedef enum
* 1 0 2
* 1 1 3
*/
typedef enum
{
typedef enum {
SpiSubMode_0 = 0,
SpiSubMode_1 = 1,
SpiSubMode_2 = 2,
@ -87,8 +84,7 @@ typedef enum
* @attention Max speed 80MHz
*
*/
typedef enum
{
typedef enum {
SpiSpeed_2MHz = 40 - 1,
SpiSpeed_5MHz = 16 - 1,
SpiSpeed_10MHz = 8 - 1,
@ -100,15 +96,13 @@ typedef enum
* @brief The SPI mode working speed.
*
*/
typedef enum
{
typedef enum {
SpiBitOrder_MSBFirst = 0,
SpiBitOrder_LSBFirst = 1,
} SpiBitOrder;
// @brief SPI interrupt soource defined.
typedef enum
{
typedef enum {
SpiIntSrc_TransDoneEn = SPI_TRANS_DONE_EN,
SpiIntSrc_WrStaDoneEn = SPI_SLV_WR_STA_DONE_EN,
SpiIntSrc_RdStaDoneEn = SPI_SLV_RD_STA_DONE_EN,
@ -117,8 +111,7 @@ typedef enum
} SpiIntSrc;
// @brief SPI CS pin.
typedef enum
{
typedef enum {
SpiPinCS_0 = 0,
SpiPinCS_1 = 1,
SpiPinCS_2 = 2,
@ -127,8 +120,7 @@ typedef enum
/**
* @brief SPI attribute
*/
typedef struct
{
typedef struct {
SpiMode mode; ///< Master or slave mode
SpiSubMode subMode; ///< SPI SPI_CPOL SPI_CPHA mode
SpiSpeed speed; ///< SPI Clock
@ -138,13 +130,12 @@ typedef struct
/**
* @brief SPI attribute
*/
typedef struct
{
typedef struct {
uint16_t cmd; ///< Command value
uint8_t cmdLen; ///< Command byte length
uint32_t *addr; ///< Point to address value
uint32_t* addr; ///< Point to address value
uint8_t addrLen; ///< Address byte length
uint32_t *data; ///< Point to data buffer
uint32_t* data; ///< Point to data buffer
uint8_t dataLen; ///< Data byte length.
} SpiData;
@ -154,7 +145,7 @@ typedef struct
* @brief Print debug information.
*
*/
void __ShowRegValue(const char * func, uint32_t line);
void __ShowRegValue(const char* func, uint32_t line);
/**
* @brief Initialize SPI module.
@ -202,7 +193,7 @@ void SPIMasterCfgCmd(SpiNum spiNum, uint32_t cmd);
*
* @return int, -1:indicates failure,others indicates success.
*/
int SPIMasterSendData(SpiNum spiNum, SpiData* pInData);
int SPIMasterSendData(SpiNum spiNum, SpiData* pInData);
/**
* @brief Receive data from slave by master.
@ -215,7 +206,7 @@ void SPIMasterCfgCmd(SpiNum spiNum, uint32_t cmd);
* @return int, -1:indicates failure,others indicates success.
*
*/
int SPIMasterRecvData(SpiNum spiNum, SpiData* pOutData);
int SPIMasterRecvData(SpiNum spiNum, SpiData* pOutData);
/**
* @brief Load data to slave send buffer.
@ -229,7 +220,7 @@ void SPIMasterCfgCmd(SpiNum spiNum, uint32_t cmd);
*
* @return int, -1:indicates failure,others indicates success.
*/
int SPISlaveSendData(SpiNum spiNum, uint32_t *pInData, uint8_t outLen);
int SPISlaveSendData(SpiNum spiNum, uint32_t* pInData, uint8_t outLen);
/**
* @brief Receive data by slave.

View File

@ -44,9 +44,9 @@
#define SPI_FASTRD_MODE (BIT(13))
#define SPI_CTRL1(i) (REG_SPI_BASE(i) + 0xc)
#define SPI_CS_HOLD_DELAY 0xf
#define SPI_CS_HOLD_DELAY 0xf
#define SPI_CS_HOLD_DELAY_S 28
#define SPI_CS_HOLD_DELAY_RES 0xfff
#define SPI_CS_HOLD_DELAY_RES 0xfff
#define SPI_CS_HOLD_DELAY_RES_S 16
@ -187,26 +187,26 @@
#define SPI_SLV_RDBUF_CMD_VALUE 0x000000FF
#define SPI_SLV_RDBUF_CMD_VALUE_S 0
#define SPI_W0(i) (REG_SPI_BASE(i) +0x40)
#define SPI_W1(i) (REG_SPI_BASE(i) +0x44)
#define SPI_W2(i) (REG_SPI_BASE(i) +0x48)
#define SPI_W3(i) (REG_SPI_BASE(i) +0x4C)
#define SPI_W4(i) (REG_SPI_BASE(i) +0x50)
#define SPI_W5(i) (REG_SPI_BASE(i) +0x54)
#define SPI_W6(i) (REG_SPI_BASE(i) +0x58)
#define SPI_W7(i) (REG_SPI_BASE(i) +0x5C)
#define SPI_W8(i) (REG_SPI_BASE(i) +0x60)
#define SPI_W9(i) (REG_SPI_BASE(i) +0x64)
#define SPI_W10(i) (REG_SPI_BASE(i) +0x68)
#define SPI_W11(i) (REG_SPI_BASE(i) +0x6C)
#define SPI_W12(i) (REG_SPI_BASE(i) +0x70)
#define SPI_W13(i) (REG_SPI_BASE(i) +0x74)
#define SPI_W14(i) (REG_SPI_BASE(i) +0x78)
#define SPI_W15(i) (REG_SPI_BASE(i) +0x7C)
#define SPI_W0(i) (REG_SPI_BASE(i) +0x40)
#define SPI_W1(i) (REG_SPI_BASE(i) +0x44)
#define SPI_W2(i) (REG_SPI_BASE(i) +0x48)
#define SPI_W3(i) (REG_SPI_BASE(i) +0x4C)
#define SPI_W4(i) (REG_SPI_BASE(i) +0x50)
#define SPI_W5(i) (REG_SPI_BASE(i) +0x54)
#define SPI_W6(i) (REG_SPI_BASE(i) +0x58)
#define SPI_W7(i) (REG_SPI_BASE(i) +0x5C)
#define SPI_W8(i) (REG_SPI_BASE(i) +0x60)
#define SPI_W9(i) (REG_SPI_BASE(i) +0x64)
#define SPI_W10(i) (REG_SPI_BASE(i) +0x68)
#define SPI_W11(i) (REG_SPI_BASE(i) +0x6C)
#define SPI_W12(i) (REG_SPI_BASE(i) +0x70)
#define SPI_W13(i) (REG_SPI_BASE(i) +0x74)
#define SPI_W14(i) (REG_SPI_BASE(i) +0x78)
#define SPI_W15(i) (REG_SPI_BASE(i) +0x7C)
#define SPI_EXT2(i) (REG_SPI_BASE(i) + 0xF8)
#define SPI_EXT2(i) (REG_SPI_BASE(i) + 0xF8)
#define SPI_EXT3(i) (REG_SPI_BASE(i) + 0xFC)
#define SPI_EXT3(i) (REG_SPI_BASE(i) + 0xFC)
#define SPI_INT_HOLD_ENA 0x00000003
#define SPI_INT_HOLD_ENA_S 0
#endif // SPI_REGISTER_H_INCLUDED

View File

@ -122,149 +122,149 @@ typedef struct {
* @{
*/
/**
/**
* @brief Wait uart tx fifo empty, do not use it if tx flow control enabled.
*
*
* @param UART_Port uart_no:UART0 or UART1
*
*
* @return null
*/
void UART_WaitTxFifoEmpty(UART_Port uart_no); //do not use if tx flow control enabled
/**
/**
* @brief Clear uart tx fifo and rx fifo.
*
*
* @param UART_Port uart_no : UART0 or UART1
*
*
* @return null
*/
void UART_ResetFifo(UART_Port uart_no);
/**
/**
* @brief Clear uart interrupt flags.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param uint32 clr_mask : To clear the interrupt bits
*
*
* @return null
*/
void UART_ClearIntrStatus(UART_Port uart_no, uint32 clr_mask);
/**
/**
* @brief Enable uart interrupts .
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param uint32 ena_mask : To enable the interrupt bits
*
*
* @return null
*/
void UART_SetIntrEna(UART_Port uart_no, uint32 ena_mask);
/**
/**
* @brief Register an application-specific interrupt handler for Uarts interrupts.
*
*
* @param void *fn : interrupt handler for Uart interrupts.
* @param void *arg : interrupt handler's arg.
*
*
* @return null
*/
void UART_intr_handler_register(void *fn, void *arg);
void UART_intr_handler_register(void* fn, void* arg);
/**
/**
* @brief Config from which serial output printf function.
*
*
* @param UART_Port uart_no : UART0 or UART1
*
*
* @return null
*/
void UART_SetPrintPort(UART_Port uart_no);
/**
/**
* @brief Config Common parameters of serial ports.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param UART_ConfigTypeDef *pUARTConfig : parameters structure
*
*
* @return null
*/
void UART_ParamConfig(UART_Port uart_no, UART_ConfigTypeDef *pUARTConfig);
void UART_ParamConfig(UART_Port uart_no, UART_ConfigTypeDef* pUARTConfig);
/**
/**
* @brief Config types of uarts.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param UART_IntrConfTypeDef *pUARTIntrConf : parameters structure
*
*
* @return null
*/
void UART_IntrConfig(UART_Port uart_no, UART_IntrConfTypeDef *pUARTIntrConf);
void UART_IntrConfig(UART_Port uart_no, UART_IntrConfTypeDef* pUARTIntrConf);
/**
/**
* @brief Config the length of the uart communication data bits.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param UART_WordLength len : the length of the uart communication data bits
*
*
* @return null
*/
void UART_SetWordLength(UART_Port uart_no, UART_WordLength len);
/**
/**
* @brief Config the length of the uart communication stop bits.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param UART_StopBits bit_num : the length uart communication stop bits
*
*
* @return null
*/
void UART_SetStopBits(UART_Port uart_no, UART_StopBits bit_num);
/**
/**
* @brief Configure whether to open the parity.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param UART_ParityMode Parity_mode : the enum of uart parity configuration
*
*
* @return null
*/
void UART_SetParity(UART_Port uart_no, UART_ParityMode Parity_mode) ;
/**
/**
* @brief Configure the Baud rate.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param uint32 baud_rate : the Baud rate
*
*
* @return null
*/
void UART_SetBaudrate(UART_Port uart_no, uint32 baud_rate);
/**
/**
* @brief Configure Hardware flow control.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param UART_HwFlowCtrl flow_ctrl : Hardware flow control mode
* @param uint8 rx_thresh : threshold of Hardware flow control
*
*
* @return null
*/
void UART_SetFlowCtrl(UART_Port uart_no, UART_HwFlowCtrl flow_ctrl, uint8 rx_thresh);
/**
/**
* @brief Configure trigging signal of uarts.
*
*
* @param UART_Port uart_no : UART0 or UART1
* @param UART_LineLevelInverse inverse_mask : Choose need to flip the IO
*
*
* @return null
*/
void UART_SetLineInverse(UART_Port uart_no, UART_LineLevelInverse inverse_mask) ;
/**
/**
* @brief An example illustrates how to configure the serial port.
*
*
* @param null
*
*
* @return null
*/
void uart_init_new(void);