Revision 279
| trunk/cardbox/cardreader.h (revision 279) | ||
|---|---|---|
| 5 | 5 |
#include <avr/interrupt.h> |
| 6 | 6 |
#include <stdint.h> |
| 7 | 7 |
#include "cardbox.h" |
| 8 |
#include "rs485_int.h" |
|
| 9 | 8 |
|
| 9 |
// Error values |
|
| 10 | 10 |
#define CR_ERR_BAD_PARITY -1 |
| 11 | 11 |
#define CR_ERR_NO_START -2 |
| 12 | 12 |
#define CR_ERR_NO_STOP -3 |
| 13 | 13 |
|
| 14 |
// How big the buffer is to read in bits of the card to |
|
| 14 | 15 |
#define CR_BUF_SIZE 800 |
| 15 | 16 |
|
| 16 | 17 |
typedef enum {
|
| ... | ... | |
| 21 | 22 |
|
| 22 | 23 |
extern volatile cr_flag_t cr_flag; |
| 23 | 24 |
extern volatile uint8_t read_card; |
| 24 |
//extern volatile uint8_t cr_buf[512]; |
|
| 25 |
//extern volatile uint16_t cr_buf_idx; |
|
| 26 | 25 |
|
| 27 | 26 |
void card_reader_setup(void); |
| 28 | 27 |
int8_t parse_card(uint8_t *buf, uint8_t *buflen); |
| trunk/cardbox/cardreader.c (revision 279) | ||
|---|---|---|
| 142 | 142 |
} |
| 143 | 143 |
|
| 144 | 144 |
// Read data in on the downtick of the clock |
| 145 |
if ((!(PIND & CR_CLK))) {
|
|
| 146 |
if (cr_buf_idx < CR_BUF_SIZE) {
|
|
| 145 |
if ((!(PIND & CR_CLK)) && (cr_buf_idx < CR_BUF_SIZE)) {
|
|
| 147 | 146 |
// Read data from card reader and flip since ours inverts |
| 148 | 147 |
cr_buf[cr_buf_idx] = !(PIND & CR_DATA); |
| 149 | 148 |
cr_buf_idx++; |
| 150 |
} else {
|
|
| 151 |
toggle_led(LED_RED, ON); |
|
| 152 |
} |
|
| 153 | 149 |
} |
| 154 | 150 |
} |
Also available in: Unified diff