|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
27 extern int binary_pst_dat_start[];
31 char* idstr = (
char*) malloc(12);
36 rfidser* term = (rfidser*) malloc(
sizeof(rfidser));
37 memset(term, 0,
sizeof(rfidser));
39 rfidptr = (
void*) malloc(
sizeof(rfid_st));
40 term->
devst = rfidptr;
41 memset((
char*)rfidptr, 0,
sizeof(rfid_st));
43 if(rxpin == 31 && txpin == 30) {
51 rfidptr->rx_pin = rxpin;
52 rfidptr->tx_pin = txpin;
54 rfidptr->en = enablePin;
57 rfidptr->ticks =
CLKFREQ/baudrate;
58 rfidptr->buffptr = bufptr;
59 rfidptr->idstr = idstr;
63 #if defined(__PROPELLER_USE_XMM__)
64 {
unsigned int buffer[2048];
65 memcpy(buffer, binary_pst_dat_start, 2048);
66 term->
cogid[0] =
cognew(buffer, (
void*)rfidptr) + 1;
69 term->
cogid[0] = setStopCOGID(
cognew((
void*)binary_pst_dat_start, (
void*)rfidptr));
80 int id = device->cogid[0];
81 rfid_st* rfidp = (rfid_st*) device->devst;
87 if(
id > 0)
cogstop(getStopCOGID(
id));
89 free((
void*)rfidp->buffptr);
90 free((
void*)rfidp->idstr);
99 volatile rfid_st* rfidp = (rfid_st*) device->devst;
100 int rfidEn = rfidp->en;
109 volatile rfid_st* rfidp = (rfid_st*) device->devst;
110 int rfidEn = rfidp->en;
118 volatile rfid_st* rfidp = (rfid_st*) device->devst;
119 int rfidEn = rfidp->en;
127 volatile rfid_st* rfidp = (rfid_st*) device->devst;
128 memset(rfidp->idstr, 0, 12);
130 int dt = (
CLKFREQ / 1000) * timeoutms;
137 memcpy(rfidp->idstr,
"timed out\0\0\0", 12);
142 readStr(device, rfidp->idstr, 12);
#define FDSERIAL_BUFF_MASK
int(* rxChar)(struct text_struct *p)
void rfid_enable(rfidser *device)
Enable RFID reading process. Reader will actively scan cards swiped.
char * rfid_get(rfidser *device, int timeoutms)
Get RFID code from serial buffer.
void rfid_disable(rfidser *device)
Disable RFID reading process. Reader will ignore any cards swiped.
Simplifies reading Parallax Serial RFID Card Reader.
int(* txChar)(struct text_struct *p, int ch)
void rfidser_close(rfidser *device)
End RFID card monitoring/reading process and recover cog and stack memory for other purposes.
#define cognew(code, param)
Start a new Propeller PASM COG.
int fdserial_rxCheck(fdserial *term)
Gets a byte from the receive buffer if available, but does not wait if there's nothing in the buffer.
char * readStr(text_t *device, char *buffer, int max)
Get string of chars from the device.
void simpleterm_close(void)
Closes the SimpleIDE Terminal connection in one cog so that it can be opened in another cog with simp...
#define CLKFREQ
Returns the current clock frequency.
void fdserial_txFlush(fdserial *term)
Remove any bytes that might be waiting in the transmit buffer.
int fdserial_txChar(fdserial *term, int txbyte)
Send a byte by adding it to the transmit buffer.
#define waitcnt(a)
Wait until system counter reaches a value.
#define cogstop(a)
Stop a COG.
#define CNT
The system clock count.
int fdserial_rxChar(fdserial *term)
Get a byte from the receive buffer, or if it's emtpy, wait until a byte is received.
void rfid_reset(rfidser *device)
Reset the RFID reader.
rfidser * rfid_open(int soutPin, int enablePin)
Runs the RFID card reading process in another cog.
This library supports creating and managing one or more full duplex serial connections with periphera...