Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MODSERIAL USBDevice_for_Rev_C_HW mbed
Fork of mbed_sv_firmware_with_init by
Diff: main.cpp
- Revision:
- 2:efaf8aee55df
- Parent:
- 1:bd988d267998
- Child:
- 3:e8cc286f9b2e
diff -r bd988d267998 -r efaf8aee55df main.cpp --- a/main.cpp Mon Jan 19 23:27:45 2015 +0000 +++ b/main.cpp Mon Jan 19 23:48:21 2015 +0000 @@ -64,10 +64,14 @@ rfid_isp = 0; // RFID FE In-System Programming (active high) rfid_rst = 1; // RFID FE Reset (active high) rfid_pwr = 1; // RFID power switch on USB board (active high for prototype 1, low for all others) - wait(0.25); // wait 1/4 second before... + wait(0.25); // wait 250ms before... rfid_rst = 0; // ... taking RFID out of reset // Prox + i2c.frequency(400000); + prox_int.mode(PullUp); // pull up proximity sensor interrupt at MCU + + return 0; } @@ -145,68 +149,68 @@ cdc.printf("Starting...\n\r"); - //while(!cdc.readable()); // spin here until a message comes in from the host PC + while(!cdc.readable()); // spin here until a message comes in from the host PC bool end_mark = FALSE; - uint8_t crcCount = sizeof(cdc_buffer_rx); // use tx buffer size to start + uint8_t crcCount = sizeof(cdc_buffer_rx); // use tx buffer size to start cdc.printf("\n\rCDC Input: "); for (i = 0; i < sizeof(cdc_buffer_rx); i++) { - //cdc_buffer_rx[i] = cdc.getc(); // + cdc_buffer_rx[i] = cdc.getc(); // read data from USB side - cdc.printf("%X, ",cdc_buffer_rx[i]); + //cdc.printf("%X, ",cdc_buffer_rx[i]); // debug - if (cdc_buffer_rx[i] == 0x7E) // check for rfid end mark in outbound message + if (cdc_buffer_rx[i] == 0x7E) // check for rfid end mark in outbound message { - crcCount = 2; // two more bytes for CRC - end_mark = TRUE; // end mark was reached + crcCount = 2; // two more bytes for CRC + end_mark = TRUE; // end mark was reached } - if (crcCount-- == 0) // end of message + if (crcCount-- == 0) // end of message { - if (end_mark == FALSE) return ERR_UART_NO_TX_ENDMARK; // no end mark detected + if (end_mark == FALSE) return ERR_UART_NO_TX_ENDMARK; // no end mark detected break; } } switch(cdc_buffer_rx[0]) { - case 0xBB: // RFID-FE + case 0xBB: // RFID-FE for (i = 0; i < sizeof(cdc_buffer_rx); i++) { - uart_buffer_tx[i] = cdc_buffer_rx[i]; // copy USB message to UART for RFID + uart_buffer_tx[i] = cdc_buffer_rx[i]; // copy USB message to UART for RFID } - status = rfid_msg(); // send buffer to RFID and get response according to RFID board + status = rfid_msg(); // send buffer to RFID and get response according to RFID board for (i = 0; i < sizeof(cdc_buffer_tx); i++) { - cdc_buffer_tx[i] = uart_buffer_rx[i]; // copy RFID response back to USB buffer + cdc_buffer_tx[i] = uart_buffer_rx[i]; // copy RFID response back to USB buffer } - cdc.printf("\n\rRFID Response: "); + //cdc.printf("\n\rRFID Response: "); // debug for (i = 0; i < sizeof(cdc_buffer_tx); i++) { - cdc.printf("%x, ", cdc_buffer_tx[i]); // send message back to PC + //cdc.printf("%x, ", cdc_buffer_tx[i]); // debug send message back to PC - if (cdc_buffer_tx[i] == 0x7E) // check for rfid end mark in outbound message + if (cdc_buffer_tx[i] == 0x7E) // check for rfid end mark in outbound message { - crcCount = 2; // two more bytes for CRC - end_mark = TRUE; // end mark was reached + crcCount = 2; // two more bytes for CRC + end_mark = TRUE; // end mark was reached } - if (crcCount-- == 0) // end of message + if (crcCount-- == 0) // end of message { if (end_mark == FALSE) return ERR_CDC_NO_TX_ENDMARK; // no end mark detected break; } } break; - case 0xCC: // Proximity Sensor + case 0xCC: // Proximity Sensor prox_msg(); break; - case 0xDD: // GPIO (LEDs and RFID-FE control + case 0xDD: // GPIO (LEDs and RFID-FE control gpio_msg(); break; - case 0xEE: // Read/write EEPROM + case 0xEE: // Read/write EEPROM eeprom_msg(); break; default: