Date: March 20, 2011 This library is created from "LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library (GNU, Keil, IAR) (Jan 28, 2011)", available from NXP's website, under "All microcontrollers support documents" [[http://ics.nxp.com/support/documents/microcontrollers/?type=software]] You will need to follow [[/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h]] while using this library Examples provided here [[/users/frank26080115/programs/LPC1700CMSIS_Examples/]] The beautiful thing is that NXP does not place copyright protection on any of the files in here Only a few modifications are made to make it compile with the mbed online compiler, I fixed some warnings as well. This is untested as of March 20, 2011 Forum post about this library: [[/forum/mbed/topic/2030/]]
debug_frmwrk.c@0:84d7747641aa, 2011-03-20 (annotated)
- Committer:
- frank26080115
- Date:
- Sun Mar 20 18:45:15 2011 +0000
- Revision:
- 0:84d7747641aa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frank26080115 | 0:84d7747641aa | 1 | /***********************************************************************//** |
frank26080115 | 0:84d7747641aa | 2 | * @file debug_frmwrk.c |
frank26080115 | 0:84d7747641aa | 3 | * @brief Contains some utilities that used for debugging through UART |
frank26080115 | 0:84d7747641aa | 4 | * @version 2.0 |
frank26080115 | 0:84d7747641aa | 5 | * @date 21. May. 2010 |
frank26080115 | 0:84d7747641aa | 6 | * @author NXP MCU SW Application Team |
frank26080115 | 0:84d7747641aa | 7 | *---------------------------------------------------------------------------- |
frank26080115 | 0:84d7747641aa | 8 | * Software that is described herein is for illustrative purposes only |
frank26080115 | 0:84d7747641aa | 9 | * which provides customers with programming information regarding the |
frank26080115 | 0:84d7747641aa | 10 | * products. This software is supplied "AS IS" without any warranties. |
frank26080115 | 0:84d7747641aa | 11 | * NXP Semiconductors assumes no responsibility or liability for the |
frank26080115 | 0:84d7747641aa | 12 | * use of the software, conveys no license or title under any patent, |
frank26080115 | 0:84d7747641aa | 13 | * copyright, or mask work right to the product. NXP Semiconductors |
frank26080115 | 0:84d7747641aa | 14 | * reserves the right to make changes in the software without |
frank26080115 | 0:84d7747641aa | 15 | * notification. NXP Semiconductors also make no representation or |
frank26080115 | 0:84d7747641aa | 16 | * warranty that such application will be suitable for the specified |
frank26080115 | 0:84d7747641aa | 17 | * use without further testing or modification. |
frank26080115 | 0:84d7747641aa | 18 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 19 | |
frank26080115 | 0:84d7747641aa | 20 | #include "debug_frmwrk.h" |
frank26080115 | 0:84d7747641aa | 21 | #include "lpc17xx_pinsel.h" |
frank26080115 | 0:84d7747641aa | 22 | |
frank26080115 | 0:84d7747641aa | 23 | /* If this source file built with example, the LPC17xx FW library configuration |
frank26080115 | 0:84d7747641aa | 24 | * file in each example directory ("lpc17xx_libcfg.h") must be included, |
frank26080115 | 0:84d7747641aa | 25 | * otherwise the default FW library configuration file must be included instead |
frank26080115 | 0:84d7747641aa | 26 | */ |
frank26080115 | 0:84d7747641aa | 27 | #ifdef __BUILD_WITH_EXAMPLE__ |
frank26080115 | 0:84d7747641aa | 28 | #include "lpc17xx_libcfg.h" |
frank26080115 | 0:84d7747641aa | 29 | #else |
frank26080115 | 0:84d7747641aa | 30 | #include "lpc17xx_libcfg_default.h" |
frank26080115 | 0:84d7747641aa | 31 | #endif /* __BUILD_WITH_EXAMPLE__ */ |
frank26080115 | 0:84d7747641aa | 32 | |
frank26080115 | 0:84d7747641aa | 33 | #ifdef _DBGFWK |
frank26080115 | 0:84d7747641aa | 34 | /* Debug framework */ |
frank26080115 | 0:84d7747641aa | 35 | |
frank26080115 | 0:84d7747641aa | 36 | void (*_db_msg)(LPC_UART_TypeDef *UARTx, const void *s); |
frank26080115 | 0:84d7747641aa | 37 | void (*_db_msg_)(LPC_UART_TypeDef *UARTx, const void *s); |
frank26080115 | 0:84d7747641aa | 38 | void (*_db_char)(LPC_UART_TypeDef *UARTx, uint8_t ch); |
frank26080115 | 0:84d7747641aa | 39 | void (*_db_dec)(LPC_UART_TypeDef *UARTx, uint8_t decn); |
frank26080115 | 0:84d7747641aa | 40 | void (*_db_dec_16)(LPC_UART_TypeDef *UARTx, uint16_t decn); |
frank26080115 | 0:84d7747641aa | 41 | void (*_db_dec_32)(LPC_UART_TypeDef *UARTx, uint32_t decn); |
frank26080115 | 0:84d7747641aa | 42 | void (*_db_hex)(LPC_UART_TypeDef *UARTx, uint8_t hexn); |
frank26080115 | 0:84d7747641aa | 43 | void (*_db_hex_16)(LPC_UART_TypeDef *UARTx, uint16_t hexn); |
frank26080115 | 0:84d7747641aa | 44 | void (*_db_hex_32)(LPC_UART_TypeDef *UARTx, uint32_t hexn); |
frank26080115 | 0:84d7747641aa | 45 | uint8_t (*_db_get_char)(LPC_UART_TypeDef *UARTx); |
frank26080115 | 0:84d7747641aa | 46 | |
frank26080115 | 0:84d7747641aa | 47 | |
frank26080115 | 0:84d7747641aa | 48 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 49 | * @brief Puts a character to UART port |
frank26080115 | 0:84d7747641aa | 50 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 51 | * @param[in] ch Character to put |
frank26080115 | 0:84d7747641aa | 52 | * @return None |
frank26080115 | 0:84d7747641aa | 53 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 54 | void UARTPutChar (LPC_UART_TypeDef *UARTx, uint8_t ch) |
frank26080115 | 0:84d7747641aa | 55 | { |
frank26080115 | 0:84d7747641aa | 56 | UART_Send(UARTx, &ch, 1, BLOCKING); |
frank26080115 | 0:84d7747641aa | 57 | } |
frank26080115 | 0:84d7747641aa | 58 | |
frank26080115 | 0:84d7747641aa | 59 | |
frank26080115 | 0:84d7747641aa | 60 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 61 | * @brief Get a character to UART port |
frank26080115 | 0:84d7747641aa | 62 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 63 | * @return character value that returned |
frank26080115 | 0:84d7747641aa | 64 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 65 | uint8_t UARTGetChar (LPC_UART_TypeDef *UARTx) |
frank26080115 | 0:84d7747641aa | 66 | { |
frank26080115 | 0:84d7747641aa | 67 | uint8_t tmp = 0; |
frank26080115 | 0:84d7747641aa | 68 | UART_Receive(UARTx, &tmp, 1, BLOCKING); |
frank26080115 | 0:84d7747641aa | 69 | return(tmp); |
frank26080115 | 0:84d7747641aa | 70 | } |
frank26080115 | 0:84d7747641aa | 71 | |
frank26080115 | 0:84d7747641aa | 72 | |
frank26080115 | 0:84d7747641aa | 73 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 74 | * @brief Puts a string to UART port |
frank26080115 | 0:84d7747641aa | 75 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 76 | * @param[in] str string to put |
frank26080115 | 0:84d7747641aa | 77 | * @return None |
frank26080115 | 0:84d7747641aa | 78 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 79 | void UARTPuts(LPC_UART_TypeDef *UARTx, const void *str) |
frank26080115 | 0:84d7747641aa | 80 | { |
frank26080115 | 0:84d7747641aa | 81 | uint8_t *s = (uint8_t *) str; |
frank26080115 | 0:84d7747641aa | 82 | |
frank26080115 | 0:84d7747641aa | 83 | while (*s) |
frank26080115 | 0:84d7747641aa | 84 | { |
frank26080115 | 0:84d7747641aa | 85 | UARTPutChar(UARTx, *s++); |
frank26080115 | 0:84d7747641aa | 86 | } |
frank26080115 | 0:84d7747641aa | 87 | } |
frank26080115 | 0:84d7747641aa | 88 | |
frank26080115 | 0:84d7747641aa | 89 | |
frank26080115 | 0:84d7747641aa | 90 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 91 | * @brief Puts a string to UART port and print new line |
frank26080115 | 0:84d7747641aa | 92 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 93 | * @param[in] str String to put |
frank26080115 | 0:84d7747641aa | 94 | * @return None |
frank26080115 | 0:84d7747641aa | 95 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 96 | void UARTPuts_(LPC_UART_TypeDef *UARTx, const void *str) |
frank26080115 | 0:84d7747641aa | 97 | { |
frank26080115 | 0:84d7747641aa | 98 | UARTPuts (UARTx, str); |
frank26080115 | 0:84d7747641aa | 99 | UARTPuts (UARTx, "\n\r"); |
frank26080115 | 0:84d7747641aa | 100 | } |
frank26080115 | 0:84d7747641aa | 101 | |
frank26080115 | 0:84d7747641aa | 102 | |
frank26080115 | 0:84d7747641aa | 103 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 104 | * @brief Puts a decimal number to UART port |
frank26080115 | 0:84d7747641aa | 105 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 106 | * @param[in] decnum Decimal number (8-bit long) |
frank26080115 | 0:84d7747641aa | 107 | * @return None |
frank26080115 | 0:84d7747641aa | 108 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 109 | void UARTPutDec(LPC_UART_TypeDef *UARTx, uint8_t decnum) |
frank26080115 | 0:84d7747641aa | 110 | { |
frank26080115 | 0:84d7747641aa | 111 | uint8_t c1=decnum%10; |
frank26080115 | 0:84d7747641aa | 112 | uint8_t c2=(decnum/10)%10; |
frank26080115 | 0:84d7747641aa | 113 | uint8_t c3=(decnum/100)%10; |
frank26080115 | 0:84d7747641aa | 114 | UARTPutChar(UARTx, '0'+c3); |
frank26080115 | 0:84d7747641aa | 115 | UARTPutChar(UARTx, '0'+c2); |
frank26080115 | 0:84d7747641aa | 116 | UARTPutChar(UARTx, '0'+c1); |
frank26080115 | 0:84d7747641aa | 117 | } |
frank26080115 | 0:84d7747641aa | 118 | |
frank26080115 | 0:84d7747641aa | 119 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 120 | * @brief Puts a decimal number to UART port |
frank26080115 | 0:84d7747641aa | 121 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 122 | * @param[in] decnum Decimal number (8-bit long) |
frank26080115 | 0:84d7747641aa | 123 | * @return None |
frank26080115 | 0:84d7747641aa | 124 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 125 | void UARTPutDec16(LPC_UART_TypeDef *UARTx, uint16_t decnum) |
frank26080115 | 0:84d7747641aa | 126 | { |
frank26080115 | 0:84d7747641aa | 127 | uint8_t c1=decnum%10; |
frank26080115 | 0:84d7747641aa | 128 | uint8_t c2=(decnum/10)%10; |
frank26080115 | 0:84d7747641aa | 129 | uint8_t c3=(decnum/100)%10; |
frank26080115 | 0:84d7747641aa | 130 | uint8_t c4=(decnum/1000)%10; |
frank26080115 | 0:84d7747641aa | 131 | uint8_t c5=(decnum/10000)%10; |
frank26080115 | 0:84d7747641aa | 132 | UARTPutChar(UARTx, '0'+c5); |
frank26080115 | 0:84d7747641aa | 133 | UARTPutChar(UARTx, '0'+c4); |
frank26080115 | 0:84d7747641aa | 134 | UARTPutChar(UARTx, '0'+c3); |
frank26080115 | 0:84d7747641aa | 135 | UARTPutChar(UARTx, '0'+c2); |
frank26080115 | 0:84d7747641aa | 136 | UARTPutChar(UARTx, '0'+c1); |
frank26080115 | 0:84d7747641aa | 137 | } |
frank26080115 | 0:84d7747641aa | 138 | |
frank26080115 | 0:84d7747641aa | 139 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 140 | * @brief Puts a decimal number to UART port |
frank26080115 | 0:84d7747641aa | 141 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 142 | * @param[in] decnum Decimal number (8-bit long) |
frank26080115 | 0:84d7747641aa | 143 | * @return None |
frank26080115 | 0:84d7747641aa | 144 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 145 | void UARTPutDec32(LPC_UART_TypeDef *UARTx, uint32_t decnum) |
frank26080115 | 0:84d7747641aa | 146 | { |
frank26080115 | 0:84d7747641aa | 147 | uint8_t c1=decnum%10; |
frank26080115 | 0:84d7747641aa | 148 | uint8_t c2=(decnum/10)%10; |
frank26080115 | 0:84d7747641aa | 149 | uint8_t c3=(decnum/100)%10; |
frank26080115 | 0:84d7747641aa | 150 | uint8_t c4=(decnum/1000)%10; |
frank26080115 | 0:84d7747641aa | 151 | uint8_t c5=(decnum/10000)%10; |
frank26080115 | 0:84d7747641aa | 152 | uint8_t c6=(decnum/100000)%10; |
frank26080115 | 0:84d7747641aa | 153 | uint8_t c7=(decnum/1000000)%10; |
frank26080115 | 0:84d7747641aa | 154 | uint8_t c8=(decnum/10000000)%10; |
frank26080115 | 0:84d7747641aa | 155 | uint8_t c9=(decnum/100000000)%10; |
frank26080115 | 0:84d7747641aa | 156 | uint8_t c10=(decnum/1000000000)%10; |
frank26080115 | 0:84d7747641aa | 157 | UARTPutChar(UARTx, '0'+c10); |
frank26080115 | 0:84d7747641aa | 158 | UARTPutChar(UARTx, '0'+c9); |
frank26080115 | 0:84d7747641aa | 159 | UARTPutChar(UARTx, '0'+c8); |
frank26080115 | 0:84d7747641aa | 160 | UARTPutChar(UARTx, '0'+c7); |
frank26080115 | 0:84d7747641aa | 161 | UARTPutChar(UARTx, '0'+c6); |
frank26080115 | 0:84d7747641aa | 162 | UARTPutChar(UARTx, '0'+c5); |
frank26080115 | 0:84d7747641aa | 163 | UARTPutChar(UARTx, '0'+c4); |
frank26080115 | 0:84d7747641aa | 164 | UARTPutChar(UARTx, '0'+c3); |
frank26080115 | 0:84d7747641aa | 165 | UARTPutChar(UARTx, '0'+c2); |
frank26080115 | 0:84d7747641aa | 166 | UARTPutChar(UARTx, '0'+c1); |
frank26080115 | 0:84d7747641aa | 167 | } |
frank26080115 | 0:84d7747641aa | 168 | |
frank26080115 | 0:84d7747641aa | 169 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 170 | * @brief Puts a hex number to UART port |
frank26080115 | 0:84d7747641aa | 171 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 172 | * @param[in] hexnum Hex number (8-bit long) |
frank26080115 | 0:84d7747641aa | 173 | * @return None |
frank26080115 | 0:84d7747641aa | 174 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 175 | void UARTPutHex (LPC_UART_TypeDef *UARTx, uint8_t hexnum) |
frank26080115 | 0:84d7747641aa | 176 | { |
frank26080115 | 0:84d7747641aa | 177 | uint8_t nibble, i; |
frank26080115 | 0:84d7747641aa | 178 | |
frank26080115 | 0:84d7747641aa | 179 | UARTPuts(UARTx, "0x"); |
frank26080115 | 0:84d7747641aa | 180 | i = 1; |
frank26080115 | 0:84d7747641aa | 181 | do { |
frank26080115 | 0:84d7747641aa | 182 | nibble = (hexnum >> (4*i)) & 0x0F; |
frank26080115 | 0:84d7747641aa | 183 | UARTPutChar(UARTx, (nibble > 9) ? ('A' + nibble - 10) : ('0' + nibble)); |
frank26080115 | 0:84d7747641aa | 184 | } while (i--); |
frank26080115 | 0:84d7747641aa | 185 | } |
frank26080115 | 0:84d7747641aa | 186 | |
frank26080115 | 0:84d7747641aa | 187 | |
frank26080115 | 0:84d7747641aa | 188 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 189 | * @brief Puts a hex number to UART port |
frank26080115 | 0:84d7747641aa | 190 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 191 | * @param[in] hexnum Hex number (16-bit long) |
frank26080115 | 0:84d7747641aa | 192 | * @return None |
frank26080115 | 0:84d7747641aa | 193 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 194 | void UARTPutHex16 (LPC_UART_TypeDef *UARTx, uint16_t hexnum) |
frank26080115 | 0:84d7747641aa | 195 | { |
frank26080115 | 0:84d7747641aa | 196 | uint8_t nibble, i; |
frank26080115 | 0:84d7747641aa | 197 | |
frank26080115 | 0:84d7747641aa | 198 | UARTPuts(UARTx, "0x"); |
frank26080115 | 0:84d7747641aa | 199 | i = 3; |
frank26080115 | 0:84d7747641aa | 200 | do { |
frank26080115 | 0:84d7747641aa | 201 | nibble = (hexnum >> (4*i)) & 0x0F; |
frank26080115 | 0:84d7747641aa | 202 | UARTPutChar(UARTx, (nibble > 9) ? ('A' + nibble - 10) : ('0' + nibble)); |
frank26080115 | 0:84d7747641aa | 203 | } while (i--); |
frank26080115 | 0:84d7747641aa | 204 | } |
frank26080115 | 0:84d7747641aa | 205 | |
frank26080115 | 0:84d7747641aa | 206 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 207 | * @brief Puts a hex number to UART port |
frank26080115 | 0:84d7747641aa | 208 | * @param[in] UARTx Pointer to UART peripheral |
frank26080115 | 0:84d7747641aa | 209 | * @param[in] hexnum Hex number (32-bit long) |
frank26080115 | 0:84d7747641aa | 210 | * @return None |
frank26080115 | 0:84d7747641aa | 211 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 212 | void UARTPutHex32 (LPC_UART_TypeDef *UARTx, uint32_t hexnum) |
frank26080115 | 0:84d7747641aa | 213 | { |
frank26080115 | 0:84d7747641aa | 214 | uint8_t nibble, i; |
frank26080115 | 0:84d7747641aa | 215 | |
frank26080115 | 0:84d7747641aa | 216 | UARTPuts(UARTx, "0x"); |
frank26080115 | 0:84d7747641aa | 217 | i = 7; |
frank26080115 | 0:84d7747641aa | 218 | do { |
frank26080115 | 0:84d7747641aa | 219 | nibble = (hexnum >> (4*i)) & 0x0F; |
frank26080115 | 0:84d7747641aa | 220 | UARTPutChar(UARTx, (nibble > 9) ? ('A' + nibble - 10) : ('0' + nibble)); |
frank26080115 | 0:84d7747641aa | 221 | } while (i--); |
frank26080115 | 0:84d7747641aa | 222 | } |
frank26080115 | 0:84d7747641aa | 223 | |
frank26080115 | 0:84d7747641aa | 224 | ///*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 225 | // * @brief print function that supports format as same as printf() |
frank26080115 | 0:84d7747641aa | 226 | // * function of <stdio.h> library |
frank26080115 | 0:84d7747641aa | 227 | // * @param[in] None |
frank26080115 | 0:84d7747641aa | 228 | // * @return None |
frank26080115 | 0:84d7747641aa | 229 | // **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 230 | //void _printf (const char *format, ...) |
frank26080115 | 0:84d7747641aa | 231 | //{ |
frank26080115 | 0:84d7747641aa | 232 | // static char buffer[512 + 1]; |
frank26080115 | 0:84d7747641aa | 233 | // va_list vArgs; |
frank26080115 | 0:84d7747641aa | 234 | // char *tmp; |
frank26080115 | 0:84d7747641aa | 235 | // va_start(vArgs, format); |
frank26080115 | 0:84d7747641aa | 236 | // vsprintf((char *)buffer, (char const *)format, vArgs); |
frank26080115 | 0:84d7747641aa | 237 | // va_end(vArgs); |
frank26080115 | 0:84d7747641aa | 238 | // |
frank26080115 | 0:84d7747641aa | 239 | // _DBG(buffer); |
frank26080115 | 0:84d7747641aa | 240 | //} |
frank26080115 | 0:84d7747641aa | 241 | |
frank26080115 | 0:84d7747641aa | 242 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 243 | * @brief Initialize Debug frame work through initializing UART port |
frank26080115 | 0:84d7747641aa | 244 | * @param[in] None |
frank26080115 | 0:84d7747641aa | 245 | * @return None |
frank26080115 | 0:84d7747641aa | 246 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 247 | void debug_frmwrk_init(void) |
frank26080115 | 0:84d7747641aa | 248 | { |
frank26080115 | 0:84d7747641aa | 249 | UART_CFG_Type UARTConfigStruct; |
frank26080115 | 0:84d7747641aa | 250 | PINSEL_CFG_Type PinCfg; |
frank26080115 | 0:84d7747641aa | 251 | |
frank26080115 | 0:84d7747641aa | 252 | #if (USED_UART_DEBUG_PORT==0) |
frank26080115 | 0:84d7747641aa | 253 | /* |
frank26080115 | 0:84d7747641aa | 254 | * Initialize UART0 pin connect |
frank26080115 | 0:84d7747641aa | 255 | */ |
frank26080115 | 0:84d7747641aa | 256 | PinCfg.Funcnum = 1; |
frank26080115 | 0:84d7747641aa | 257 | PinCfg.OpenDrain = 0; |
frank26080115 | 0:84d7747641aa | 258 | PinCfg.Pinmode = 0; |
frank26080115 | 0:84d7747641aa | 259 | PinCfg.Pinnum = 2; |
frank26080115 | 0:84d7747641aa | 260 | PinCfg.Portnum = 0; |
frank26080115 | 0:84d7747641aa | 261 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:84d7747641aa | 262 | PinCfg.Pinnum = 3; |
frank26080115 | 0:84d7747641aa | 263 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:84d7747641aa | 264 | #elif (USED_UART_DEBUG_PORT==1) |
frank26080115 | 0:84d7747641aa | 265 | /* |
frank26080115 | 0:84d7747641aa | 266 | * Initialize UART1 pin connect |
frank26080115 | 0:84d7747641aa | 267 | */ |
frank26080115 | 0:84d7747641aa | 268 | PinCfg.Funcnum = 1; |
frank26080115 | 0:84d7747641aa | 269 | PinCfg.OpenDrain = 0; |
frank26080115 | 0:84d7747641aa | 270 | PinCfg.Pinmode = 0; |
frank26080115 | 0:84d7747641aa | 271 | PinCfg.Pinnum = 15; |
frank26080115 | 0:84d7747641aa | 272 | PinCfg.Portnum = 0; |
frank26080115 | 0:84d7747641aa | 273 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:84d7747641aa | 274 | PinCfg.Pinnum = 16; |
frank26080115 | 0:84d7747641aa | 275 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:84d7747641aa | 276 | #endif |
frank26080115 | 0:84d7747641aa | 277 | |
frank26080115 | 0:84d7747641aa | 278 | /* Initialize UART Configuration parameter structure to default state: |
frank26080115 | 0:84d7747641aa | 279 | * Baudrate = 9600bps |
frank26080115 | 0:84d7747641aa | 280 | * 8 data bit |
frank26080115 | 0:84d7747641aa | 281 | * 1 Stop bit |
frank26080115 | 0:84d7747641aa | 282 | * None parity |
frank26080115 | 0:84d7747641aa | 283 | */ |
frank26080115 | 0:84d7747641aa | 284 | UART_ConfigStructInit(&UARTConfigStruct); |
frank26080115 | 0:84d7747641aa | 285 | // Re-configure baudrate to 115200bps |
frank26080115 | 0:84d7747641aa | 286 | UARTConfigStruct.Baud_rate = 115200; |
frank26080115 | 0:84d7747641aa | 287 | |
frank26080115 | 0:84d7747641aa | 288 | // Initialize DEBUG_UART_PORT peripheral with given to corresponding parameter |
frank26080115 | 0:84d7747641aa | 289 | UART_Init((LPC_UART_TypeDef*)DEBUG_UART_PORT, &UARTConfigStruct); |
frank26080115 | 0:84d7747641aa | 290 | |
frank26080115 | 0:84d7747641aa | 291 | // Enable UART Transmit |
frank26080115 | 0:84d7747641aa | 292 | UART_TxCmd((LPC_UART_TypeDef*)DEBUG_UART_PORT, ENABLE); |
frank26080115 | 0:84d7747641aa | 293 | |
frank26080115 | 0:84d7747641aa | 294 | _db_msg = UARTPuts; |
frank26080115 | 0:84d7747641aa | 295 | _db_msg_ = UARTPuts_; |
frank26080115 | 0:84d7747641aa | 296 | _db_char = UARTPutChar; |
frank26080115 | 0:84d7747641aa | 297 | _db_hex = UARTPutHex; |
frank26080115 | 0:84d7747641aa | 298 | _db_hex_16 = UARTPutHex16; |
frank26080115 | 0:84d7747641aa | 299 | _db_hex_32 = UARTPutHex32; |
frank26080115 | 0:84d7747641aa | 300 | _db_dec = UARTPutDec; |
frank26080115 | 0:84d7747641aa | 301 | _db_dec_16 = UARTPutDec16; |
frank26080115 | 0:84d7747641aa | 302 | _db_dec_32 = UARTPutDec32; |
frank26080115 | 0:84d7747641aa | 303 | _db_get_char = UARTGetChar; |
frank26080115 | 0:84d7747641aa | 304 | } |
frank26080115 | 0:84d7747641aa | 305 | #endif /*_DBGFWK */ |