fix(ulp): enable astyle linter and format ULP component
This commit is contained in:
@@ -63,13 +63,13 @@ static inline void ulp_riscv_gpio_init(gpio_num_t gpio_num)
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
SET_PERI_REG_MASK(SENS_SAR_PERI_CLK_GATE_CONF_REG, SENS_IOMUX_CLK_EN_M);
|
||||
#endif
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_MUX_SEL);
|
||||
REG_SET_FIELD(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_FUN_SEL, 0);
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_MUX_SEL);
|
||||
REG_SET_FIELD(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_FUN_SEL, 0);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_deinit(gpio_num_t gpio_num)
|
||||
{
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_MUX_SEL);
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_MUX_SEL);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_output_enable(gpio_num_t gpio_num)
|
||||
@@ -84,12 +84,12 @@ static inline void ulp_riscv_gpio_output_disable(gpio_num_t gpio_num)
|
||||
|
||||
static inline void ulp_riscv_gpio_input_enable(gpio_num_t gpio_num)
|
||||
{
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_FUN_IE);
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_FUN_IE);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_input_disable(gpio_num_t gpio_num)
|
||||
{
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_FUN_IE);
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_FUN_IE);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_output_level(gpio_num_t gpio_num, uint8_t level)
|
||||
@@ -108,27 +108,27 @@ static inline uint8_t ulp_riscv_gpio_get_level(gpio_num_t gpio_num)
|
||||
|
||||
static inline void ulp_riscv_gpio_set_output_mode(gpio_num_t gpio_num, rtc_io_out_mode_t mode)
|
||||
{
|
||||
REG_SET_FIELD(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_DRV, mode);
|
||||
REG_SET_FIELD(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_DRV, mode);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_pullup(gpio_num_t gpio_num)
|
||||
{
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_RUE);
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_RUE);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_pullup_disable(gpio_num_t gpio_num)
|
||||
{
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_RUE);
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_RUE);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_pulldown(gpio_num_t gpio_num)
|
||||
{
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_RDE);
|
||||
SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_RDE);
|
||||
}
|
||||
|
||||
static inline void ulp_riscv_gpio_pulldown_disable(gpio_num_t gpio_num)
|
||||
{
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num*4, RTC_IO_TOUCH_PAD0_RDE);
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num * 4, RTC_IO_TOUCH_PAD0_RDE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Locks are based on the Peterson's algorithm, https://en.wikipedia.org/wiki/Peterson%27s_algorithm
|
||||
*
|
||||
|
||||
@@ -13,7 +13,6 @@ extern "C" {
|
||||
/* Underlying driver function for printing a char, e.g. over UART */
|
||||
typedef void (*putc_fn_t)(const void *ctx, const char c);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Installs a print driver that will be used for ulp_riscv_print calls
|
||||
*
|
||||
@@ -22,7 +21,6 @@ typedef void (*putc_fn_t)(const void *ctx, const char c);
|
||||
*/
|
||||
void ulp_riscv_print_install(putc_fn_t putc, void *putc_ctx);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Prints a null-terminated string
|
||||
*
|
||||
@@ -30,7 +28,6 @@ void ulp_riscv_print_install(putc_fn_t putc, void *putc_ctx);
|
||||
*/
|
||||
void ulp_riscv_print_str(const char *str);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Prints a hex number. Does not print 0x, only the digits
|
||||
*
|
||||
|
||||
@@ -17,7 +17,7 @@ extern "C" {
|
||||
* When COCPU accesses the RTC memory, dont need to convert the access address.
|
||||
*/
|
||||
#define WRITE_RTC_MEM(addr, val) (*((volatile int*)(addr))) = (int) (val)
|
||||
#define READ_RTC_MEM(addr) (*(volatile int*)(addr))
|
||||
#define READ_RTC_MEM(addr) (*(volatile int*)(addr))
|
||||
|
||||
/*
|
||||
* When COCPU accesses the RTC register, it needs to convert the access address.
|
||||
|
||||
@@ -83,7 +83,6 @@ esp_err_t ulp_riscv_touch_pad_sleep_channel_read_benchmark(touch_pad_t touch_num
|
||||
*/
|
||||
esp_err_t ulp_riscv_touch_pad_sleep_channel_read_smooth(touch_pad_t touch_num, uint32_t *smooth_data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reset benchmark of touch sensor sleep channel.
|
||||
* @note Refer `touch_pad_sleep_channel_reset_benchmark()` for more details
|
||||
|
||||
@@ -22,7 +22,6 @@ typedef struct {
|
||||
gpio_num_t tx_pin; // TX pin number
|
||||
} ulp_riscv_uart_t; // Context for the driver, initialized by ulp_riscv_uart_init
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the bit-banged UART driver
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -67,7 +67,6 @@ void __attribute__((__noreturn__)) ulp_riscv_halt(void);
|
||||
*/
|
||||
void ulp_riscv_timer_stop(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Resumes the ULP timer
|
||||
*
|
||||
@@ -76,10 +75,9 @@ void ulp_riscv_timer_stop(void);
|
||||
*/
|
||||
void ulp_riscv_timer_resume(void);
|
||||
|
||||
#define ULP_RISCV_GET_CCOUNT() ({ int __ccount; \
|
||||
asm volatile("rdcycle %0;" : "=r"(__ccount)); \
|
||||
__ccount; })
|
||||
|
||||
#define ULP_RISCV_GET_CCOUNT() ({ int __ccount; \
|
||||
asm volatile("rdcycle %0;" : "=r"(__ccount)); \
|
||||
__ccount; })
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
/* These are only approximate default numbers, the default frequency
|
||||
@@ -99,7 +97,7 @@ void ulp_riscv_timer_resume(void);
|
||||
void static inline ulp_riscv_delay_cycles(uint32_t cycles)
|
||||
{
|
||||
uint32_t start = ULP_RISCV_GET_CCOUNT();
|
||||
/* Off with an estimate of cycles in this function to improve accuracy */
|
||||
/* Off with an estimate of cycles in this function to improve accuracy */
|
||||
uint32_t end = start + cycles - 20;
|
||||
|
||||
while (ULP_RISCV_GET_CCOUNT() < end) {
|
||||
|
||||
@@ -21,7 +21,7 @@ esp_err_t ulp_riscv_gpio_isr_register(gpio_num_t gpio_num, ulp_riscv_gpio_int_ty
|
||||
}
|
||||
|
||||
/* Set the interrupt type */
|
||||
REG_SET_FIELD(RTC_GPIO_PIN0_REG + 4*gpio_num, RTC_GPIO_PIN0_INT_TYPE, intr_type);
|
||||
REG_SET_FIELD(RTC_GPIO_PIN0_REG + 4 * gpio_num, RTC_GPIO_PIN0_INT_TYPE, intr_type);
|
||||
|
||||
/* Set the interrupt handler */
|
||||
return ulp_riscv_intr_alloc(ULP_RISCV_RTCIO0_INTR_SOURCE + gpio_num, handler, arg);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -43,27 +43,27 @@
|
||||
* |----------|----------|---------|---------|----------|------------|---------|
|
||||
*/
|
||||
static void ulp_riscv_i2c_format_cmd(uint32_t cmd_idx, uint8_t op_code, uint8_t ack_val,
|
||||
uint8_t ack_expected, uint8_t ack_check_en, uint8_t byte_num)
|
||||
uint8_t ack_expected, uint8_t ack_check_en, uint8_t byte_num)
|
||||
{
|
||||
uint32_t reg_addr = RTC_I2C_CMD0_REG + 4*cmd_idx;
|
||||
uint32_t reg_addr = RTC_I2C_CMD0_REG + 4 * cmd_idx;
|
||||
|
||||
CLEAR_PERI_REG_MASK(reg_addr, 0xFFFFFFFF);
|
||||
|
||||
WRITE_PERI_REG(reg_addr,
|
||||
(0 << 31) | // CMD Done
|
||||
(0 << 31) | // CMD Done
|
||||
|
||||
((op_code & 0x3) << 11) | // Opcode
|
||||
((op_code & 0x3) << 11) | // Opcode
|
||||
|
||||
((ack_val & 0x1) << 10) | // ACK bit sent by I2C controller during READ.
|
||||
// Ignored during RSTART, STOP, END and WRITE cmds.
|
||||
((ack_val & 0x1) << 10) | // ACK bit sent by I2C controller during READ.
|
||||
// Ignored during RSTART, STOP, END and WRITE cmds.
|
||||
|
||||
((ack_expected & 0x1) << 9) | // ACK bit expected by I2C controller during WRITE.
|
||||
// Ignored during RSTART, STOP, END and READ cmds.
|
||||
((ack_expected & 0x1) << 9) | // ACK bit expected by I2C controller during WRITE.
|
||||
// Ignored during RSTART, STOP, END and READ cmds.
|
||||
|
||||
((ack_check_en & 0x1) << 8) | // I2C controller verifies that the ACK bit sent by the slave device matches
|
||||
// the ACK expected bit during WRITE.
|
||||
// Ignored during RSTART, STOP, END and READ cmds.
|
||||
((byte_num & 0xFF) << 0)); // Byte Num
|
||||
((ack_check_en & 0x1) << 8) | // I2C controller verifies that the ACK bit sent by the slave device matches
|
||||
// the ACK expected bit during WRITE.
|
||||
// Ignored during RSTART, STOP, END and READ cmds.
|
||||
((byte_num & 0xFF) << 0)); // Byte Num
|
||||
}
|
||||
|
||||
static inline int32_t ulp_riscv_i2c_wait_for_interrupt(int32_t ticks_to_wait)
|
||||
@@ -76,9 +76,9 @@ static inline int32_t ulp_riscv_i2c_wait_for_interrupt(int32_t ticks_to_wait)
|
||||
|
||||
/* Return 0 if Tx or Rx data interrupt bits are set. */
|
||||
if ((status & RTC_I2C_TX_DATA_INT_ST) ||
|
||||
(status & RTC_I2C_RX_DATA_INT_ST)) {
|
||||
(status & RTC_I2C_RX_DATA_INT_ST)) {
|
||||
return 0;
|
||||
/* In case of error status, break and return -1 */
|
||||
/* In case of error status, break and return -1 */
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
} else if ((status & RTC_I2C_TIMEOUT_INT_ST) ||
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
@@ -176,7 +176,7 @@ void ulp_riscv_i2c_master_read_from_device(uint8_t *data_rd, size_t size)
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
/* Poll for RTC I2C Rx Data interrupt bit to be set */
|
||||
if(!ulp_riscv_i2c_wait_for_interrupt(ULP_RISCV_I2C_RW_TIMEOUT)) {
|
||||
if (!ulp_riscv_i2c_wait_for_interrupt(ULP_RISCV_I2C_RW_TIMEOUT)) {
|
||||
/* Read the data
|
||||
*
|
||||
* Unfortunately, the RTC I2C has no fifo buffer to help us with reading and storing
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -25,7 +25,7 @@ void ulp_riscv_print_str(const char *str)
|
||||
}
|
||||
|
||||
for (int i = 0; str[i] != 0; i++) {
|
||||
s_print_ctx.putc(s_print_ctx.putc_ctx ,str[i]);
|
||||
s_print_ctx.putc(s_print_ctx.putc_ctx, str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ void ulp_riscv_print_hex(int h)
|
||||
for (x = 0; x < 8; x++) {
|
||||
c = (h >> 28) & 0xf; // extract the leftmost byte
|
||||
if (c < 10) {
|
||||
s_print_ctx.putc(s_print_ctx.putc_ctx ,'0' + c);
|
||||
s_print_ctx.putc(s_print_ctx.putc_ctx, '0' + c);
|
||||
} else {
|
||||
s_print_ctx.putc(s_print_ctx.putc_ctx ,'a' + c - 10);
|
||||
s_print_ctx.putc(s_print_ctx.putc_ctx, 'a' + c - 10);
|
||||
}
|
||||
h <<= 4; // move the 2nd leftmost byte to the left, to be extracted next
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ void ulp_riscv_uart_putc(const ulp_riscv_uart_t *uart, const char c)
|
||||
{
|
||||
ulp_riscv_gpio_output_level(uart->tx_pin, 0);
|
||||
|
||||
for (int i = 0; i<8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
/* Offset the delay to account for cycles spent setting the bit */
|
||||
ulp_riscv_delay_cycles(uart->bit_duration_cycles - 100);
|
||||
if ( (1 << i) & c) {
|
||||
if ((1 << i) & c) {
|
||||
ulp_riscv_gpio_output_level(uart->tx_pin, 1);
|
||||
} else {
|
||||
ulp_riscv_gpio_output_level(uart->tx_pin, 0);
|
||||
|
||||
@@ -30,7 +30,7 @@ void ulp_riscv_halt(void)
|
||||
/* Suspends the ulp operation and reset the ULP core. Must be the final operation before going to halt. */
|
||||
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_DONE | RTC_CNTL_COCPU_SHUT_RESET_EN);
|
||||
|
||||
while(1);
|
||||
while (1);
|
||||
}
|
||||
|
||||
void ulp_riscv_timer_stop(void)
|
||||
@@ -55,7 +55,7 @@ void ulp_riscv_enable_sw_intr(intr_handler_t handler, void *arg)
|
||||
|
||||
/* Register interrupt handler */
|
||||
if (handler) {
|
||||
ulp_riscv_intr_alloc(ULP_RISCV_SW_INTR_SOURCE, handler, arg);
|
||||
ulp_riscv_intr_alloc(ULP_RISCV_SW_INTR_SOURCE, handler, arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user