48 # define outChar __esos_unsafe_PutUint8
59 #if (NUM_UART_MODS >= 1)
64 #if (NUM_UART_MODS >= 2)
69 #if (NUM_UART_MODS >= 3)
74 #if (NUM_UART_MODS >= 4)
92 #if (SERIAL_EOL_DEFAULT == SERIAL_EOL_CR_LF)
93 if (*psz_s ==
'\n')
outChar(0x0D);
96 #if (SERIAL_EOL_DEFAULT == SERIAL_EOL_CR)
97 if (*psz_s ==
'\n')
outChar(0x0D);
100 #if (SERIAL_EOL_DEFAULT == SERIAL_EOL_LF)
111 static uint16_t inStringInternal(
char *psz_buff, uint16_t u16_maxCount,
uint8_t echoFlag) {
115 if (!u16_maxCount)
return 0;
117 for (u16_i = 0; u16_i < u16_maxCount; u16_i++) {
120 if (u8_c ==
'\n' ||u8_c ==
'\r' )
break;
139 uint16_t
inString(
char *psz_buff, int16_t u16_maxCount) {
140 return inStringInternal(psz_buff,u16_maxCount,0);
147 return inStringInternal(psz_buff,u16_maxCount,1);
151 void outUint8NoLeader(
uint8_t u8_x) {
153 u8_c = (u8_x>>4)& 0xf;
154 if (u8_c > 9)
outChar(
'A'+u8_c-10);
158 if (u8_c > 9)
outChar(
'A'+u8_c-10);
168 outUint8NoLeader(u8_x);
180 outUint8NoLeader(u8_c);
182 outUint8NoLeader(u8_c);
192 u8_c = (u32_x >> 24);
193 outUint8NoLeader(u8_c);
194 u8_c = (u32_x >> 16);
195 outUint8NoLeader(u8_c);
197 outUint8NoLeader(u8_c);
199 outUint8NoLeader(u8_c);
207 static const uint8_t u8_d[]= {50, 30, 20, 10, 5, 3, 2, 1 };
208 static const uint8_t u8_f[]= {5, 3, 2, 1, 5, 3, 2, 1 };
219 if (u8_destroy >= 200) {
223 if (u8_destroy >= 100) {
227 for (u8_i=0; u8_i<8; u8_i++) {
228 if (u8_destroy >= u8_d[u8_i]) {
229 psz_out[1+(u8_i/4)] += u8_f[u8_i];
230 u8_destroy -= u8_d[u8_i];
242 static const uint16_t u16_d[]= {50000, 30000, 20000, 10000, 5000, 3000, 2000, 1000, \
243 500, 300, 200, 100, 50, 30, 20, 10, 5, 3, 2, 1
245 static const uint8_t u8_f[]= {5, 3, 2, 1 };
248 uint16_t u16_destroy;
259 for (u8_i=0; u8_i<20; u8_i++) {
260 if (u16_destroy >= u16_d[u8_i]) {
261 psz_out[u8_i/4] += u8_f[u8_i % 4];
262 u16_destroy -= u16_d[u8_i];
277 switch (__C30_UART) {
278 #if (NUM_UART_MODS >= 1)
282 #if (NUM_UART_MODS >= 2)
286 #if (NUM_UART_MODS >= 3)
290 #if (NUM_UART_MODS >= 4)
316 switch (__C30_UART) {
317 #if (NUM_UART_MODS >= 1)
321 #if (NUM_UART_MODS >= 2)
323 return isCharReady2();
325 #if (NUM_UART_MODS >= 3)
327 return isCharReady3();
329 #if (NUM_UART_MODS >= 4)
331 return isCharReady4();
349 #if DEFAULT_UART == 1
351 #elif DEFAULT_UART == 2
352 configUART2(u32_baudRate);
353 #elif DEFAULT_UART == 3
354 configUART3(u32_baudRate);
355 #elif DEFAULT_UART == 4
356 configUART4(u32_baudRate);
358 # error "Invalid DEFAULT_UART."