From 23ef8b2c64aea2217254b34a8b34cf7cc6d4e364 Mon Sep 17 00:00:00 2001 From: kkitayam <45088311+kkitayam@users.noreply.github.com> Date: Sat, 6 Nov 2021 19:32:15 +0900 Subject: [PATCH] Change the variables for a switch and a LED to symbols defined by the macros --- .../msp432e4/boards/msp_exp432e401y/board.h | 12 ++++----- hw/bsp/msp432e4/family.c | 27 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h b/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h index b449f3ca4..3130d663b 100644 --- a/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h +++ b/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h @@ -27,13 +27,13 @@ #ifndef BOARD_H_ #define BOARD_H_ -#define LED_PORT P1OUT -#define LED_PIN BIT0 -#define LED_STATE_ON 1 +#define CLK_LED 12u +#define GPIO_LED GPION +#define GPIO_LED_PIN 1u -#define BUTTON_PORT P1IN -#define BUTTON_PIN BIT1 -#define BUTTON_STATE_ACTIVE 0 +#define CLK_BUTTON 8u +#define GPIO_BUTTON GPIOJ +#define GPIO_BUTTON_PIN 0u #ifdef __cplusplus extern "C" { diff --git a/hw/bsp/msp432e4/family.c b/hw/bsp/msp432e4/family.c index b20af563b..7114da693 100644 --- a/hw/bsp/msp432e4/family.c +++ b/hw/bsp/msp432e4/family.c @@ -28,9 +28,6 @@ #include "board.h" #include "msp.h" -/* Frequency of the external crystal oscillator */ -#define XTAL_FREQUENCY 25000000UL - //--------------------------------------------------------------------+ // Forward USB interrupt events to TinyUSB IRQ Handler //--------------------------------------------------------------------+ @@ -82,17 +79,17 @@ void board_init(void) NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); #endif - /* USR_LED1 PN1 */ - SYSCTL->RCGCGPIO |= 1u << 12; - while (!(SYSCTL->PRGPIO & (1u << 12))) ; - GPION->DIR = 2u; - GPION->DEN = 2u; + /* USR_LED1 ON1 */ + SYSCTL->RCGCGPIO |= TU_BIT(CLK_LED); + while (!(SYSCTL->PRGPIO & TU_BIT(CLK_LED))) ; + GPIO_LED->DIR = TU_BIT(GPIO_LED_PIN); + GPIO_LED->DEN = TU_BIT(GPIO_LED_PIN); /* USR_SW1 PJ0 */ - SYSCTL->RCGCGPIO |= 1u << 8; - while (!(SYSCTL->PRGPIO & (1u << 8))) ; - GPIOJ->PUR = 1u; - GPIOJ->DEN = 1u; + SYSCTL->RCGCGPIO |= TU_BIT(CLK_BUTTON); + while (!(SYSCTL->PRGPIO & TU_BIT(CLK_BUTTON))) ; + GPIO_BUTTON->PUR = TU_BIT(GPIO_BUTTON_PIN); + GPIO_BUTTON->DEN = TU_BIT(GPIO_BUTTON_PIN); /* UART PA0,1 */ SYSCTL->RCGCGPIO |= 1u << 0; @@ -136,14 +133,14 @@ void board_init(void) void board_led_write(bool state) { if (state) - GPION->DATA |= 2u; + GPIO_LED->DATA |= TU_BIT(GPIO_LED_PIN); else - GPION->DATA &= ~2u; + GPIO_LED->DATA &= ~TU_BIT(GPIO_LED_PIN); } uint32_t board_button_read(void) { - return (GPIOJ->DATA & 1u) ? 0u : 1u; + return (GPIO_BUTTON->DATA & TU_BIT(GPIO_BUTTON_PIN)) ? 0u : 1u; } int board_uart_read(uint8_t * buf, int len)