From 86be22d2c765309f955cb0bb9c4e16d8ae5fa6fd Mon Sep 17 00:00:00 2001 From: Federico Cerutti Date: Wed, 26 Aug 2020 17:19:05 +0200 Subject: [PATCH] Shared a function I forgot about, documented sharing practises --- Firmware/Chameleon-Mini/Codec/Codec.h | 1 + Firmware/Chameleon-Mini/Codec/ISO15693.c | 2 +- .../Chameleon-Mini/Codec/SniffISO14443-2A.c | 7 ++---- Firmware/Chameleon-Mini/ISRSharing.S | 25 +++++++++++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Firmware/Chameleon-Mini/Codec/Codec.h b/Firmware/Chameleon-Mini/Codec/Codec.h index 84bf9c3..8899cac 100644 --- a/Firmware/Chameleon-Mini/Codec/Codec.h +++ b/Firmware/Chameleon-Mini/Codec/Codec.h @@ -116,6 +116,7 @@ typedef enum { extern uint8_t CodecBuffer[CODEC_BUFFER_SIZE]; extern uint8_t CodecBuffer2[CODEC_BUFFER_SIZE]; +/* Shared ISR pointers and handlers */ void (* volatile isr_func_TCD0_CCC_vect)(void); void isr_Reader14443_2A_TCD0_CCC_vect(void); void isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void); diff --git a/Firmware/Chameleon-Mini/Codec/ISO15693.c b/Firmware/Chameleon-Mini/Codec/ISO15693.c index 39ea805..4bd91a2 100644 --- a/Firmware/Chameleon-Mini/Codec/ISO15693.c +++ b/Firmware/Chameleon-Mini/Codec/ISO15693.c @@ -258,7 +258,7 @@ ISR_SHARED isr_ISO15693_CODEC_TIMER_SAMPLING_CCC_VECT(void) { * It disables its own interrupt when all data has been sent */ //ISR(CODEC_TIMER_LOADMOD_CCB_VECT) -void isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void) { +ISR_SHARED isr_ISO15693_CODEC_TIMER_LOADMOD_CCB_VECT(void) { static void *JumpTable[] = { [LOADMOD_START_SINGLE] = && LOADMOD_START_SINGLE_LABEL, [LOADMOD_SOF_SINGLE] = && LOADMOD_SOF_SINGLE_LABEL, diff --git a/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c b/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c index ac132fb..57ae2c6 100644 --- a/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c +++ b/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c @@ -351,16 +351,13 @@ ISR(ACA_AC0_vect) { // this interrupt either finds the SOC or gets triggered bef StateRegister = PICC_FRAME; } -ISR(CODEC_TIMER_LOADMOD_CCB_VECT) { // pause found - isr_func_CODEC_TIMER_LOADMOD_CCB_VECT(); -} - +// Called once a pause is found // Decode the Card -> Reader signal // according to the pause and modulated period // if the half bit duration is modulated, then add 1 to buffer // if the half bit duration is not modulated, then add 0 to buffer //ISR(CODEC_TIMER_LOADMOD_CCB_VECT) // pause found -void isr_SniffISO14443_2A_CODEC_TIMER_LOADMOD_CCB_VECT(void) { +ISR_SHARED isr_SniffISO14443_2A_CODEC_TIMER_LOADMOD_CCB_VECT(void) { uint8_t tmp = CODEC_TIMER_TIMESTAMPS.CNTL; CODEC_TIMER_TIMESTAMPS.CNT = 0; diff --git a/Firmware/Chameleon-Mini/ISRSharing.S b/Firmware/Chameleon-Mini/ISRSharing.S index 9a18a82..dfa802b 100644 --- a/Firmware/Chameleon-Mini/ISRSharing.S +++ b/Firmware/Chameleon-Mini/ISRSharing.S @@ -9,7 +9,7 @@ #include "Codec/Codec.h" #include -; Use this macro to call isr functions +; Macro to call ISR functions .macro call_isr isr_address push r30 push r31 @@ -21,7 +21,23 @@ pop r30 reti .endm -; Find first pause and start sampling +; Shared ISR must be defined below as globals +; Example: +; +; .global +; INTERRUPT-TO-SHARE: +; call_isr POINTER-TO-VARIABLE-INTERRUPT-HANDLER +; +; Where: +; INTERRUPT-TO-SHARE +; The target interrupt which needs to be shared +; POINTER-TO-VARIABLE-INTERRUPT-HANDLER +; A pointer to the current interrupt handler which can be modified +; at runtime. Must be a volatile pointer to function defined in Codec.h + +; TODO spostare i commenti qui sotto alle funzioni appropriate. Non ha senso commentare i nomi dei vettori, ma bisogna commentare la funzione nel contesto +; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +; Sample reader field and demodulate signal after first pause .global CODEC_DEMOD_IN_INT0_VECT CODEC_DEMOD_IN_INT0_VECT: call_isr isr_func_CODEC_DEMOD_IN_INT0_VECT @@ -30,3 +46,8 @@ CODEC_DEMOD_IN_INT0_VECT: .global CODEC_TIMER_SAMPLING_CCC_VECT CODEC_TIMER_SAMPLING_CCC_VECT: call_isr isr_func_TCD0_CCC_vect + +; Send response data from emulated card to reader +.global CODEC_TIMER_LOADMOD_CCB_VECT +CODEC_TIMER_LOADMOD_CCB_VECT: + call_isr isr_func_CODEC_TIMER_LOADMOD_CCB_VECT \ No newline at end of file