Skip to content

Commit 7df8da1

Browse files
committed
32 bit rx filters fixed
1 parent 16d1f79 commit 7df8da1

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

eXoCAN.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "eXoCAN.h"
22

33
// vers 1.0.1 02/06/2021
4+
// vers 1.0.2 04/15/2021
45

56
void eXoCAN::begin(idtype addrType, int brp, BusType hw)
67
{
@@ -125,26 +126,27 @@ void eXoCAN::filter16Init(int bank, int mode, int a, int b, int c, int d) // 16b
125126
periphBit(FINIT) = 0; // ~FINIT 'active' filter mode ]
126127
}
127128

128-
void eXoCAN::filterList32Init(int bank, int idA, int idB) //32b filters
129+
void eXoCAN::filterList32Init(int bank, u_int32_t idA, u_int32_t idB) //32b filters
129130
{
130-
filter32Init(bank, 1, idA, idB);
131+
filter32Init(bank, 1, idA, idB);
132+
// filter32Init(0, 1, 0x00232461, 0x00232461);
131133
}
132134

133-
void eXoCAN::filterMask32Init(int bank, int id, int mask) //32b filters
135+
void eXoCAN::filterMask32Init(int bank, u_int32_t id, u_int32_t mask) //32b filters
134136
{
135137
filter32Init(bank, 0, id, mask);
136138
}
137139

138-
void eXoCAN::filter32Init(int bank, int mode, int a, int b) //32b filters
140+
void eXoCAN::filter32Init(int bank, int mode, u_int32_t a, u_int32_t b) //32b filters
139141
{
140-
periphBit(FINIT) = 1; // FINIT 'init' filter mode ]
141-
periphBit(fa1r, bank) = 0; // de-activate filter 'bank'
142-
periphBit(fs1r, bank) = 1; // fsc filter scale reg, 0 => 2ea. 16b, 1=>32b
143-
periphBit(fm1r, bank) = mode; // fbm list mode = 1, 0 = mask
144-
MMIO32(fr1 + (8 * bank)) = a << 21; // the RXID/MASK to match ]
145-
MMIO32(fr2 + (8 * bank)) = b << 21; // must replace a mask of zeros so that everything isn't passed
146-
periphBit(fa1r, bank) = 1; // activate this filter ]
147-
periphBit(FINIT) = 0; // ~FINIT 'active' filter mode ]
142+
periphBit(FINIT) = 1; // FINIT 'init' filter mode
143+
periphBit(fa1r, bank) = 0; // de-activate filter 'bank'
144+
periphBit(fs1r, bank) = 1; // fsc filter scale reg, 0 => 2ea. 16b, 1=>32b
145+
periphBit(fm1r, bank) = mode; // fbm list mode = 1, 0 = mask
146+
MMIO32(fr1 + (8 * bank)) = (a << 3) | 4; // the RXID/MASK to match
147+
MMIO32(fr2 + (8 * bank)) = (b << 3) | 4; // must replace a mask of zeros so that everything isn't passed
148+
periphBit(fa1r, bank) = 1; // activate this filter
149+
periphBit(FINIT) = 0; // ~FINIT 'active' filter mode
148150
}
149151

150152
//bool eXoCAN::transmit(int txId, const void *ptr, unsigned int len)

eXoCAN.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ C:\Users\jhe\Documents\PlatformIO\Projects\eXoCanInt\lib\eXoCAN
1616
// 'list' filters get seached first even when the index is higher that a mask filter
1717
1818
19-
extended IDs are working 4/19
19+
extended IDs are working 4/19
2020
21-
constructor now does all the setup 4/27
21+
constructor now does all the setup 4/27
22+
bug fix: extended ID filtering wasn't working. Wrong shift + set IDE bit 4/15/21
2223
*/
2324
#include <arduino.h>
2425

@@ -130,8 +131,9 @@ struct msgFrm
130131
idtype idLen = STD_ID_LEN;
131132
uint8_t txMsgLen = 0x08;
132133
MSG txMsg;
134+
//uint8_t txMsg[8];
133135
BusType busConfig = PORTA_11_12_XCVR;
134-
int txDly = 5000;
136+
uint32_t txDly = 5000;
135137
};
136138

137139
class eXoCAN
@@ -140,7 +142,7 @@ class eXoCAN
140142
idtype _extIDs = STD_ID_LEN;
141143
idtype _rxExtended;
142144
void filter16Init(int bank, int mode, int a = 0, int b = 0, int c = 0, int d = 0); // 16b filters
143-
void filter32Init(int bank, int mode, int a, int b); //32b filters
145+
void filter32Init(int bank, int mode, u_int32_t a, u_int32_t b); //32b filters
144146

145147
protected:
146148
public:
@@ -152,8 +154,8 @@ class eXoCAN
152154
void disableInterrupt();
153155
void filterMask16Init(int bank, int idA = 0, int maskA = 0, int idB = 0, int maskB = 0x7ff); // 16b mask filters
154156
void filterList16Init(int bank, int idA = 0, int idB = 0, int idC = 0, int idD = 0); // 16b list filters
155-
void filterMask32Init(int bank, int id = 0, int mask = 0);
156-
void filterList32Init(int bank, int idA = 0, int idB = 0); // 32b filters
157+
void filterMask32Init(int bank, u_int32_t id = 0, u_int32_t mask = 0);
158+
void filterList32Init(int bank, u_int32_t idA = 0, u_int32_t idB = 0); // 32b filters
157159
bool transmit(int txId, const void *ptr, unsigned int len);
158160
//int receive(volatile int *id, volatile int *fltrIdx, volatile void *pData);
159161
int receive(volatile int &id, volatile int &fltrIdx, volatile uint8_t pData[]);

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type":"git",
88
"url":"https://github.com/exothink/eXoCAN.git"
99
},
10-
"version":"1.0.1",
10+
"version":"1.0.2",
1111
"authors":
1212
{
1313
"name": "John Eckert",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name=eXoThink STM32F103 CAN Bus Library
22
keywords=CAN Bus, STM32DUINO, automobile, Blue Pill
33
description=Easy to use eXoCAN supports polling/interrupts, single wire and CAN bus xcvrs, 16/32b filters, STD/Extended IDs, listen only,...
4-
version=1.0.1
4+
version=1.0.2
55
author=John Eckert
66
maintainer=https://github.com/exothink
77
sentence=STM32duino CAN library for STM32F103.

0 commit comments

Comments
 (0)