Added ledcontrol to lf functions

This commit is contained in:
Łukasz Jurczyk 2021-11-18 14:26:41 +01:00
commit 218a4ba2ec
No known key found for this signature in database
GPG key ID: 95B48A1500000000
26 changed files with 432 additions and 426 deletions

View file

@ -186,7 +186,7 @@ void lf_wait_periods(size_t periods) {
lf_count_edge_periods_ex(periods, true, false);
}
void lf_init(bool reader, bool simulate) {
void lf_init(bool reader, bool simulate, bool ledcontrol) {
StopTicks();
@ -240,7 +240,7 @@ void lf_init(bool reader, bool simulate) {
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV4_CLOCK;
// Clear all leds
LEDsoff();
if (ledcontrol) LEDsoff();
// Reset and enable timers
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
@ -258,7 +258,7 @@ void lf_init(bool reader, bool simulate) {
lf_sample_mean();
}
void lf_finalize(void) {
void lf_finalize(bool ledcontrol) {
// Disable timers
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
@ -269,7 +269,7 @@ void lf_finalize(void) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff();
if (ledcontrol) LEDsoff();
StartTicks();
}
@ -329,9 +329,9 @@ static void lf_manchester_send_bit(uint8_t bit) {
}
// simulation
bool lf_manchester_send_bytes(const uint8_t *frame, size_t frame_len) {
bool lf_manchester_send_bytes(const uint8_t *frame, size_t frame_len, bool ledcontrol) {
LED_B_ON();
if (ledcontrol) LED_B_ON();
lf_manchester_send_bit(1);
lf_manchester_send_bit(1);
@ -344,6 +344,6 @@ bool lf_manchester_send_bytes(const uint8_t *frame, size_t frame_len) {
lf_manchester_send_bit((frame[i / 8] >> (7 - (i % 8))) & 1);
}
LED_B_OFF();
if (ledcontrol) LED_B_OFF();
return true;
}