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
main.cpp
- Committer:
- toni
- Date:
- 2014-11-12
- Revision:
- 1:6713f9d95bad
- Parent:
- 0:a6addbfe44b4
- Child:
- 2:41df6e176f9a
File content as of revision 1:6713f9d95bad:
#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("\n\rHello World!\n");
while(1) {
sendFrame(0x80, 0x00, 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("\n\rTX :\t");
debugPC.printf("FF ");
debugPC.printf("00 ");
debugPC.printf("%x ", lengthData );
debugPC.printf("%x ", command);
for(unsigned int cpt; cpt<lengthData; cpt++)
debugPC.printf("%x ", *(data+cpt));
debugPC.printf("%x ", csum);
}
void flashingLED() {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
