style changes, fix i2c typo

crypto-aes
Hierophect 3 years ago
parent 4ec588bb37
commit 5aae8df5d7

@ -61,8 +61,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
//match pins to I2C objects
I2C_TypeDef * I2Cx;
uint8_t sda_len = sizeof(mcu_i2c_sda_list) / sizeof(*mcu_i2c_sda_list);
uint8_t scl_len = sizeof(mcu_i2c_scl_list) / sizeof(*mcu_i2c_scl_list);
uint8_t sda_len = MP_ARRAY_SIZE(mcu_i2c_sda_list);
uint8_t scl_len = MP_ARRAY_SIZE(mcu_i2c_scl_list);
bool i2c_taken = false;
for (uint i = 0; i < sda_len; i++) {
@ -137,7 +137,7 @@ void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
never_reset_i2c[i] = true;
never_reset_pin_number(self->scl->pin->port, self->scl->pin->number);
never_reset_pin_number(self->sda->pin->port, self->scl->pin->number);
never_reset_pin_number(self->sda->pin->port, self->sda->pin->number);
break;
}
}
@ -209,21 +209,21 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
STATIC void i2c_clock_enable(uint8_t mask) {
//Note: hard reset required due to soft reboot issue.
#ifdef I2C1
if (mask & 1<<0) {
if (mask & (1 << 0)) {
__HAL_RCC_I2C1_CLK_ENABLE();
__HAL_RCC_I2C1_FORCE_RESET();
__HAL_RCC_I2C1_RELEASE_RESET();
}
#endif
#ifdef I2C2
if (mask & 1<<1) {
if (mask & (1 << 1)) {
__HAL_RCC_I2C2_CLK_ENABLE();
__HAL_RCC_I2C2_FORCE_RESET();
__HAL_RCC_I2C2_RELEASE_RESET();
}
#endif
#ifdef I2C3
if (mask & 1<<2) {
if (mask & (1 << 2)) {
__HAL_RCC_I2C3_CLK_ENABLE();
__HAL_RCC_I2C3_FORCE_RESET();
__HAL_RCC_I2C3_RELEASE_RESET();
@ -233,17 +233,17 @@ STATIC void i2c_clock_enable(uint8_t mask) {
STATIC void i2c_clock_disable(uint8_t mask) {
#ifdef I2C1
if (mask & 1<<0) {
if (mask & (1 << 0)) {
__HAL_RCC_I2C1_CLK_DISABLE();
}
#endif
#ifdef I2C2
if (mask & 1<<1) {
if (mask & (1 << 1)) {
__HAL_RCC_I2C2_CLK_DISABLE();
}
#endif
#ifdef I2C3
if (mask & 1<<2) {
if (mask & (1 << 2)) {
__HAL_RCC_I2C3_CLK_DISABLE();
}
#endif

@ -104,9 +104,9 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
//match pins to SPI objects
SPI_TypeDef * SPIx;
uint8_t sck_len = sizeof(mcu_spi_sck_list)/sizeof(*mcu_spi_sck_list);
uint8_t mosi_len = sizeof(mcu_spi_mosi_list)/sizeof(*mcu_spi_mosi_list);
uint8_t miso_len = sizeof(mcu_spi_miso_list)/sizeof(*mcu_spi_miso_list);
uint8_t sck_len = MP_ARRAY_SIZE(mcu_spi_sck_list);
uint8_t mosi_len = MP_ARRAY_SIZE(mcu_spi_mosi_list);
uint8_t miso_len = MP_ARRAY_SIZE(mcu_spi_miso_list);
bool spi_taken = false;
//SCK is not optional. MOSI and MISO are
@ -393,32 +393,32 @@ uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) {
STATIC void spi_clock_enable(uint8_t mask) {
#ifdef SPI1
if (mask & 1<<0) {
if (mask & (1 << 0)) {
__HAL_RCC_SPI1_CLK_ENABLE();
}
#endif
#ifdef SPI2
if (mask & 1<<1) {
if (mask & (1 << 1)) {
__HAL_RCC_SPI2_CLK_ENABLE();
}
#endif
#ifdef SPI3
if (mask & 1<<2) {
if (mask & (1 << 2)) {
__HAL_RCC_SPI3_CLK_ENABLE();
}
#endif
#ifdef SPI4
if (mask & 1<<3) {
if (mask & (1 << 3)) {
__HAL_RCC_SPI4_CLK_ENABLE();
}
#endif
#ifdef SPI5
if (mask & 1<<4) {
if (mask & (1 << 4)) {
__HAL_RCC_SPI5_CLK_ENABLE();
}
#endif
#ifdef SPI6
if (mask & 1<<5) {
if (mask & (1 << 5)) {
__HAL_RCC_SPI6_CLK_ENABLE();
}
#endif
@ -426,32 +426,32 @@ STATIC void spi_clock_enable(uint8_t mask) {
STATIC void spi_clock_disable(uint8_t mask) {
#ifdef SPI1
if (mask & 1<<0) {
if (mask & (1 << 0)) {
__HAL_RCC_SPI1_CLK_DISABLE();
}
#endif
#ifdef SPI2
if (mask & 1<<1) {
if (mask & (1 << 1)) {
__HAL_RCC_SPI2_CLK_DISABLE();
}
#endif
#ifdef SPI3
if (mask & 1<<2) {
if (mask & (1 << 2)) {
__HAL_RCC_SPI3_CLK_DISABLE();
}
#endif
#ifdef SPI4
if (mask & 1<<3) {
if (mask & (1 << 3)) {
__HAL_RCC_SPI4_CLK_DISABLE();
}
#endif
#ifdef SPI5
if (mask & 1<<4) {
if (mask & (1 << 4)) {
__HAL_RCC_SPI5_CLK_DISABLE();
}
#endif
#ifdef SPI6
if (mask & 1<<5) {
if (mask & (1 << 5)) {
__HAL_RCC_SPI6_CLK_DISABLE();
}
#endif

@ -79,8 +79,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self,
//match pins to UART objects
USART_TypeDef * USARTx;
uint8_t tx_len = sizeof(mcu_uart_tx_list) / sizeof(*mcu_uart_tx_list);
uint8_t rx_len = sizeof(mcu_uart_rx_list) / sizeof(*mcu_uart_rx_list);
uint8_t tx_len = MP_ARRAY_SIZE(mcu_uart_tx_list);
uint8_t rx_len = MP_ARRAY_SIZE(mcu_uart_rx_list);
bool uart_taken = false;
uint8_t uart_index = 0; //origin 0 corrected

@ -106,7 +106,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
uint32_t frequency,
bool variable_frequency) {
TIM_TypeDef * TIMx;
uint8_t tim_num = sizeof(mcu_tim_pin_list) / sizeof(*mcu_tim_pin_list);
uint8_t tim_num = MP_ARRAY_SIZE(mcu_tim_pin_list);
bool tim_chan_taken = false;
bool tim_taken_f_mismatch = false;
bool var_freq_mismatch = false;
@ -324,63 +324,63 @@ bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self
STATIC void tim_clock_enable(uint16_t mask) {
#ifdef TIM1
if (mask & 1<<0) {
if (mask & (1 << 0)) {
__HAL_RCC_TIM1_CLK_ENABLE();
}
#endif
#ifdef TIM2
if (mask & 1<<1) {
if (mask & (1 << 1)) {
__HAL_RCC_TIM2_CLK_ENABLE();
}
#endif
#ifdef TIM3
if (mask & 1<<2) {
if (mask & (1 << 2)) {
__HAL_RCC_TIM3_CLK_ENABLE();
}
#endif
#ifdef TIM4
if (mask & 1<<3) {
if (mask & (1 << 3)) {
__HAL_RCC_TIM4_CLK_ENABLE();
}
#endif
#ifdef TIM5
if (mask & 1<<4) {
if (mask & (1 << 4)) {
__HAL_RCC_TIM5_CLK_ENABLE();
}
#endif
//6 and 7 are reserved ADC timers
#ifdef TIM8
if (mask & 1<<7) {
if (mask & (1 << 7)) {
__HAL_RCC_TIM8_CLK_ENABLE();
}
#endif
#ifdef TIM9
if (mask & 1<<8) {
if (mask & (1 << 8)) {
__HAL_RCC_TIM9_CLK_ENABLE();
}
#endif
#ifdef TIM10
if (mask & 1<<9) {
if (mask & (1 << 9)) {
__HAL_RCC_TIM10_CLK_ENABLE();
}
#endif
#ifdef TIM11
if (mask & 1<<10) {
if (mask & (1 << 10)) {
__HAL_RCC_TIM11_CLK_ENABLE();
}
#endif
#ifdef TIM12
if (mask & 1<<11) {
if (mask & (1 << 11)) {
__HAL_RCC_TIM12_CLK_ENABLE();
}
#endif
#ifdef TIM13
if (mask & 1<<12) {
if (mask & (1 << 12)) {
__HAL_RCC_TIM13_CLK_ENABLE();
}
#endif
#ifdef TIM14
if (mask & 1<<13) {
if (mask & (1 << 13)) {
__HAL_RCC_TIM14_CLK_ENABLE();
}
#endif
@ -388,63 +388,63 @@ STATIC void tim_clock_enable(uint16_t mask) {
STATIC void tim_clock_disable(uint16_t mask) {
#ifdef TIM1
if (mask & 1<<0) {
if (mask & (1 << 0)) {
__HAL_RCC_TIM1_CLK_DISABLE();
}
#endif
#ifdef TIM2
if (mask & 1<<1) {
if (mask & (1 << 1)) {
__HAL_RCC_TIM2_CLK_DISABLE();
}
#endif
#ifdef TIM3
if (mask & 1<<2) {
if (mask & (1 << 2)) {
__HAL_RCC_TIM3_CLK_DISABLE();
}
#endif
#ifdef TIM4
if (mask & 1<<3) {
if (mask & (1 << 3)) {
__HAL_RCC_TIM4_CLK_DISABLE();
}
#endif
#ifdef TIM5
if (mask & 1<<4) {
if (mask & (1 << 4)) {
__HAL_RCC_TIM5_CLK_DISABLE();
}
#endif
//6 and 7 are reserved ADC timers
#ifdef TIM8
if (mask & 1<<7) {
if (mask & (1 << 7)) {
__HAL_RCC_TIM8_CLK_DISABLE();
}
#endif
#ifdef TIM9
if (mask & 1<<8) {
if (mask & (1 << 8)) {
__HAL_RCC_TIM9_CLK_DISABLE();
}
#endif
#ifdef TIM10
if (mask & 1<<9) {
if (mask & (1 << 9)) {
__HAL_RCC_TIM10_CLK_DISABLE();
}
#endif
#ifdef TIM11
if (mask & 1<<10) {
if (mask & (1 << 10)) {
__HAL_RCC_TIM11_CLK_DISABLE();
}
#endif
#ifdef TIM12
if (mask & 1<<11) {
if (mask & (1 << 11)) {
__HAL_RCC_TIM12_CLK_DISABLE();
}
#endif
#ifdef TIM13
if (mask & 1<<12) {
if (mask & (1 << 12)) {
__HAL_RCC_TIM13_CLK_DISABLE();
}
#endif
#ifdef TIM14
if (mask & 1<<13) {
if (mask & (1 << 13)) {
__HAL_RCC_TIM14_CLK_DISABLE();
}
#endif

Loading…
Cancel
Save