mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-14 04:18:56 +00:00
running blinking example
This commit is contained in:
parent
4ec23ea786
commit
e4a69a6f71
@ -58,18 +58,14 @@ const static struct {
|
||||
void board_init(void)
|
||||
{
|
||||
CGU_Init();
|
||||
SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/1000 ); /* 1 ms Timer */
|
||||
SysTick_Config( CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/TICKS_PER_SECOND ); /* 1 ms Timer */
|
||||
|
||||
/* Turn on 5V USB VBUS TODO Should be Host-only */
|
||||
scu_pinmux(0x2, 6, MD_PUP | MD_EZI, FUNC4); // P2_6 USB1_PWR_EN, USB1 VBus function
|
||||
scu_pinmux(0x2, 5, MD_PLN | MD_EZI | MD_ZI, FUNC2); // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
|
||||
|
||||
/* Turn on 5V USB VBUS TODO Should be Host-only */
|
||||
#if 1 //(BOARD == BOARD_XPLORER)
|
||||
scu_pinmux(0x1, 7, MD_PUP | MD_EZI, FUNC4); // P1_7 USB0_PWR_EN, USB0 VBus function Xplorer
|
||||
#else
|
||||
scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7); // P2_3 USB0_PWR_EN, USB0 VBus function Farnell
|
||||
#endif
|
||||
|
||||
// Leds Init
|
||||
uint8_t i;
|
||||
|
34
demos/host/main.c
Normal file
34
demos/host/main.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include "boards/board.h"
|
||||
#include "tusb.h"
|
||||
|
||||
#if defined(__CODE_RED)
|
||||
#include <cr_section_macros.h>
|
||||
#include <NXP/crp.h>
|
||||
// Variable to store CRP value in. Will be placed automatically
|
||||
// by the linker when "Enable Code Read Protect" selected.
|
||||
// See crp.h header for more information
|
||||
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
|
||||
#endif
|
||||
|
||||
volatile uint32_t system_tick = 0;
|
||||
void SysTick_Handler (void)
|
||||
{
|
||||
system_tick++;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint32_t current_tick = system_tick;
|
||||
|
||||
board_init();
|
||||
tusb_init(0);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (current_tick + 1000 < system_tick)
|
||||
{
|
||||
current_tick += 1000;
|
||||
board_leds(0x03, (current_tick/1000)%2); /* Toggle LED once per second */
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user