generated from Embedded_Projects/MPyATE_Template
GPIO: Use pin mask table.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
4dbda61014
commit
daa2a698d2
|
@ -95,7 +95,7 @@ static inline uint16_t app_gpio_read_reg_cfg(void) {
|
|||
uint16_t ret = 0x0000U;
|
||||
|
||||
for (uint8_t i = 0; i < APP_GPIO_PIN_COUNT; i++) {
|
||||
uint32_t dir = GPIO->DIR[0] & (1U << s_app_gpio_id_table[i]);
|
||||
uint32_t dir = GPIO->DIR[0] & (s_app_gpio_mask_table[i]);
|
||||
if (dir == 0UL) {
|
||||
/* Input mode */
|
||||
ret |= (2U << (2 * i));
|
||||
|
@ -115,10 +115,10 @@ static inline void app_gpio_write_reg_cfg(uint16_t data) {
|
|||
for (uint8_t i = 0; i < APP_GPIO_PIN_COUNT; i++) {
|
||||
if (data & (2U << (2 * i))) {
|
||||
/* Input mode */
|
||||
GPIO->DIRCLR[0] = (1U << s_app_gpio_id_table[i]);
|
||||
GPIO->DIRCLR[0] = (s_app_gpio_mask_table[i]);
|
||||
} else {
|
||||
/* Output mode */
|
||||
GPIO->DIRSET[0] = (1U << s_app_gpio_id_table[i]);
|
||||
GPIO->DIRSET[0] = (s_app_gpio_mask_table[i]);
|
||||
|
||||
if (data & (1U << (2 * i))) {
|
||||
/* OD mode */
|
||||
|
@ -147,7 +147,7 @@ static inline uint16_t app_gpio_read_reg_output(void) {
|
|||
uint16_t ret = 0x0000U;
|
||||
|
||||
for (uint8_t i = 0; i < APP_GPIO_PIN_COUNT; i++) {
|
||||
if (GPIO->SET[0] & (1U << s_app_gpio_id_table[i])) {
|
||||
if (GPIO->SET[0] & (s_app_gpio_mask_table[i])) {
|
||||
ret |= (1U << i);
|
||||
}
|
||||
}
|
||||
|
@ -158,9 +158,9 @@ static inline uint16_t app_gpio_read_reg_output(void) {
|
|||
static inline void app_gpio_write_reg_output(uint16_t data) {
|
||||
for (uint8_t i = 0; i < APP_GPIO_PIN_COUNT; i++) {
|
||||
if (data & (1 << i)) {
|
||||
GPIO->SET[0] = (1U << s_app_gpio_id_table[i]);
|
||||
GPIO->SET[0] = (s_app_gpio_mask_table[i]);
|
||||
} else {
|
||||
GPIO->CLR[0] = (1U << s_app_gpio_id_table[i]);
|
||||
GPIO->CLR[0] = (s_app_gpio_mask_table[i]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue