change the board_leds API to on_mask, off_mask
getting led toggling per second on host demo add greeting message
This commit is contained in:
parent
799c709524
commit
8cc4c6f52d
|
@ -98,7 +98,7 @@
|
|||
//--------------------------------------------------------------------+
|
||||
// Init board peripherals : Clock, UART, LEDs, Buttons
|
||||
void board_init(void);
|
||||
void board_leds(uint32_t mask, uint32_t state);
|
||||
void board_leds(uint32_t on_mask, uint32_t off_mask);
|
||||
uint32_t board_uart_send(uint8_t *buffer, uint32_t length);
|
||||
uint32_t board_uart_recv(uint8_t *buffer, uint32_t length);
|
||||
|
||||
|
|
|
@ -43,15 +43,93 @@
|
|||
|
||||
#define UART_PORT LPC_USART0
|
||||
|
||||
#if 0
|
||||
static const struct {
|
||||
uint8_t port;
|
||||
uint8_t pin;
|
||||
}leds[CFG_LED_NUMBER] = { {0, 8} };
|
||||
void board_init(void)
|
||||
{
|
||||
SystemInit();
|
||||
CGU_Init();
|
||||
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
|
||||
|
||||
// USB0 Power: EA4357 channel B U20 GPIO26 active low (base board), P2_3 on LPC4357
|
||||
scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus Power
|
||||
|
||||
// USB1 Power: EA4357 channel A U20 is enabled by SJ5 connected to pad 1-2, no more action required
|
||||
scu_pinmux(0x2, 5, MD_PLN | MD_EZI | MD_ZI, FUNC2); // USB1_VBUS monitor presence, must be high for bus reset occur
|
||||
|
||||
// init I2C and set up MIC2555 to have 15k pull-down on USB1 D+ & D-
|
||||
I2C_Init(LPC_I2C0, 100000);
|
||||
I2C_Cmd(LPC_I2C0, ENABLE);
|
||||
|
||||
pca9532_init(); // Leds Init
|
||||
|
||||
// ASSERT_INT(0x058d, mic255_get_vendorid(), (void) 0); // verify vendor id
|
||||
// ASSERT( mic255_regs_write(6, BIN8(1100)), (void) 0); // pull down D+/D- for host
|
||||
|
||||
#if CFG_UART_ENABLE
|
||||
//------------- UART init -------------//
|
||||
scu_pinmux(0xF ,10 , MD_PDN, FUNC1); // PF.10 : UART0_TXD
|
||||
scu_pinmux(0xF ,11 , MD_PLN|MD_EZI|MD_ZI, FUNC1); // PF.11 : UART0_RXD
|
||||
|
||||
UART_CFG_Type UARTConfigStruct;
|
||||
UART_ConfigStructInit(&UARTConfigStruct);
|
||||
UARTConfigStruct.Baud_rate = CFG_UART_BAUDRATE;
|
||||
UARTConfigStruct.Clock_Speed = 0;
|
||||
|
||||
UART_Init(UART_PORT, &UARTConfigStruct);
|
||||
UART_TxCmd(UART_PORT, ENABLE); // Enable UART Transmit
|
||||
#endif
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// LEDS
|
||||
//--------------------------------------------------------------------+
|
||||
void board_leds(uint32_t on_mask, uint32_t off_mask)
|
||||
{
|
||||
pca9532_setLeds( on_mask << 8, off_mask << 8);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// UART
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_UART_ENABLE
|
||||
uint32_t board_uart_send(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
return UART_Send(UART_PORT, buffer, length, BLOCKING);
|
||||
}
|
||||
|
||||
uint32_t board_uart_recv(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
return UART_Receive(UART_PORT, buffer, length, BLOCKING);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Initialize the trim potentiometer, i.e. ADC connected to TrimPot on
|
||||
* Base Board.
|
||||
*
|
||||
*****************************************************************************/
|
||||
//void trimpot_init(void)
|
||||
//{
|
||||
// // pinsel for AD0.3 on p7.5
|
||||
// scu_pinmux( 7 , 5 , PDN_DISABLE | PUP_DISABLE | INBUF_DISABLE, 0 );
|
||||
// LPC_SCU->ENAIO0 |= (1<<3);
|
||||
//
|
||||
// ADC_Init(LPC_ADC0, 400000, 10);
|
||||
//
|
||||
// ADC_IntConfig(LPC_ADC0, ADC_ADINTEN2, DISABLE);
|
||||
// ADC_ChannelCmd(LPC_ADC0, ADC_CH_TRIMPOT, ENABLE);
|
||||
//}
|
||||
|
||||
//------------- MIC2555 external OTG transceiver on USB1 -------------//
|
||||
|
||||
// MIC2555 1YML = 0101111, 0YML = 0101101
|
||||
#define MIC255_ADDR BIN8(0101111)
|
||||
//#define MIC255_ADDR BIN8(0101111)
|
||||
|
||||
//static uint8_t mic255_regs_read(uint8_t regs_addr)
|
||||
//{
|
||||
|
@ -103,104 +181,4 @@ static const struct {
|
|||
// return (vendor_high << 8) | vendor_low;
|
||||
//}
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
SystemInit();
|
||||
CGU_Init();
|
||||
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
|
||||
|
||||
// USB0 Power: EA4357 channel B U20 GPIO26 active low (base board), P2_3 on LPC4357
|
||||
scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus Power
|
||||
|
||||
// USB1 Power: EA4357 channel A U20 is enabled by SJ5 connected to pad 1-2, no more action required
|
||||
scu_pinmux(0x2, 5, MD_PLN | MD_EZI | MD_ZI, FUNC2); // USB1_VBUS monitor presence, must be high for bus reset occur
|
||||
|
||||
// init I2C and set up MIC2555 to have 15k pull-down on USB1 D+ & D-
|
||||
// I2C_Init(LPC_I2C0, 100000);
|
||||
// I2C_Cmd(LPC_I2C0, ENABLE);
|
||||
//
|
||||
// ASSERT_INT(0x058d, mic255_get_vendorid(), (void) 0); // verify vendor id
|
||||
// ASSERT( mic255_regs_write(6, BIN8(1100)), (void) 0); // pull down D+/D- for host
|
||||
|
||||
#if 0
|
||||
// Leds Init
|
||||
for (uint8_t i=0; i<CFG_LED_NUMBER; i++)
|
||||
{
|
||||
scu_pinmux(leds[i].port, leds[i].pin, MD_PUP|MD_EZI|MD_ZI, 0); // MD_PDN
|
||||
GPIO_SetDir(leds[i].port, BIT_(leds[i].pin), 1); // output
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CFG_UART_ENABLE
|
||||
//------------- UART init -------------//
|
||||
scu_pinmux(0xF ,10 , MD_PDN, FUNC1); // PF.10 : UART0_TXD
|
||||
scu_pinmux(0xF ,11 , MD_PLN|MD_EZI|MD_ZI, FUNC1); // PF.11 : UART0_RXD
|
||||
|
||||
UART_CFG_Type UARTConfigStruct;
|
||||
UART_ConfigStructInit(&UARTConfigStruct);
|
||||
UARTConfigStruct.Baud_rate = CFG_UART_BAUDRATE;
|
||||
UARTConfigStruct.Clock_Speed = 0;
|
||||
|
||||
UART_Init(UART_PORT, &UARTConfigStruct);
|
||||
UART_TxCmd(UART_PORT, ENABLE); // Enable UART Transmit
|
||||
#endif
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// LEDS
|
||||
//--------------------------------------------------------------------+
|
||||
void board_leds(uint32_t mask, uint32_t state) __attribute__ ((warning("not supported yet")));
|
||||
void board_leds(uint32_t mask, uint32_t state)
|
||||
{
|
||||
#if 0
|
||||
uint8_t i;
|
||||
for(i=0; i<CFG_LED_NUMBER; i++)
|
||||
{
|
||||
if ( mask & BIT_(i) )
|
||||
{
|
||||
(mask & state) ? GPIO_SetValue(leds[i].port, BIT_(leds[i].pin)) : GPIO_ClearValue(leds[i].port, BIT_(leds[i].pin)) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// UART
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_UART_ENABLE
|
||||
uint32_t board_uart_send(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
return UART_Send(UART_PORT, buffer, length, BLOCKING);
|
||||
}
|
||||
|
||||
uint32_t board_uart_recv(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
return UART_Receive(UART_PORT, buffer, length, BLOCKING);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Initialize the trim potentiometer, i.e. ADC connected to TrimPot on
|
||||
* Base Board.
|
||||
*
|
||||
*****************************************************************************/
|
||||
//void trimpot_init(void)
|
||||
//{
|
||||
// // pinsel for AD0.3 on p7.5
|
||||
// scu_pinmux( 7 , 5 , PDN_DISABLE | PUP_DISABLE | INBUF_DISABLE, 0 );
|
||||
// LPC_SCU->ENAIO0 |= (1<<3);
|
||||
//
|
||||
// ADC_Init(LPC_ADC0, 400000, 10);
|
||||
//
|
||||
// ADC_IntConfig(LPC_ADC0, ADC_ADINTEN2, DISABLE);
|
||||
// ADC_ChannelCmd(LPC_ADC0, ADC_CH_TRIMPOT, ENABLE);
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -60,11 +60,9 @@
|
|||
#include "lpc43xx_cgu.h"
|
||||
#include "lpc43xx_gpio.h"
|
||||
#include "lpc43xx_uart.h"
|
||||
#include "lpc43xx_i2c.h"
|
||||
|
||||
#define EA_BASE_BOARD
|
||||
#ifdef EA_BASE_BOARD
|
||||
#include "oem_base_board/pca9532.h"
|
||||
#endif
|
||||
#include "oem_base_board/pca9532.h" // LEDs
|
||||
|
||||
#define CFG_LED_NUMBER 0
|
||||
#define CFG_LED_ON (1)
|
||||
|
|
|
@ -17,18 +17,20 @@
|
|||
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
|
||||
#endif
|
||||
|
||||
void print_greeting(void);
|
||||
int main(void)
|
||||
{
|
||||
uint32_t current_tick = system_ticks;
|
||||
|
||||
board_init();
|
||||
print_greeting();
|
||||
|
||||
tusb_init();
|
||||
|
||||
//------------- application task init -------------//
|
||||
keyboard_app_init();
|
||||
mouse_app_init();
|
||||
|
||||
printf("reset\n");
|
||||
while (1)
|
||||
{
|
||||
tusb_task_runner();
|
||||
|
@ -37,17 +39,30 @@ int main(void)
|
|||
|
||||
if (current_tick + CFG_TICKS_PER_SECOND < system_ticks)
|
||||
{
|
||||
static uint8_t timeout_10_ms = 0;
|
||||
timeout_10_ms = (timeout_10_ms+1) % 10;
|
||||
if (timeout_10_ms % 10 == 0)
|
||||
{
|
||||
printf("tinyusb: " __DATE__ "\t" __TIME__ "\n"); // toggle leds on EA4357 is quite troublesome
|
||||
}
|
||||
|
||||
current_tick += CFG_TICKS_PER_SECOND;
|
||||
board_leds(0x01, (current_tick/CFG_TICKS_PER_SECOND)%2); /* Toggle LED once per second */
|
||||
|
||||
/* Toggle LED once per second */
|
||||
if ( (current_tick/CFG_TICKS_PER_SECOND) % 2)
|
||||
{
|
||||
board_leds(0x01, 0x00);
|
||||
}
|
||||
else
|
||||
{
|
||||
board_leds(0x00, 0x01);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_greeting(void)
|
||||
{
|
||||
printf("\
|
||||
--------------------------------------------------------------------\
|
||||
- Host Demo (a tinyusb example)\r\n\
|
||||
- if you find any bugs or get any questions, feel free to file an\r\n\
|
||||
- issue at https://github.com/hathach/tinyusb\r\n\
|
||||
--------------------------------------------------------------------\r\n\r\n"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue