mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-14 18:40:37 +00:00
Change the variables for a switch and a LED to symbols defined by the macros
This commit is contained in:
parent
e4520e7aa7
commit
23ef8b2c64
@ -27,13 +27,13 @@
|
|||||||
#ifndef BOARD_H_
|
#ifndef BOARD_H_
|
||||||
#define BOARD_H_
|
#define BOARD_H_
|
||||||
|
|
||||||
#define LED_PORT P1OUT
|
#define CLK_LED 12u
|
||||||
#define LED_PIN BIT0
|
#define GPIO_LED GPION
|
||||||
#define LED_STATE_ON 1
|
#define GPIO_LED_PIN 1u
|
||||||
|
|
||||||
#define BUTTON_PORT P1IN
|
#define CLK_BUTTON 8u
|
||||||
#define BUTTON_PIN BIT1
|
#define GPIO_BUTTON GPIOJ
|
||||||
#define BUTTON_STATE_ACTIVE 0
|
#define GPIO_BUTTON_PIN 0u
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -28,9 +28,6 @@
|
|||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "msp.h"
|
#include "msp.h"
|
||||||
|
|
||||||
/* Frequency of the external crystal oscillator */
|
|
||||||
#define XTAL_FREQUENCY 25000000UL
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
// 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 );
|
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* USR_LED1 PN1 */
|
/* USR_LED1 ON1 */
|
||||||
SYSCTL->RCGCGPIO |= 1u << 12;
|
SYSCTL->RCGCGPIO |= TU_BIT(CLK_LED);
|
||||||
while (!(SYSCTL->PRGPIO & (1u << 12))) ;
|
while (!(SYSCTL->PRGPIO & TU_BIT(CLK_LED))) ;
|
||||||
GPION->DIR = 2u;
|
GPIO_LED->DIR = TU_BIT(GPIO_LED_PIN);
|
||||||
GPION->DEN = 2u;
|
GPIO_LED->DEN = TU_BIT(GPIO_LED_PIN);
|
||||||
|
|
||||||
/* USR_SW1 PJ0 */
|
/* USR_SW1 PJ0 */
|
||||||
SYSCTL->RCGCGPIO |= 1u << 8;
|
SYSCTL->RCGCGPIO |= TU_BIT(CLK_BUTTON);
|
||||||
while (!(SYSCTL->PRGPIO & (1u << 8))) ;
|
while (!(SYSCTL->PRGPIO & TU_BIT(CLK_BUTTON))) ;
|
||||||
GPIOJ->PUR = 1u;
|
GPIO_BUTTON->PUR = TU_BIT(GPIO_BUTTON_PIN);
|
||||||
GPIOJ->DEN = 1u;
|
GPIO_BUTTON->DEN = TU_BIT(GPIO_BUTTON_PIN);
|
||||||
|
|
||||||
/* UART PA0,1 */
|
/* UART PA0,1 */
|
||||||
SYSCTL->RCGCGPIO |= 1u << 0;
|
SYSCTL->RCGCGPIO |= 1u << 0;
|
||||||
@ -136,14 +133,14 @@ void board_init(void)
|
|||||||
void board_led_write(bool state)
|
void board_led_write(bool state)
|
||||||
{
|
{
|
||||||
if (state)
|
if (state)
|
||||||
GPION->DATA |= 2u;
|
GPIO_LED->DATA |= TU_BIT(GPIO_LED_PIN);
|
||||||
else
|
else
|
||||||
GPION->DATA &= ~2u;
|
GPIO_LED->DATA &= ~TU_BIT(GPIO_LED_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_button_read(void)
|
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)
|
int board_uart_read(uint8_t * buf, int len)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user