SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
current_sense/hardware_specific/teensy/teensy4_mcu.h
Go to the documentation of this file.
1
2#ifndef TEENSY4_CURRENTSENSE_MCU_DEF
3#define TEENSY4_CURRENTSENSE_MCU_DEF
4
5#include "../../hardware_api.h"
6#include "../../../common/foc_utils.h"
7
8// if defined
9// - Teensy 4.0
10// - Teensy 4.1
11#if defined(__arm__) && defined(CORE_TEENSY) && ( defined(__IMXRT1062__) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY_MICROMOD) )
12
13#define _ADC_VOLTAGE 3.3f
14#define _ADC_RESOLUTION 4026.0f
15
16// generic implementation of the hardware specific structure
17// containing all the necessary current sense parameters
18// will be returned as a void pointer from the _configureADCx functions
19// will be provided to the _readADCVoltageX() as a void pointer
20typedef struct Teensy4CurrentSenseParams {
21 int pins[3] = {(int)NOT_SET};
22 float adc_voltage_conv;
23} Teensy4CurrentSenseParams;
24
25
26
27const uint8_t pin_to_channel[] = { // pg 482
28 7, // 0/A0 AD_B1_02
29 8, // 1/A1 AD_B1_03
30 12, // 2/A2 AD_B1_07
31 11, // 3/A3 AD_B1_06
32 6, // 4/A4 AD_B1_01
33 5, // 5/A5 AD_B1_00
34 15, // 6/A6 AD_B1_10
35 0, // 7/A7 AD_B1_11
36 13, // 8/A8 AD_B1_08
37 14, // 9/A9 AD_B1_09
38 1, // 24/A10 AD_B0_12
39 2, // 25/A11 AD_B0_13
40 128+3, // 26/A12 AD_B1_14 - only on ADC2, 3
41 128+4, // 27/A13 AD_B1_15 - only on ADC2, 4
42 7, // 14/A0 AD_B1_02
43 8, // 15/A1 AD_B1_03
44 12, // 16/A2 AD_B1_07
45 11, // 17/A3 AD_B1_06
46 6, // 18/A4 AD_B1_01
47 5, // 19/A5 AD_B1_00
48 15, // 20/A6 AD_B1_10
49 0, // 21/A7 AD_B1_11
50 13, // 22/A8 AD_B1_08
51 14, // 23/A9 AD_B1_09
52 1, // 24/A10 AD_B0_12
53 2, // 25/A11 AD_B0_13
54 128+3, // 26/A12 AD_B1_14 - only on ADC2, 3
55 128+4, // 27/A13 AD_B1_15 - only on ADC2, 4
56#ifdef ARDUINO_TEENSY41
57 255, // 28
58 255, // 29
59 255, // 30
60 255, // 31
61 255, // 32
62 255, // 33
63 255, // 34
64 255, // 35
65 255, // 36
66 255, // 37
67 128+1, // 38/A14 AD_B1_12 - only on ADC2, 1
68 128+2, // 39/A15 AD_B1_13 - only on ADC2, 2
69 9, // 40/A16 AD_B1_04
70 10, // 41/A17 AD_B1_05
71#endif
72};
73
74
75#endif
76
77#endif
return raw_adc *GenericCurrentSenseParams *cs_params adc_voltage_conv
#define NOT_SET
Definition foc_utils.h:34