These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
UART/AutoBaud/uart_autobaud_test.c@0:bf7b9fba3924, 2011-03-20 (annotated)
- Committer:
- frank26080115
- Date:
- Sun Mar 20 05:38:56 2011 +0000
- Revision:
- 0:bf7b9fba3924
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frank26080115 | 0:bf7b9fba3924 | 1 | /***********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 2 | * @file uart_autobaud_test.c |
frank26080115 | 0:bf7b9fba3924 | 3 | * @purpose This example describes how to configure UART using auto-baud |
frank26080115 | 0:bf7b9fba3924 | 4 | * rate in interrupt mode |
frank26080115 | 0:bf7b9fba3924 | 5 | * @version 2.0 |
frank26080115 | 0:bf7b9fba3924 | 6 | * @date 21. May. 2010 |
frank26080115 | 0:bf7b9fba3924 | 7 | * @author NXP MCU SW Application Team |
frank26080115 | 0:bf7b9fba3924 | 8 | *--------------------------------------------------------------------- |
frank26080115 | 0:bf7b9fba3924 | 9 | * Software that is described herein is for illustrative purposes only |
frank26080115 | 0:bf7b9fba3924 | 10 | * which provides customers with programming information regarding the |
frank26080115 | 0:bf7b9fba3924 | 11 | * products. This software is supplied "AS IS" without any warranties. |
frank26080115 | 0:bf7b9fba3924 | 12 | * NXP Semiconductors assumes no responsibility or liability for the |
frank26080115 | 0:bf7b9fba3924 | 13 | * use of the software, conveys no license or title under any patent, |
frank26080115 | 0:bf7b9fba3924 | 14 | * copyright, or mask work right to the product. NXP Semiconductors |
frank26080115 | 0:bf7b9fba3924 | 15 | * reserves the right to make changes in the software without |
frank26080115 | 0:bf7b9fba3924 | 16 | * notification. NXP Semiconductors also make no representation or |
frank26080115 | 0:bf7b9fba3924 | 17 | * warranty that such application will be suitable for the specified |
frank26080115 | 0:bf7b9fba3924 | 18 | * use without further testing or modification. |
frank26080115 | 0:bf7b9fba3924 | 19 | **********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 20 | #include "lpc17xx_uart.h" |
frank26080115 | 0:bf7b9fba3924 | 21 | #include "lpc17xx_libcfg.h" |
frank26080115 | 0:bf7b9fba3924 | 22 | #include "lpc17xx_pinsel.h" |
frank26080115 | 0:bf7b9fba3924 | 23 | |
frank26080115 | 0:bf7b9fba3924 | 24 | /* Example group ----------------------------------------------------------- */ |
frank26080115 | 0:bf7b9fba3924 | 25 | /** @defgroup UART_AutoBaud AutoBaud |
frank26080115 | 0:bf7b9fba3924 | 26 | * @ingroup UART_Examples |
frank26080115 | 0:bf7b9fba3924 | 27 | * @{ |
frank26080115 | 0:bf7b9fba3924 | 28 | */ |
frank26080115 | 0:bf7b9fba3924 | 29 | |
frank26080115 | 0:bf7b9fba3924 | 30 | /************************** PRIVATE VARIABLES *************************/ |
frank26080115 | 0:bf7b9fba3924 | 31 | uint8_t syncmenu[] = "AutoBaudrate Status: Synchronous! \n\r"; |
frank26080115 | 0:bf7b9fba3924 | 32 | uint8_t menu1[] = "Hello NXP Semiconductors \n\r"; |
frank26080115 | 0:bf7b9fba3924 | 33 | uint8_t menu2[] = |
frank26080115 | 0:bf7b9fba3924 | 34 | "UART Auto Baudrate demo\n\r\t " |
frank26080115 | 0:bf7b9fba3924 | 35 | "MCU LPC17xx - ARM Cortex-M3 \n\r\t " |
frank26080115 | 0:bf7b9fba3924 | 36 | "UART0 - Auto Baud rate mode used \n\r"; |
frank26080115 | 0:bf7b9fba3924 | 37 | uint8_t menu3[] = "UART demo terminated!\n"; |
frank26080115 | 0:bf7b9fba3924 | 38 | |
frank26080115 | 0:bf7b9fba3924 | 39 | /* Synchronous Flag */ |
frank26080115 | 0:bf7b9fba3924 | 40 | __IO FlagStatus Synchronous; |
frank26080115 | 0:bf7b9fba3924 | 41 | |
frank26080115 | 0:bf7b9fba3924 | 42 | /************************** PRIVATE FUNCTIONS *************************/ |
frank26080115 | 0:bf7b9fba3924 | 43 | void UART0_IRQHandler(void); |
frank26080115 | 0:bf7b9fba3924 | 44 | |
frank26080115 | 0:bf7b9fba3924 | 45 | void print_menu(void); |
frank26080115 | 0:bf7b9fba3924 | 46 | |
frank26080115 | 0:bf7b9fba3924 | 47 | /*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/ |
frank26080115 | 0:bf7b9fba3924 | 48 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 49 | * @brief UART0 interrupt handler sub-routine |
frank26080115 | 0:bf7b9fba3924 | 50 | * @param None |
frank26080115 | 0:bf7b9fba3924 | 51 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 52 | **********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 53 | void UART0_IRQHandler(void) |
frank26080115 | 0:bf7b9fba3924 | 54 | { |
frank26080115 | 0:bf7b9fba3924 | 55 | // Call Standard UART 0 interrupt handler |
frank26080115 | 0:bf7b9fba3924 | 56 | uint32_t intsrc, tmp, tmp1; |
frank26080115 | 0:bf7b9fba3924 | 57 | |
frank26080115 | 0:bf7b9fba3924 | 58 | /* Determine the interrupt source */ |
frank26080115 | 0:bf7b9fba3924 | 59 | intsrc = UART_GetIntId(LPC_UART0); |
frank26080115 | 0:bf7b9fba3924 | 60 | tmp = intsrc & UART_IIR_INTID_MASK; |
frank26080115 | 0:bf7b9fba3924 | 61 | |
frank26080115 | 0:bf7b9fba3924 | 62 | // Receive Line Status |
frank26080115 | 0:bf7b9fba3924 | 63 | if (tmp == UART_IIR_INTID_RLS){ |
frank26080115 | 0:bf7b9fba3924 | 64 | // Check line status |
frank26080115 | 0:bf7b9fba3924 | 65 | tmp1 = UART_GetLineStatus(LPC_UART0); |
frank26080115 | 0:bf7b9fba3924 | 66 | // Mask out the Receive Ready and Transmit Holding empty status |
frank26080115 | 0:bf7b9fba3924 | 67 | tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \ |
frank26080115 | 0:bf7b9fba3924 | 68 | | UART_LSR_BI | UART_LSR_RXFE); |
frank26080115 | 0:bf7b9fba3924 | 69 | // If any error exist |
frank26080115 | 0:bf7b9fba3924 | 70 | if (tmp1) { |
frank26080115 | 0:bf7b9fba3924 | 71 | |
frank26080115 | 0:bf7b9fba3924 | 72 | while(tmp1){ |
frank26080115 | 0:bf7b9fba3924 | 73 | ; //implement error handling here |
frank26080115 | 0:bf7b9fba3924 | 74 | } |
frank26080115 | 0:bf7b9fba3924 | 75 | } |
frank26080115 | 0:bf7b9fba3924 | 76 | } |
frank26080115 | 0:bf7b9fba3924 | 77 | |
frank26080115 | 0:bf7b9fba3924 | 78 | |
frank26080115 | 0:bf7b9fba3924 | 79 | intsrc &= (UART_IIR_ABEO_INT | UART_IIR_ABTO_INT); |
frank26080115 | 0:bf7b9fba3924 | 80 | // Check if End of auto-baudrate interrupt or Auto baudrate time out |
frank26080115 | 0:bf7b9fba3924 | 81 | if (intsrc){ |
frank26080115 | 0:bf7b9fba3924 | 82 | // Clear interrupt pending |
frank26080115 | 0:bf7b9fba3924 | 83 | if(intsrc & UART_IIR_ABEO_INT) |
frank26080115 | 0:bf7b9fba3924 | 84 | UART_ABClearIntPending(LPC_UART0, UART_AUTOBAUD_INTSTAT_ABEO); |
frank26080115 | 0:bf7b9fba3924 | 85 | if (intsrc & UART_IIR_ABTO_INT) |
frank26080115 | 0:bf7b9fba3924 | 86 | UART_ABClearIntPending(LPC_UART0, UART_AUTOBAUD_INTSTAT_ABTO); |
frank26080115 | 0:bf7b9fba3924 | 87 | if (Synchronous == RESET) |
frank26080115 | 0:bf7b9fba3924 | 88 | { |
frank26080115 | 0:bf7b9fba3924 | 89 | /* Interrupt caused by End of auto-baud */ |
frank26080115 | 0:bf7b9fba3924 | 90 | if (intsrc & UART_AUTOBAUD_INTSTAT_ABEO){ |
frank26080115 | 0:bf7b9fba3924 | 91 | // Disable AB interrupt |
frank26080115 | 0:bf7b9fba3924 | 92 | UART_IntConfig(LPC_UART0, UART_INTCFG_ABEO, DISABLE); |
frank26080115 | 0:bf7b9fba3924 | 93 | // Set Sync flag |
frank26080115 | 0:bf7b9fba3924 | 94 | Synchronous = SET; |
frank26080115 | 0:bf7b9fba3924 | 95 | } |
frank26080115 | 0:bf7b9fba3924 | 96 | |
frank26080115 | 0:bf7b9fba3924 | 97 | /* Auto-Baudrate Time-Out interrupt (not implemented) */ |
frank26080115 | 0:bf7b9fba3924 | 98 | if (intsrc & UART_AUTOBAUD_INTSTAT_ABTO) { |
frank26080115 | 0:bf7b9fba3924 | 99 | /* Just clear this bit - Add your code here */ |
frank26080115 | 0:bf7b9fba3924 | 100 | UART_ABClearIntPending(LPC_UART0, UART_AUTOBAUD_INTSTAT_ABTO); |
frank26080115 | 0:bf7b9fba3924 | 101 | } |
frank26080115 | 0:bf7b9fba3924 | 102 | } |
frank26080115 | 0:bf7b9fba3924 | 103 | } |
frank26080115 | 0:bf7b9fba3924 | 104 | } |
frank26080115 | 0:bf7b9fba3924 | 105 | |
frank26080115 | 0:bf7b9fba3924 | 106 | |
frank26080115 | 0:bf7b9fba3924 | 107 | /*-------------------------PRIVATE FUNCTIONS------------------------------*/ |
frank26080115 | 0:bf7b9fba3924 | 108 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 109 | * @brief Print menu |
frank26080115 | 0:bf7b9fba3924 | 110 | * @param[in] None |
frank26080115 | 0:bf7b9fba3924 | 111 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 112 | **********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 113 | void print_menu(void) |
frank26080115 | 0:bf7b9fba3924 | 114 | { |
frank26080115 | 0:bf7b9fba3924 | 115 | UART_Send(LPC_UART0, menu1, sizeof(menu1), BLOCKING); |
frank26080115 | 0:bf7b9fba3924 | 116 | UART_Send(LPC_UART0, menu2, sizeof(menu2), BLOCKING); |
frank26080115 | 0:bf7b9fba3924 | 117 | } |
frank26080115 | 0:bf7b9fba3924 | 118 | |
frank26080115 | 0:bf7b9fba3924 | 119 | |
frank26080115 | 0:bf7b9fba3924 | 120 | /*-------------------------MAIN FUNCTION------------------------------*/ |
frank26080115 | 0:bf7b9fba3924 | 121 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 122 | * @brief c_entry: Main UART program body |
frank26080115 | 0:bf7b9fba3924 | 123 | * @param[in] None |
frank26080115 | 0:bf7b9fba3924 | 124 | * @return int |
frank26080115 | 0:bf7b9fba3924 | 125 | **********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 126 | int c_entry(void) |
frank26080115 | 0:bf7b9fba3924 | 127 | { |
frank26080115 | 0:bf7b9fba3924 | 128 | // UART Configuration structure variable |
frank26080115 | 0:bf7b9fba3924 | 129 | UART_CFG_Type UARTConfigStruct; |
frank26080115 | 0:bf7b9fba3924 | 130 | // UART FIFO configuration Struct variable |
frank26080115 | 0:bf7b9fba3924 | 131 | UART_FIFO_CFG_Type UARTFIFOConfigStruct; |
frank26080115 | 0:bf7b9fba3924 | 132 | // Pin configuration for UART0 |
frank26080115 | 0:bf7b9fba3924 | 133 | PINSEL_CFG_Type PinCfg; |
frank26080115 | 0:bf7b9fba3924 | 134 | // Auto baudrate configuration structure |
frank26080115 | 0:bf7b9fba3924 | 135 | UART_AB_CFG_Type ABConfig; |
frank26080115 | 0:bf7b9fba3924 | 136 | |
frank26080115 | 0:bf7b9fba3924 | 137 | uint32_t idx, len; |
frank26080115 | 0:bf7b9fba3924 | 138 | __IO FlagStatus exitflag; |
frank26080115 | 0:bf7b9fba3924 | 139 | uint8_t buffer[10]; |
frank26080115 | 0:bf7b9fba3924 | 140 | |
frank26080115 | 0:bf7b9fba3924 | 141 | /* |
frank26080115 | 0:bf7b9fba3924 | 142 | * Initialize UART0 pin connect |
frank26080115 | 0:bf7b9fba3924 | 143 | */ |
frank26080115 | 0:bf7b9fba3924 | 144 | PinCfg.Funcnum = 1; |
frank26080115 | 0:bf7b9fba3924 | 145 | PinCfg.OpenDrain = 0; |
frank26080115 | 0:bf7b9fba3924 | 146 | PinCfg.Pinmode = 0; |
frank26080115 | 0:bf7b9fba3924 | 147 | PinCfg.Pinnum = 2; |
frank26080115 | 0:bf7b9fba3924 | 148 | PinCfg.Portnum = 0; |
frank26080115 | 0:bf7b9fba3924 | 149 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:bf7b9fba3924 | 150 | PinCfg.Pinnum = 3; |
frank26080115 | 0:bf7b9fba3924 | 151 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:bf7b9fba3924 | 152 | |
frank26080115 | 0:bf7b9fba3924 | 153 | /* Initialize UART Configuration parameter structure to default state: |
frank26080115 | 0:bf7b9fba3924 | 154 | * Baudrate = 9600bps |
frank26080115 | 0:bf7b9fba3924 | 155 | * 8 data bit |
frank26080115 | 0:bf7b9fba3924 | 156 | * 1 Stop bit |
frank26080115 | 0:bf7b9fba3924 | 157 | * None parity |
frank26080115 | 0:bf7b9fba3924 | 158 | */ |
frank26080115 | 0:bf7b9fba3924 | 159 | UART_ConfigStructInit(&UARTConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 160 | |
frank26080115 | 0:bf7b9fba3924 | 161 | /* Initialize UART0 peripheral with given to corresponding parameter |
frank26080115 | 0:bf7b9fba3924 | 162 | * in this case, don't care the baudrate value UART initialized |
frank26080115 | 0:bf7b9fba3924 | 163 | * since this will be determine when running auto baudrate |
frank26080115 | 0:bf7b9fba3924 | 164 | */ |
frank26080115 | 0:bf7b9fba3924 | 165 | UART_Init(LPC_UART0, &UARTConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 166 | |
frank26080115 | 0:bf7b9fba3924 | 167 | /* Initialize FIFOConfigStruct to default state: |
frank26080115 | 0:bf7b9fba3924 | 168 | * - FIFO_DMAMode = DISABLE |
frank26080115 | 0:bf7b9fba3924 | 169 | * - FIFO_Level = UART_FIFO_TRGLEV0 |
frank26080115 | 0:bf7b9fba3924 | 170 | * - FIFO_ResetRxBuf = ENABLE |
frank26080115 | 0:bf7b9fba3924 | 171 | * - FIFO_ResetTxBuf = ENABLE |
frank26080115 | 0:bf7b9fba3924 | 172 | * - FIFO_State = ENABLE |
frank26080115 | 0:bf7b9fba3924 | 173 | */ |
frank26080115 | 0:bf7b9fba3924 | 174 | UART_FIFOConfigStructInit(&UARTFIFOConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 175 | |
frank26080115 | 0:bf7b9fba3924 | 176 | // Initialize FIFO for UART0 peripheral |
frank26080115 | 0:bf7b9fba3924 | 177 | UART_FIFOConfig(LPC_UART0, &UARTFIFOConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 178 | |
frank26080115 | 0:bf7b9fba3924 | 179 | |
frank26080115 | 0:bf7b9fba3924 | 180 | // Enable UART Transmit |
frank26080115 | 0:bf7b9fba3924 | 181 | UART_TxCmd(LPC_UART0, ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 182 | |
frank26080115 | 0:bf7b9fba3924 | 183 | |
frank26080115 | 0:bf7b9fba3924 | 184 | /* Enable UART End of Auto baudrate interrupt */ |
frank26080115 | 0:bf7b9fba3924 | 185 | UART_IntConfig(LPC_UART0, UART_INTCFG_ABEO, ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 186 | /* Enable UART Auto baudrate timeout interrupt */ |
frank26080115 | 0:bf7b9fba3924 | 187 | UART_IntConfig(LPC_UART0, UART_INTCFG_ABTO, ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 188 | |
frank26080115 | 0:bf7b9fba3924 | 189 | /* preemption = 1, sub-priority = 1 */ |
frank26080115 | 0:bf7b9fba3924 | 190 | NVIC_SetPriority(UART0_IRQn, ((0x01<<3)|0x01)); |
frank26080115 | 0:bf7b9fba3924 | 191 | /* Enable Interrupt for UART0 channel */ |
frank26080115 | 0:bf7b9fba3924 | 192 | NVIC_EnableIRQ(UART0_IRQn); |
frank26080115 | 0:bf7b9fba3924 | 193 | |
frank26080115 | 0:bf7b9fba3924 | 194 | |
frank26080115 | 0:bf7b9fba3924 | 195 | /* ---------------------- Auto baud rate section ----------------------- */ |
frank26080115 | 0:bf7b9fba3924 | 196 | // Reset Synchronous flag for auto-baudrate mode |
frank26080115 | 0:bf7b9fba3924 | 197 | Synchronous = RESET; |
frank26080115 | 0:bf7b9fba3924 | 198 | |
frank26080115 | 0:bf7b9fba3924 | 199 | // Configure Auto baud rate mode |
frank26080115 | 0:bf7b9fba3924 | 200 | ABConfig.ABMode = UART_AUTOBAUD_MODE0; |
frank26080115 | 0:bf7b9fba3924 | 201 | ABConfig.AutoRestart = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 202 | |
frank26080115 | 0:bf7b9fba3924 | 203 | // Start auto baudrate mode |
frank26080115 | 0:bf7b9fba3924 | 204 | UART_ABCmd(LPC_UART0, &ABConfig, ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 205 | print_menu(); |
frank26080115 | 0:bf7b9fba3924 | 206 | |
frank26080115 | 0:bf7b9fba3924 | 207 | /* Loop until auto baudrate mode complete */ |
frank26080115 | 0:bf7b9fba3924 | 208 | while (Synchronous == RESET); |
frank26080115 | 0:bf7b9fba3924 | 209 | |
frank26080115 | 0:bf7b9fba3924 | 210 | |
frank26080115 | 0:bf7b9fba3924 | 211 | // Print status of auto baudrate |
frank26080115 | 0:bf7b9fba3924 | 212 | UART_Send(LPC_UART0, syncmenu, sizeof(syncmenu), BLOCKING); |
frank26080115 | 0:bf7b9fba3924 | 213 | /* ---------------------- End of Auto baud rate section ----------------------- */ |
frank26080115 | 0:bf7b9fba3924 | 214 | |
frank26080115 | 0:bf7b9fba3924 | 215 | // print welcome screen |
frank26080115 | 0:bf7b9fba3924 | 216 | print_menu(); |
frank26080115 | 0:bf7b9fba3924 | 217 | |
frank26080115 | 0:bf7b9fba3924 | 218 | // reset exit flag |
frank26080115 | 0:bf7b9fba3924 | 219 | exitflag = RESET; |
frank26080115 | 0:bf7b9fba3924 | 220 | |
frank26080115 | 0:bf7b9fba3924 | 221 | /* Read some data from the buffer */ |
frank26080115 | 0:bf7b9fba3924 | 222 | while (exitflag == RESET) |
frank26080115 | 0:bf7b9fba3924 | 223 | { |
frank26080115 | 0:bf7b9fba3924 | 224 | len = 0; |
frank26080115 | 0:bf7b9fba3924 | 225 | while (len == 0) |
frank26080115 | 0:bf7b9fba3924 | 226 | { |
frank26080115 | 0:bf7b9fba3924 | 227 | len = UART_Receive(LPC_UART0, buffer, sizeof(buffer), NONE_BLOCKING); |
frank26080115 | 0:bf7b9fba3924 | 228 | } |
frank26080115 | 0:bf7b9fba3924 | 229 | |
frank26080115 | 0:bf7b9fba3924 | 230 | /* Got some data */ |
frank26080115 | 0:bf7b9fba3924 | 231 | idx = 0; |
frank26080115 | 0:bf7b9fba3924 | 232 | while (idx < len) |
frank26080115 | 0:bf7b9fba3924 | 233 | { |
frank26080115 | 0:bf7b9fba3924 | 234 | if (buffer[idx] == 27) |
frank26080115 | 0:bf7b9fba3924 | 235 | { |
frank26080115 | 0:bf7b9fba3924 | 236 | /* ESC key, set exit flag */ |
frank26080115 | 0:bf7b9fba3924 | 237 | UART_Send(LPC_UART0, menu3, sizeof(menu3), BLOCKING); |
frank26080115 | 0:bf7b9fba3924 | 238 | exitflag = SET; |
frank26080115 | 0:bf7b9fba3924 | 239 | } |
frank26080115 | 0:bf7b9fba3924 | 240 | else if (buffer[idx] == 'r') |
frank26080115 | 0:bf7b9fba3924 | 241 | { |
frank26080115 | 0:bf7b9fba3924 | 242 | print_menu(); |
frank26080115 | 0:bf7b9fba3924 | 243 | } |
frank26080115 | 0:bf7b9fba3924 | 244 | else |
frank26080115 | 0:bf7b9fba3924 | 245 | { |
frank26080115 | 0:bf7b9fba3924 | 246 | /* Echo it back */ |
frank26080115 | 0:bf7b9fba3924 | 247 | UART_Send(LPC_UART0, &buffer[idx], 1, BLOCKING); |
frank26080115 | 0:bf7b9fba3924 | 248 | } |
frank26080115 | 0:bf7b9fba3924 | 249 | idx++; |
frank26080115 | 0:bf7b9fba3924 | 250 | } |
frank26080115 | 0:bf7b9fba3924 | 251 | } |
frank26080115 | 0:bf7b9fba3924 | 252 | |
frank26080115 | 0:bf7b9fba3924 | 253 | // wait for current transmission complete - THR must be empty |
frank26080115 | 0:bf7b9fba3924 | 254 | while (UART_CheckBusy(LPC_UART0) == SET); |
frank26080115 | 0:bf7b9fba3924 | 255 | |
frank26080115 | 0:bf7b9fba3924 | 256 | // DeInitialize UART0 peripheral |
frank26080115 | 0:bf7b9fba3924 | 257 | UART_DeInit(LPC_UART0); |
frank26080115 | 0:bf7b9fba3924 | 258 | |
frank26080115 | 0:bf7b9fba3924 | 259 | /* Loop forever */ |
frank26080115 | 0:bf7b9fba3924 | 260 | while(1); |
frank26080115 | 0:bf7b9fba3924 | 261 | return 1; |
frank26080115 | 0:bf7b9fba3924 | 262 | } |
frank26080115 | 0:bf7b9fba3924 | 263 | |
frank26080115 | 0:bf7b9fba3924 | 264 | /* With ARM and GHS toolsets, the entry point is main() - this will |
frank26080115 | 0:bf7b9fba3924 | 265 | allow the linker to generate wrapper code to setup stacks, allocate |
frank26080115 | 0:bf7b9fba3924 | 266 | heap area, and initialize and copy code and data segments. For GNU |
frank26080115 | 0:bf7b9fba3924 | 267 | toolsets, the entry point is through __start() in the crt0_gnu.asm |
frank26080115 | 0:bf7b9fba3924 | 268 | file, and that startup code will setup stacks and data */ |
frank26080115 | 0:bf7b9fba3924 | 269 | int main(void) |
frank26080115 | 0:bf7b9fba3924 | 270 | { |
frank26080115 | 0:bf7b9fba3924 | 271 | return c_entry(); |
frank26080115 | 0:bf7b9fba3924 | 272 | } |
frank26080115 | 0:bf7b9fba3924 | 273 | |
frank26080115 | 0:bf7b9fba3924 | 274 | |
frank26080115 | 0:bf7b9fba3924 | 275 | #ifdef DEBUG |
frank26080115 | 0:bf7b9fba3924 | 276 | /******************************************************************************* |
frank26080115 | 0:bf7b9fba3924 | 277 | * @brief Reports the name of the source file and the source line number |
frank26080115 | 0:bf7b9fba3924 | 278 | * where the CHECK_PARAM error has occurred. |
frank26080115 | 0:bf7b9fba3924 | 279 | * @param[in] file Pointer to the source file name |
frank26080115 | 0:bf7b9fba3924 | 280 | * @param[in] line assert_param error line source number |
frank26080115 | 0:bf7b9fba3924 | 281 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 282 | *******************************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 283 | void check_failed(uint8_t *file, uint32_t line) |
frank26080115 | 0:bf7b9fba3924 | 284 | { |
frank26080115 | 0:bf7b9fba3924 | 285 | /* User can add his own implementation to report the file name and line number, |
frank26080115 | 0:bf7b9fba3924 | 286 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
frank26080115 | 0:bf7b9fba3924 | 287 | |
frank26080115 | 0:bf7b9fba3924 | 288 | /* Infinite loop */ |
frank26080115 | 0:bf7b9fba3924 | 289 | while(1); |
frank26080115 | 0:bf7b9fba3924 | 290 | } |
frank26080115 | 0:bf7b9fba3924 | 291 | #endif |