Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow custom preamble values * Custom preamble duration * All commands return unified response code * New unknown command response code * Switch to SDCC's medium memory model * delay() is more accurate * flip manchester bits
- Loading branch information
Showing
25 changed files
with
504 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
|
||
#include <stddef.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include "fifo.h" | ||
|
||
static volatile uint8_t fifo_count(fifo_buffer const *b) { | ||
return (b ? (b->head - b->tail) : 0); | ||
} | ||
|
||
bool fifo_full(fifo_buffer const *b) { | ||
return (b ? (fifo_count(b) == b->buffer_len) : true); | ||
} | ||
|
||
bool fifo_empty(fifo_buffer const *b) { | ||
return (b ? (fifo_count(b) == 0) : true); | ||
} | ||
|
||
uint8_t fifo_peek(fifo_buffer const *b) { | ||
if (b) { | ||
return (b->buffer[b->tail % b->buffer_len]); | ||
} | ||
return 0; | ||
} | ||
|
||
uint8_t fifo_get(fifo_buffer * b) { | ||
uint8_t data_byte = 0; | ||
|
||
if (!fifo_empty(b)) { | ||
data_byte = b->buffer[b->tail % b->buffer_len]; | ||
b->tail++; | ||
} | ||
return data_byte; | ||
} | ||
|
||
bool fifo_put(fifo_buffer * b, uint8_t data_byte) { | ||
bool status = false; /* return value */ | ||
|
||
if (b) { | ||
/* limit the ring to prevent overwriting */ | ||
if (!fifo_full(b)) { | ||
b->buffer[b->head % b->buffer_len] = data_byte; | ||
b->head++; | ||
status = true; | ||
} | ||
} | ||
return status; | ||
} | ||
|
||
void fifo_init(fifo_buffer * b, volatile uint8_t *buffer, uint8_t size) { | ||
if (b) { | ||
b->head = 0; | ||
b->tail = 0; | ||
b->buffer = buffer; | ||
b->buffer_len = size; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
/* fifo queue for use with interrupt routines. Size must be power of 2 */ | ||
|
||
#ifndef FIFO_H | ||
#define FIFO_H | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
struct fifo_buffer_t { | ||
volatile uint8_t head; /* first byte of data */ | ||
volatile uint8_t tail; /* last byte of data */ | ||
volatile uint8_t *buffer; /* block of memory or array of data */ | ||
uint8_t buffer_len; /* length of the data */ | ||
}; | ||
typedef struct fifo_buffer_t fifo_buffer; | ||
|
||
bool fifo_empty(fifo_buffer const *b); | ||
|
||
bool fifo_full(fifo_buffer const *b); | ||
|
||
uint8_t fifo_peek(fifo_buffer const *b); | ||
|
||
uint8_t fifo_get(fifo_buffer *b); | ||
|
||
bool fifo_put(fifo_buffer *b, uint8_t data_byte); | ||
|
||
/* size must be a power of 2 */ | ||
void fifo_init(fifo_buffer *b, volatile uint8_t *buffer, uint8_t size); | ||
|
||
#endif // FIFO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.