diff --git a/eXoCAN.cpp b/eXoCAN.cpp index 8aecc8e..2664880 100644 --- a/eXoCAN.cpp +++ b/eXoCAN.cpp @@ -1,6 +1,7 @@ #include "eXoCAN.h" // vers 1.0.1 02/06/2021 +// vers 1.0.2 04/15/2021 void eXoCAN::begin(idtype addrType, int brp, BusType hw) { @@ -125,26 +126,27 @@ void eXoCAN::filter16Init(int bank, int mode, int a, int b, int c, int d) // 16b periphBit(FINIT) = 0; // ~FINIT 'active' filter mode ] } -void eXoCAN::filterList32Init(int bank, int idA, int idB) //32b filters +void eXoCAN::filterList32Init(int bank, u_int32_t idA, u_int32_t idB) //32b filters { - filter32Init(bank, 1, idA, idB); + filter32Init(bank, 1, idA, idB); + // filter32Init(0, 1, 0x00232461, 0x00232461); } -void eXoCAN::filterMask32Init(int bank, int id, int mask) //32b filters +void eXoCAN::filterMask32Init(int bank, u_int32_t id, u_int32_t mask) //32b filters { filter32Init(bank, 0, id, mask); } -void eXoCAN::filter32Init(int bank, int mode, int a, int b) //32b filters +void eXoCAN::filter32Init(int bank, int mode, u_int32_t a, u_int32_t b) //32b filters { - periphBit(FINIT) = 1; // FINIT 'init' filter mode ] - periphBit(fa1r, bank) = 0; // de-activate filter 'bank' - periphBit(fs1r, bank) = 1; // fsc filter scale reg, 0 => 2ea. 16b, 1=>32b - periphBit(fm1r, bank) = mode; // fbm list mode = 1, 0 = mask - MMIO32(fr1 + (8 * bank)) = a << 21; // the RXID/MASK to match ] - MMIO32(fr2 + (8 * bank)) = b << 21; // must replace a mask of zeros so that everything isn't passed - periphBit(fa1r, bank) = 1; // activate this filter ] - periphBit(FINIT) = 0; // ~FINIT 'active' filter mode ] + periphBit(FINIT) = 1; // FINIT 'init' filter mode + periphBit(fa1r, bank) = 0; // de-activate filter 'bank' + periphBit(fs1r, bank) = 1; // fsc filter scale reg, 0 => 2ea. 16b, 1=>32b + periphBit(fm1r, bank) = mode; // fbm list mode = 1, 0 = mask + MMIO32(fr1 + (8 * bank)) = (a << 3) | 4; // the RXID/MASK to match + MMIO32(fr2 + (8 * bank)) = (b << 3) | 4; // must replace a mask of zeros so that everything isn't passed + periphBit(fa1r, bank) = 1; // activate this filter + periphBit(FINIT) = 0; // ~FINIT 'active' filter mode } //bool eXoCAN::transmit(int txId, const void *ptr, unsigned int len) diff --git a/eXoCAN.h b/eXoCAN.h index da33bcc..dc2c61f 100644 --- a/eXoCAN.h +++ b/eXoCAN.h @@ -16,9 +16,10 @@ C:\Users\jhe\Documents\PlatformIO\Projects\eXoCanInt\lib\eXoCAN // 'list' filters get seached first even when the index is higher that a mask filter -extended IDs are working 4/19 +extended IDs are working 4/19 -constructor now does all the setup 4/27 +constructor now does all the setup 4/27 + bug fix: extended ID filtering wasn't working. Wrong shift + set IDE bit 4/15/21 */ #include @@ -130,8 +131,9 @@ struct msgFrm idtype idLen = STD_ID_LEN; uint8_t txMsgLen = 0x08; MSG txMsg; + //uint8_t txMsg[8]; BusType busConfig = PORTA_11_12_XCVR; - int txDly = 5000; + uint32_t txDly = 5000; }; class eXoCAN @@ -140,7 +142,7 @@ class eXoCAN idtype _extIDs = STD_ID_LEN; idtype _rxExtended; void filter16Init(int bank, int mode, int a = 0, int b = 0, int c = 0, int d = 0); // 16b filters - void filter32Init(int bank, int mode, int a, int b); //32b filters + void filter32Init(int bank, int mode, u_int32_t a, u_int32_t b); //32b filters protected: public: @@ -152,8 +154,8 @@ class eXoCAN void disableInterrupt(); void filterMask16Init(int bank, int idA = 0, int maskA = 0, int idB = 0, int maskB = 0x7ff); // 16b mask filters void filterList16Init(int bank, int idA = 0, int idB = 0, int idC = 0, int idD = 0); // 16b list filters - void filterMask32Init(int bank, int id = 0, int mask = 0); - void filterList32Init(int bank, int idA = 0, int idB = 0); // 32b filters + void filterMask32Init(int bank, u_int32_t id = 0, u_int32_t mask = 0); + void filterList32Init(int bank, u_int32_t idA = 0, u_int32_t idB = 0); // 32b filters bool transmit(int txId, const void *ptr, unsigned int len); //int receive(volatile int *id, volatile int *fltrIdx, volatile void *pData); int receive(volatile int &id, volatile int &fltrIdx, volatile uint8_t pData[]); diff --git a/library.json b/library.json index 397a113..a8e993e 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type":"git", "url":"https://github.com/exothink/eXoCAN.git" }, - "version":"1.0.1", + "version":"1.0.2", "authors": { "name": "John Eckert", diff --git a/library.properties b/library.properties index a65f1d7..7d0711a 100644 --- a/library.properties +++ b/library.properties @@ -1,7 +1,7 @@ name=eXoThink STM32F103 CAN Bus Library keywords=CAN Bus, STM32DUINO, automobile, Blue Pill description=Easy to use eXoCAN supports polling/interrupts, single wire and CAN bus xcvrs, 16/32b filters, STD/Extended IDs, listen only,... -version=1.0.1 +version=1.0.2 author=John Eckert maintainer=https://github.com/exothink sentence=STM32duino CAN library for STM32F103.