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: mbed
Fork of CRIC_RFID by
Diff: main.cpp
- Revision:
- 0:a6addbfe44b4
- Child:
- 1:6713f9d95bad
diff -r 000000000000 -r a6addbfe44b4 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 12 10:15:52 2014 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+Serial debugPC(USBTX, USBRX); // tx, rx //Communication pour le debug entre le PC et le mbed
+Serial comRFID(p13, p14); // tx, rx //Communication entre le mbed et le RFID SM130
+
+void flashingLED();
+void sendFrame(unsigned char command, unsigned char lengthData, unsigned char *data);
+
+int main() {
+ unsigned char tabData[20];
+
+ debugPC.baud(19200);
+ debugPC.printf("\nHello World!\n");
+
+ while(1) {
+ sendFrame(0x80, 0x01, tabData);
+ if(comRFID.readable() == 1){
+ debugPC.printf("\nOK");
+ }
+ flashingLED();
+ }
+}
+
+void sendFrame(unsigned char command, unsigned char lengthData, unsigned char *data){
+ unsigned char csum = 0;
+
+ lengthData += 1; // +1 pour ajout taille commande
+
+ comRFID.putc(0xFF); //HEADER
+ comRFID.putc(0x00); //RESERVED
+ comRFID.putc(lengthData ); //LENGTH
+ comRFID.putc(command); //COMMAND
+ for(unsigned int cpt; cpt<lengthData; cpt++){ //DATA
+ comRFID.putc(*(data+cpt));
+ }
+ //Calcul du checksum
+ csum += lengthData;
+ csum += command;
+ for(unsigned int cpt; cpt<lengthData-1; cpt++)
+ csum += *(data + cpt);
+
+ comRFID.putc(csum); //CSUM
+
+ //Affiche debug
+ debugPC.printf("\nTX :\t0xFF 0x00");
+ debugPC.putc(lengthData );
+ debugPC.putc(command);
+ for(unsigned int cpt; cpt<lengthData; cpt++)
+ debugPC.putc(*(data+cpt));
+ debugPC.putc(csum);
+}
+
+void flashingLED() {
+ myled = 1;
+ wait(0.2);
+ myled = 0;
+ wait(0.2);
+}
\ No newline at end of file
