1 /******************************************************************************
3 * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Source File
4 * Blink a LED using CM3 SysTick
7 *----------------------------------------------------------------------------
9 * Copyright (C) 2008 ARM Limited. All rights reserved.
11 * ARM Limited (ARM) is supplying this software for use with Cortex-M3
12 * processor based microcontrollers. This file can be freely distributed
13 * within development tools that are supporting such ARM based processors.
15 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
16 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
18 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
19 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
21 ******************************************************************************/
26 uint32_t msTicks; /* counts 1ms timeTicks */
27 /*----------------------------------------------------------------------------
29 *----------------------------------------------------------------------------*/
30 void SysTick_Handler(void) {
31 msTicks++; /* increment counter necessary in Delay() */
34 /*------------------------------------------------------------------------------
35 delays number of tick Systicks (happens every 1 ms)
36 *------------------------------------------------------------------------------*/
37 __inline static void Delay (uint32_t dlyTicks) {
41 while ((msTicks - curTicks) < dlyTicks);
44 /*------------------------------------------------------------------------------
46 *------------------------------------------------------------------------------*/
47 __inline static void LED_Config(void) {
49 GPIO1->FIODIR = (1<<29)|(1<<18); /* LEDs on PORT1 18 & 29 are Output */
52 /*------------------------------------------------------------------------------
54 *------------------------------------------------------------------------------*/
55 __inline static void LED_On (uint32_t led) {
57 GPIO1->FIOPIN |= (led); /* Turn On LED */
61 /*------------------------------------------------------------------------------
63 *------------------------------------------------------------------------------*/
64 __inline static void LED_Off (uint32_t led) {
66 GPIO1->FIOPIN &= ~(led); /* Turn Off LED */
71 LED_On ((1<<29)); /* Turn on the LED. */
72 LED_On ((1<<18)); /* Turn on the LED. */
73 Delay (100); /* delay 100 Msec */
74 LED_Off ((1<<29)); /* Turn on the LED. */
75 Delay (100); /* delay 100 Msec */
76 LED_Off ((1<<18)); /* Turn on the LED. */
77 LED_On ((1<<29)); /* Turn on the LED. */
78 Delay (100); /* delay 100 Msec */
82 /*----------------------------------------------------------------------------
84 *----------------------------------------------------------------------------*/
87 SystemInit(); /* setup clocks */
89 if (SysTick_Config(SystemFrequency / 1000)) { /* Setup SysTick Timer for 1 msec interrupts */
90 while (1); /* Capture error */
95 VCOM_Init(); // VCOM Initialization
97 USB_Init(); // USB Initialization
99 USB_Connect(TRUE); // USB Connect
102 while (!USB_Configuration) ; // wait until USB is configured
104 while (1) { // Loop forever
105 VCOM_Serial2Usb(); // read serial port and initiate USB event
106 VCOM_CheckSerialState();