Format new content
This commit is contained in:
@@ -85,7 +85,7 @@ enum StatusLED {
|
|||||||
LED_HEATING, // The unit is heating up to temperature
|
LED_HEATING, // The unit is heating up to temperature
|
||||||
LED_HOT, // The unit is at operating temperature
|
LED_HOT, // The unit is at operating temperature
|
||||||
LED_COOLING_STILL_HOT, // The unit is off and cooling but still hot
|
LED_COOLING_STILL_HOT, // The unit is off and cooling but still hot
|
||||||
LED_UNKNOWN, //
|
LED_UNKNOWN, //
|
||||||
};
|
};
|
||||||
void setStatusLED(const enum StatusLED state);
|
void setStatusLED(const enum StatusLED state);
|
||||||
|
|
||||||
|
|||||||
@@ -13,453 +13,427 @@
|
|||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include <IRQ.h>
|
#include <IRQ.h>
|
||||||
volatile uint16_t PWMSafetyTimer = 0;
|
volatile uint16_t PWMSafetyTimer = 0;
|
||||||
volatile uint8_t pendingPWM = 0;
|
volatile uint8_t pendingPWM = 0;
|
||||||
uint16_t totalPWM = 255;
|
uint16_t totalPWM = 255;
|
||||||
const uint16_t powerPWM = 255;
|
const uint16_t powerPWM = 255;
|
||||||
|
|
||||||
history<uint16_t, PID_TIM_HZ> rawTempFilter = { { 0 }, 0, 0 };
|
history<uint16_t, PID_TIM_HZ> rawTempFilter = {{0}, 0, 0};
|
||||||
void resetWatchdog() {
|
void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); }
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TEMP_NTC
|
#ifdef TEMP_NTC
|
||||||
// Lookup table for the NTC
|
// Lookup table for the NTC
|
||||||
// Stored as ADCReading,Temp in degC
|
// Stored as ADCReading,Temp in degC
|
||||||
static const uint16_t NTCHandleLookup[] = {
|
static const uint16_t NTCHandleLookup[] = {
|
||||||
// ADC Reading , Temp in Cx10
|
// ADC Reading , Temp in Cx10
|
||||||
808, 1600, //
|
808, 1600, //
|
||||||
832, 1590, //
|
832, 1590, //
|
||||||
848, 1580, //
|
848, 1580, //
|
||||||
872, 1570, //
|
872, 1570, //
|
||||||
888, 1560, //
|
888, 1560, //
|
||||||
912, 1550, //
|
912, 1550, //
|
||||||
936, 1540, //
|
936, 1540, //
|
||||||
960, 1530, //
|
960, 1530, //
|
||||||
984, 1520, //
|
984, 1520, //
|
||||||
1008, 1510, //
|
1008, 1510, //
|
||||||
1032, 1500, //
|
1032, 1500, //
|
||||||
1056, 1490, //
|
1056, 1490, //
|
||||||
1080, 1480, //
|
1080, 1480, //
|
||||||
1112, 1470, //
|
1112, 1470, //
|
||||||
1136, 1460, //
|
1136, 1460, //
|
||||||
1168, 1450, //
|
1168, 1450, //
|
||||||
1200, 1440, //
|
1200, 1440, //
|
||||||
1224, 1430, //
|
1224, 1430, //
|
||||||
1256, 1420, //
|
1256, 1420, //
|
||||||
1288, 1410, //
|
1288, 1410, //
|
||||||
1328, 1400, //
|
1328, 1400, //
|
||||||
1360, 1390, //
|
1360, 1390, //
|
||||||
1392, 1380, //
|
1392, 1380, //
|
||||||
1432, 1370, //
|
1432, 1370, //
|
||||||
1464, 1360, //
|
1464, 1360, //
|
||||||
1504, 1350, //
|
1504, 1350, //
|
||||||
1544, 1340, //
|
1544, 1340, //
|
||||||
1584, 1330, //
|
1584, 1330, //
|
||||||
1632, 1320, //
|
1632, 1320, //
|
||||||
1672, 1310, //
|
1672, 1310, //
|
||||||
1720, 1300, //
|
1720, 1300, //
|
||||||
1760, 1290, //
|
1760, 1290, //
|
||||||
1808, 1280, //
|
1808, 1280, //
|
||||||
1856, 1270, //
|
1856, 1270, //
|
||||||
1912, 1260, //
|
1912, 1260, //
|
||||||
1960, 1250, //
|
1960, 1250, //
|
||||||
2016, 1240, //
|
2016, 1240, //
|
||||||
2072, 1230, //
|
2072, 1230, //
|
||||||
2128, 1220, //
|
2128, 1220, //
|
||||||
2184, 1210, //
|
2184, 1210, //
|
||||||
2248, 1200, //
|
2248, 1200, //
|
||||||
2304, 1190, //
|
2304, 1190, //
|
||||||
2368, 1180, //
|
2368, 1180, //
|
||||||
2440, 1170, //
|
2440, 1170, //
|
||||||
2504, 1160, //
|
2504, 1160, //
|
||||||
2576, 1150, //
|
2576, 1150, //
|
||||||
2648, 1140, //
|
2648, 1140, //
|
||||||
2720, 1130, //
|
2720, 1130, //
|
||||||
2792, 1120, //
|
2792, 1120, //
|
||||||
2872, 1110, //
|
2872, 1110, //
|
||||||
2952, 1100, //
|
2952, 1100, //
|
||||||
3040, 1090, //
|
3040, 1090, //
|
||||||
3128, 1080, //
|
3128, 1080, //
|
||||||
3216, 1070, //
|
3216, 1070, //
|
||||||
3304, 1060, //
|
3304, 1060, //
|
||||||
3400, 1050, //
|
3400, 1050, //
|
||||||
3496, 1040, //
|
3496, 1040, //
|
||||||
3592, 1030, //
|
3592, 1030, //
|
||||||
3696, 1020, //
|
3696, 1020, //
|
||||||
3800, 1010, //
|
3800, 1010, //
|
||||||
3912, 1000, //
|
3912, 1000, //
|
||||||
4024, 990, //
|
4024, 990, //
|
||||||
4136, 980, //
|
4136, 980, //
|
||||||
4256, 970, //
|
4256, 970, //
|
||||||
4376, 960, //
|
4376, 960, //
|
||||||
4504, 950, //
|
4504, 950, //
|
||||||
4632, 940, //
|
4632, 940, //
|
||||||
4768, 930, //
|
4768, 930, //
|
||||||
4904, 920, //
|
4904, 920, //
|
||||||
5048, 910, //
|
5048, 910, //
|
||||||
5192, 900, //
|
5192, 900, //
|
||||||
5336, 890, //
|
5336, 890, //
|
||||||
5488, 880, //
|
5488, 880, //
|
||||||
5648, 870, //
|
5648, 870, //
|
||||||
5808, 860, //
|
5808, 860, //
|
||||||
5976, 850, //
|
5976, 850, //
|
||||||
6144, 840, //
|
6144, 840, //
|
||||||
6320, 830, //
|
6320, 830, //
|
||||||
6504, 820, //
|
6504, 820, //
|
||||||
6688, 810, //
|
6688, 810, //
|
||||||
6872, 800, //
|
6872, 800, //
|
||||||
7072, 790, //
|
7072, 790, //
|
||||||
7264, 780, //
|
7264, 780, //
|
||||||
7472, 770, //
|
7472, 770, //
|
||||||
7680, 760, //
|
7680, 760, //
|
||||||
7896, 750, //
|
7896, 750, //
|
||||||
8112, 740, //
|
8112, 740, //
|
||||||
8336, 730, //
|
8336, 730, //
|
||||||
8568, 720, //
|
8568, 720, //
|
||||||
8800, 710, //
|
8800, 710, //
|
||||||
9040, 700, //
|
9040, 700, //
|
||||||
9288, 690, //
|
9288, 690, //
|
||||||
9536, 680, //
|
9536, 680, //
|
||||||
9792, 670, //
|
9792, 670, //
|
||||||
10056, 660, //
|
10056, 660, //
|
||||||
10320, 650, //
|
10320, 650, //
|
||||||
10592, 640, //
|
10592, 640, //
|
||||||
10872, 630, //
|
10872, 630, //
|
||||||
11152, 620, //
|
11152, 620, //
|
||||||
11440, 610, //
|
11440, 610, //
|
||||||
11728, 600, //
|
11728, 600, //
|
||||||
12024, 590, //
|
12024, 590, //
|
||||||
12320, 580, //
|
12320, 580, //
|
||||||
12632, 570, //
|
12632, 570, //
|
||||||
12936, 560, //
|
12936, 560, //
|
||||||
13248, 550, //
|
13248, 550, //
|
||||||
13568, 540, //
|
13568, 540, //
|
||||||
13888, 530, //
|
13888, 530, //
|
||||||
14216, 520, //
|
14216, 520, //
|
||||||
14544, 510, //
|
14544, 510, //
|
||||||
14880, 500, //
|
14880, 500, //
|
||||||
15216, 490, //
|
15216, 490, //
|
||||||
15552, 480, //
|
15552, 480, //
|
||||||
15888, 470, //
|
15888, 470, //
|
||||||
16232, 460, //
|
16232, 460, //
|
||||||
16576, 450, //
|
16576, 450, //
|
||||||
16920, 440, //
|
16920, 440, //
|
||||||
17272, 430, //
|
17272, 430, //
|
||||||
17616, 420, //
|
17616, 420, //
|
||||||
17968, 410, //
|
17968, 410, //
|
||||||
18320, 400, //
|
18320, 400, //
|
||||||
18664, 390, //
|
18664, 390, //
|
||||||
19016, 380, //
|
19016, 380, //
|
||||||
19368, 370, //
|
19368, 370, //
|
||||||
19712, 360, //
|
19712, 360, //
|
||||||
20064, 350, //
|
20064, 350, //
|
||||||
20408, 340, //
|
20408, 340, //
|
||||||
20752, 330, //
|
20752, 330, //
|
||||||
21088, 320, //
|
21088, 320, //
|
||||||
21432, 310, //
|
21432, 310, //
|
||||||
21768, 300, //
|
21768, 300, //
|
||||||
22096, 290, //
|
22096, 290, //
|
||||||
22424, 280, //
|
22424, 280, //
|
||||||
22752, 270, //
|
22752, 270, //
|
||||||
23072, 260, //
|
23072, 260, //
|
||||||
23392, 250, //
|
23392, 250, //
|
||||||
23704, 240, //
|
23704, 240, //
|
||||||
24008, 230, //
|
24008, 230, //
|
||||||
24312, 220, //
|
24312, 220, //
|
||||||
24608, 210, //
|
24608, 210, //
|
||||||
24904, 200, //
|
24904, 200, //
|
||||||
25192, 190, //
|
25192, 190, //
|
||||||
25472, 180, //
|
25472, 180, //
|
||||||
25744, 170, //
|
25744, 170, //
|
||||||
26016, 160, //
|
26016, 160, //
|
||||||
26280, 150, //
|
26280, 150, //
|
||||||
26536, 140, //
|
26536, 140, //
|
||||||
26784, 130, //
|
26784, 130, //
|
||||||
27024, 120, //
|
27024, 120, //
|
||||||
27264, 110, //
|
27264, 110, //
|
||||||
27496, 100, //
|
27496, 100, //
|
||||||
27720, 90, //
|
27720, 90, //
|
||||||
27936, 80, //
|
27936, 80, //
|
||||||
28144, 70, //
|
28144, 70, //
|
||||||
28352, 60, //
|
28352, 60, //
|
||||||
28544, 50, //
|
28544, 50, //
|
||||||
28736, 40, //
|
28736, 40, //
|
||||||
28920, 30, //
|
28920, 30, //
|
||||||
29104, 20, //
|
29104, 20, //
|
||||||
29272, 10, //
|
29272, 10, //
|
||||||
};
|
};
|
||||||
const int NTCHandleLookupItems = sizeof(NTCHandleLookup)
|
const int NTCHandleLookupItems = sizeof(NTCHandleLookup) / (2 * sizeof(uint16_t));
|
||||||
/ (2 * sizeof(uint16_t));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// These are called by the HAL after the corresponding events from the system
|
// These are called by the HAL after the corresponding events from the system
|
||||||
// timers.
|
// timers.
|
||||||
|
|
||||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||||
// Period has elapsed
|
// Period has elapsed
|
||||||
if (htim->Instance == TIM4) {
|
if (htim->Instance == TIM4) {
|
||||||
// STM uses this for internal functions as a counter for timeouts
|
// STM uses this for internal functions as a counter for timeouts
|
||||||
HAL_IncTick();
|
HAL_IncTick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint16_t getHandleTemperature() {
|
uint16_t getHandleTemperature() {
|
||||||
int32_t result = getADC(0);
|
int32_t result = getADC(0);
|
||||||
return Utils::InterpolateLookupTable(NTCHandleLookup, NTCHandleLookupItems,
|
return Utils::InterpolateLookupTable(NTCHandleLookup, NTCHandleLookupItems, result);
|
||||||
result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getTipInstantTemperature() {
|
uint16_t getTipInstantTemperature() { return getADC(2); }
|
||||||
return getADC(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getTipRawTemp(uint8_t refresh) {
|
uint16_t getTipRawTemp(uint8_t refresh) {
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
uint16_t lastSample = getTipInstantTemperature();
|
uint16_t lastSample = getTipInstantTemperature();
|
||||||
rawTempFilter.update(lastSample);
|
rawTempFilter.update(lastSample);
|
||||||
return lastSample;
|
return lastSample;
|
||||||
} else {
|
} else {
|
||||||
return rawTempFilter.average();
|
return rawTempFilter.average();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
||||||
// ADC maximum is 32767 == 3.3V at input == 28.05V at VIN
|
// ADC maximum is 32767 == 3.3V at input == 28.05V at VIN
|
||||||
// Therefore we can divide down from there
|
// Therefore we can divide down from there
|
||||||
// Multiplying ADC max by 4 for additional calibration options,
|
// Multiplying ADC max by 4 for additional calibration options,
|
||||||
// ideal term is 467
|
// ideal term is 467
|
||||||
static uint8_t preFillneeded = 10;
|
static uint8_t preFillneeded = 10;
|
||||||
static uint32_t samples[BATTFILTERDEPTH];
|
static uint32_t samples[BATTFILTERDEPTH];
|
||||||
static uint8_t index = 0;
|
static uint8_t index = 0;
|
||||||
if (preFillneeded) {
|
if (preFillneeded) {
|
||||||
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
|
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
|
||||||
samples[i] = getADC(1);
|
samples[i] = getADC(1);
|
||||||
preFillneeded--;
|
preFillneeded--;
|
||||||
}
|
}
|
||||||
if (sample) {
|
if (sample) {
|
||||||
samples[index] = getADC(1);
|
samples[index] = getADC(1);
|
||||||
index = (index + 1) % BATTFILTERDEPTH;
|
index = (index + 1) % BATTFILTERDEPTH;
|
||||||
}
|
}
|
||||||
uint32_t sum = 0;
|
uint32_t sum = 0;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
|
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
|
||||||
sum += samples[i];
|
sum += samples[i];
|
||||||
|
|
||||||
sum /= BATTFILTERDEPTH;
|
sum /= BATTFILTERDEPTH;
|
||||||
if (divisor == 0) {
|
if (divisor == 0) {
|
||||||
divisor = 1;
|
divisor = 1;
|
||||||
}
|
}
|
||||||
return sum * 4 / divisor;
|
return sum * 4 / divisor;
|
||||||
}
|
}
|
||||||
bool tryBetterPWM(uint8_t pwm) {
|
bool tryBetterPWM(uint8_t pwm) {
|
||||||
// We dont need this for the MHP30
|
// We dont need this for the MHP30
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void setTipPWM(uint8_t pulse) {
|
void setTipPWM(uint8_t pulse) {
|
||||||
// We can just set the timer directly
|
// We can just set the timer directly
|
||||||
htim3.Instance->CCR1 = pulse;
|
htim3.Instance->CCR1 = pulse;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unstick_I2C() {
|
void unstick_I2C() {
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
int timeout = 100;
|
int timeout = 100;
|
||||||
int timeout_cnt = 0;
|
int timeout_cnt = 0;
|
||||||
|
|
||||||
// 1. Clear PE bit.
|
// 1. Clear PE bit.
|
||||||
hi2c1.Instance->CR1 &= ~(0x0001);
|
hi2c1.Instance->CR1 &= ~(0x0001);
|
||||||
/**I2C1 GPIO Configuration
|
/**I2C1 GPIO Configuration
|
||||||
PB6 ------> I2C1_SCL
|
PB6 ------> I2C1_SCL
|
||||||
PB7 ------> I2C1_SDA
|
PB7 ------> I2C1_SDA
|
||||||
*/
|
*/
|
||||||
// 2. Configure the SCL and SDA I/Os as General Purpose Output Open-Drain, High level (Write 1 to GPIOx_ODR).
|
// 2. Configure the SCL and SDA I/Os as General Purpose Output Open-Drain, High level (Write 1 to GPIOx_ODR).
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = SCL_Pin;
|
GPIO_InitStruct.Pin = SCL_Pin;
|
||||||
HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
|
||||||
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = SDA_Pin;
|
GPIO_InitStruct.Pin = SDA_Pin;
|
||||||
HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
|
||||||
HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
while (GPIO_PIN_SET != HAL_GPIO_ReadPin(SDA_GPIO_Port, SDA_Pin)) {
|
while (GPIO_PIN_SET != HAL_GPIO_ReadPin(SDA_GPIO_Port, SDA_Pin)) {
|
||||||
// Move clock to release I2C
|
// Move clock to release I2C
|
||||||
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_RESET);
|
||||||
asm("nop");
|
asm("nop");
|
||||||
asm("nop");
|
asm("nop");
|
||||||
asm("nop");
|
asm("nop");
|
||||||
asm("nop");
|
asm("nop");
|
||||||
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
timeout_cnt++;
|
timeout_cnt++;
|
||||||
if (timeout_cnt > timeout)
|
if (timeout_cnt > timeout)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 12. Configure the SCL and SDA I/Os as Alternate function Open-Drain.
|
// 12. Configure the SCL and SDA I/Os as Alternate function Open-Drain.
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = SCL_Pin;
|
GPIO_InitStruct.Pin = SCL_Pin;
|
||||||
HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = SDA_Pin;
|
GPIO_InitStruct.Pin = SDA_Pin;
|
||||||
HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
|
||||||
HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
// 13. Set SWRST bit in I2Cx_CR1 register.
|
// 13. Set SWRST bit in I2Cx_CR1 register.
|
||||||
hi2c1.Instance->CR1 |= 0x8000;
|
hi2c1.Instance->CR1 |= 0x8000;
|
||||||
|
|
||||||
asm("nop");
|
asm("nop");
|
||||||
|
|
||||||
// 14. Clear SWRST bit in I2Cx_CR1 register.
|
// 14. Clear SWRST bit in I2Cx_CR1 register.
|
||||||
hi2c1.Instance->CR1 &= ~0x8000;
|
hi2c1.Instance->CR1 &= ~0x8000;
|
||||||
|
|
||||||
asm("nop");
|
asm("nop");
|
||||||
|
|
||||||
// 15. Enable the I2C peripheral by setting the PE bit in I2Cx_CR1 register
|
// 15. Enable the I2C peripheral by setting the PE bit in I2Cx_CR1 register
|
||||||
hi2c1.Instance->CR1 |= 0x0001;
|
hi2c1.Instance->CR1 |= 0x0001;
|
||||||
|
|
||||||
// Call initialization function.
|
// Call initialization function.
|
||||||
HAL_I2C_Init(&hi2c1);
|
HAL_I2C_Init(&hi2c1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getButtonA() {
|
uint8_t getButtonA() { return HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ? 1 : 0; }
|
||||||
return HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ?
|
uint8_t getButtonB() { return HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ? 1 : 0; }
|
||||||
1 : 0;
|
|
||||||
}
|
|
||||||
uint8_t getButtonB() {
|
|
||||||
return HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ?
|
|
||||||
1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BSPInit(void) {
|
void BSPInit(void) { WS2812::init(); }
|
||||||
WS2812::init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reboot() {
|
void reboot() { NVIC_SystemReset(); }
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void delay_ms(uint16_t count) {
|
void delay_ms(uint16_t count) { HAL_Delay(count); }
|
||||||
HAL_Delay(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPlatePullup(bool pullingUp) {
|
void setPlatePullup(bool pullingUp) {
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
GPIO_InitStruct.Pin = PLATE_SENSOR_PULLUP_Pin;
|
GPIO_InitStruct.Pin = PLATE_SENSOR_PULLUP_Pin;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
if (pullingUp) {
|
if (pullingUp) {
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
HAL_GPIO_WritePin(PLATE_SENSOR_PULLUP_GPIO_Port,
|
HAL_GPIO_WritePin(PLATE_SENSOR_PULLUP_GPIO_Port, PLATE_SENSOR_PULLUP_Pin, GPIO_PIN_SET);
|
||||||
PLATE_SENSOR_PULLUP_Pin, GPIO_PIN_SET);
|
} else {
|
||||||
} else {
|
// Hi-z
|
||||||
// Hi-z
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
HAL_GPIO_WritePin(PLATE_SENSOR_PULLUP_GPIO_Port, PLATE_SENSOR_PULLUP_Pin, GPIO_PIN_RESET);
|
||||||
HAL_GPIO_WritePin(PLATE_SENSOR_PULLUP_GPIO_Port,
|
}
|
||||||
PLATE_SENSOR_PULLUP_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_Init(PLATE_SENSOR_PULLUP_GPIO_Port, &GPIO_InitStruct);
|
||||||
}
|
|
||||||
HAL_GPIO_Init(PLATE_SENSOR_PULLUP_GPIO_Port, &GPIO_InitStruct);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t tipSenseResistancex10Ohms = 0;
|
uint16_t tipSenseResistancex10Ohms = 0;
|
||||||
bool isTipDisconnected() {
|
bool isTipDisconnected() {
|
||||||
static bool lastTipDisconnectedState = true;
|
static bool lastTipDisconnectedState = true;
|
||||||
static uint16_t adcReadingPD1Set = 0;
|
static uint16_t adcReadingPD1Set = 0;
|
||||||
static TickType_t lastMeas = 0;
|
static TickType_t lastMeas = 0;
|
||||||
// For the MHP30 we want to include a little extra logic in here
|
// For the MHP30 we want to include a little extra logic in here
|
||||||
// As when the tip is first connected we want to measure the ~100 ohm resistor on the base of the tip
|
// As when the tip is first connected we want to measure the ~100 ohm resistor on the base of the tip
|
||||||
// And likewise if its removed we want to clear that measurement
|
// And likewise if its removed we want to clear that measurement
|
||||||
/*
|
/*
|
||||||
* plate_sensor_res = ((adc5_value_PD1_set - adc5_value_PD1_cleared) / (adc5_value_PD1_cleared + 4096 - adc5_value_PD1_set)) * 1000.0;
|
* plate_sensor_res = ((adc5_value_PD1_set - adc5_value_PD1_cleared) / (adc5_value_PD1_cleared + 4096 - adc5_value_PD1_set)) * 1000.0;
|
||||||
* */
|
* */
|
||||||
|
|
||||||
bool tipDisconnected = getADC(2) > (4090*8);
|
bool tipDisconnected = getADC(2) > (4090 * 8);
|
||||||
// We have to handle here that this ^ will trip while measuring the gain resistor
|
// We have to handle here that this ^ will trip while measuring the gain resistor
|
||||||
if (xTaskGetTickCount() - lastMeas
|
if (xTaskGetTickCount() - lastMeas < (TICKS_100MS * 2 + (TICKS_100MS / 2))) {
|
||||||
< (TICKS_100MS * 2 + (TICKS_100MS / 2))) {
|
tipDisconnected = false;
|
||||||
tipDisconnected = false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tipDisconnected != lastTipDisconnectedState) {
|
if (tipDisconnected != lastTipDisconnectedState) {
|
||||||
if (tipDisconnected) {
|
if (tipDisconnected) {
|
||||||
// Tip is now disconnected
|
// Tip is now disconnected
|
||||||
tipSenseResistancex10Ohms = 0; // zero out the resistance
|
tipSenseResistancex10Ohms = 0; // zero out the resistance
|
||||||
adcReadingPD1Set = 0;
|
adcReadingPD1Set = 0;
|
||||||
lastMeas = 0;
|
lastMeas = 0;
|
||||||
}
|
}
|
||||||
lastTipDisconnectedState = tipDisconnected;
|
lastTipDisconnectedState = tipDisconnected;
|
||||||
}
|
}
|
||||||
if (!tipDisconnected) {
|
if (!tipDisconnected) {
|
||||||
if (tipSenseResistancex10Ohms == 0) {
|
if (tipSenseResistancex10Ohms == 0) {
|
||||||
if (lastMeas == 0) {
|
if (lastMeas == 0) {
|
||||||
lastMeas = xTaskGetTickCount();
|
lastMeas = xTaskGetTickCount();
|
||||||
setPlatePullup(true);
|
setPlatePullup(true);
|
||||||
} else if (xTaskGetTickCount() - lastMeas > (TICKS_100MS)) {
|
} else if (xTaskGetTickCount() - lastMeas > (TICKS_100MS)) {
|
||||||
lastMeas = xTaskGetTickCount();
|
lastMeas = xTaskGetTickCount();
|
||||||
// We are sensing the resistance
|
// We are sensing the resistance
|
||||||
if (adcReadingPD1Set == 0) {
|
if (adcReadingPD1Set == 0) {
|
||||||
// We will record the reading for PD1 being set
|
// We will record the reading for PD1 being set
|
||||||
adcReadingPD1Set = getADC(3);
|
adcReadingPD1Set = getADC(3);
|
||||||
setPlatePullup(false);
|
setPlatePullup(false);
|
||||||
} else {
|
} else {
|
||||||
// We have taken reading one
|
// We have taken reading one
|
||||||
uint16_t adcReadingPD1Cleared = getADC(3);
|
uint16_t adcReadingPD1Cleared = getADC(3);
|
||||||
uint32_t a = ((int) adcReadingPD1Set
|
uint32_t a = ((int)adcReadingPD1Set - (int)adcReadingPD1Cleared);
|
||||||
- (int) adcReadingPD1Cleared);
|
a *= 10000;
|
||||||
a *= 10000;
|
uint32_t b = ((int)adcReadingPD1Cleared + (32768 - (int)adcReadingPD1Set));
|
||||||
uint32_t b = ((int) adcReadingPD1Cleared
|
if (b) {
|
||||||
+ (32768 - (int) adcReadingPD1Set));
|
tipSenseResistancex10Ohms = a / b;
|
||||||
if (b) {
|
} else {
|
||||||
tipSenseResistancex10Ohms = a / b;
|
tipSenseResistancex10Ohms = adcReadingPD1Set = lastMeas = 0;
|
||||||
} else {
|
}
|
||||||
tipSenseResistancex10Ohms = adcReadingPD1Set =
|
if (tipSenseResistancex10Ohms > 1100 || tipSenseResistancex10Ohms < 900) {
|
||||||
lastMeas = 0;
|
tipSenseResistancex10Ohms = 0; // out of range
|
||||||
}
|
adcReadingPD1Set = 0;
|
||||||
if (tipSenseResistancex10Ohms > 1100
|
lastMeas = 0;
|
||||||
|| tipSenseResistancex10Ohms < 900) {
|
}
|
||||||
tipSenseResistancex10Ohms = 0; // out of range
|
}
|
||||||
adcReadingPD1Set = 0;
|
}
|
||||||
lastMeas = 0;
|
return true; // we fake tip being disconnected until this is measured
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true; // we fake tip being disconnected until this is measured
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tipDisconnected;
|
return tipDisconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStatusLED(const enum StatusLED state) {
|
void setStatusLED(const enum StatusLED state) {
|
||||||
static enum StatusLED lastState = LED_UNKNOWN;
|
static enum StatusLED lastState = LED_UNKNOWN;
|
||||||
if (lastState != state || state == LED_HEATING) {
|
if (lastState != state || state == LED_HEATING) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case LED_UNKNOWN:
|
case LED_UNKNOWN:
|
||||||
case LED_OFF:
|
case LED_OFF:
|
||||||
WS2812::led_set_color(0, 0, 0, 0);
|
WS2812::led_set_color(0, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
case LED_STANDBY:
|
case LED_STANDBY:
|
||||||
WS2812::led_set_color(0, 0, 0xFF, 0); //green
|
WS2812::led_set_color(0, 0, 0xFF, 0); // green
|
||||||
break;
|
break;
|
||||||
case LED_HEATING: {
|
case LED_HEATING: {
|
||||||
WS2812::led_set_color(0, ((HAL_GetTick() / 10) % 192) + 64, 0,
|
WS2812::led_set_color(0, ((HAL_GetTick() / 10) % 192) + 64, 0,
|
||||||
0); //Red fade
|
0); // Red fade
|
||||||
}
|
} break;
|
||||||
break;
|
case LED_HOT:
|
||||||
case LED_HOT:
|
WS2812::led_set_color(0, 0xFF, 0, 0); // red
|
||||||
WS2812::led_set_color(0, 0xFF, 0, 0); //red
|
break;
|
||||||
break;
|
case LED_COOLING_STILL_HOT:
|
||||||
case LED_COOLING_STILL_HOT:
|
WS2812::led_set_color(0, 0xFF, 0x8C, 0x00); // Orange
|
||||||
WS2812::led_set_color(0, 0xFF, 0x8C, 0x00); //Orange
|
break;
|
||||||
break;
|
}
|
||||||
}
|
WS2812::led_update();
|
||||||
WS2812::led_update();
|
lastState = state;
|
||||||
lastState = state;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,220 +1,198 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @file stm32f1xx.h
|
* @file stm32f1xx.h
|
||||||
* @author MCD Application Team
|
* @author MCD Application Team
|
||||||
* @brief CMSIS STM32F1xx Device Peripheral Access Layer Header File.
|
* @brief CMSIS STM32F1xx Device Peripheral Access Layer Header File.
|
||||||
*
|
*
|
||||||
* The file is the unique include file that the application programmer
|
* The file is the unique include file that the application programmer
|
||||||
* is using in the C source code, usually in main.c. This file contains:
|
* is using in the C source code, usually in main.c. This file contains:
|
||||||
* - Configuration section that allows to select:
|
* - Configuration section that allows to select:
|
||||||
* - The STM32F1xx device used in the target application
|
* - The STM32F1xx device used in the target application
|
||||||
* - To use or not the peripheral<61>s drivers in application code(i.e.
|
* - To use or not the peripheral<61>s drivers in application code(i.e.
|
||||||
* code will be based on direct access to peripheral<61>s registers
|
* code will be based on direct access to peripheral<61>s registers
|
||||||
* rather than drivers API), this option is controlled by
|
* rather than drivers API), this option is controlled by
|
||||||
* "#define USE_HAL_DRIVER"
|
* "#define USE_HAL_DRIVER"
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
* @attention
|
||||||
*
|
*
|
||||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||||
* All rights reserved.</center></h2>
|
* All rights reserved.</center></h2>
|
||||||
*
|
*
|
||||||
* This software component is licensed by ST under BSD 3-Clause license,
|
* This software component is licensed by ST under BSD 3-Clause license,
|
||||||
* the "License"; You may not use this file except in compliance with the
|
* the "License"; You may not use this file except in compliance with the
|
||||||
* License. You may obtain a copy of the License at:
|
* License. You may obtain a copy of the License at:
|
||||||
* opensource.org/licenses/BSD-3-Clause
|
* opensource.org/licenses/BSD-3-Clause
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup CMSIS
|
/** @addtogroup CMSIS
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup stm32f1xx
|
/** @addtogroup stm32f1xx
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __STM32F1XX_H
|
#ifndef __STM32F1XX_H
|
||||||
#define __STM32F1XX_H
|
#define __STM32F1XX_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @addtogroup Library_configuration_section
|
/** @addtogroup Library_configuration_section
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief STM32 Family
|
* @brief STM32 Family
|
||||||
*/
|
*/
|
||||||
#if !defined (STM32F1)
|
#if !defined(STM32F1)
|
||||||
#define STM32F1
|
#define STM32F1
|
||||||
#endif /* STM32F1 */
|
#endif /* STM32F1 */
|
||||||
|
|
||||||
/* Uncomment the line below according to the target STM32L device used in your
|
/* Uncomment the line below according to the target STM32L device used in your
|
||||||
application
|
application
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined (STM32F100xB) && !defined (STM32F100xE) && !defined (STM32F101x6) && \
|
#if !defined(STM32F100xB) && !defined(STM32F100xE) && !defined(STM32F101x6) && !defined(STM32F101xB) && !defined(STM32F101xE) && !defined(STM32F101xG) && !defined(STM32F102x6) \
|
||||||
!defined (STM32F101xB) && !defined (STM32F101xE) && !defined (STM32F101xG) && !defined (STM32F102x6) && !defined (STM32F102xB) && !defined (STM32F103x6) && \
|
&& !defined(STM32F102xB) && !defined(STM32F103x6) && !defined(STM32F103xB) && !defined(STM32F103xE) && !defined(STM32F103xG) && !defined(STM32F105xC) && !defined(STM32F107xC)
|
||||||
!defined (STM32F103xB) && !defined (STM32F103xE) && !defined (STM32F103xG) && !defined (STM32F105xC) && !defined (STM32F107xC)
|
/* #define STM32F100xB */ /*!< STM32F100C4, STM32F100R4, STM32F100C6, STM32F100R6, STM32F100C8, STM32F100R8, STM32F100V8, STM32F100CB, STM32F100RB and STM32F100VB */
|
||||||
/* #define STM32F100xB */ /*!< STM32F100C4, STM32F100R4, STM32F100C6, STM32F100R6, STM32F100C8, STM32F100R8, STM32F100V8, STM32F100CB, STM32F100RB and STM32F100VB */
|
/* #define STM32F100xE */ /*!< STM32F100RC, STM32F100VC, STM32F100ZC, STM32F100RD, STM32F100VD, STM32F100ZD, STM32F100RE, STM32F100VE and STM32F100ZE */
|
||||||
/* #define STM32F100xE */ /*!< STM32F100RC, STM32F100VC, STM32F100ZC, STM32F100RD, STM32F100VD, STM32F100ZD, STM32F100RE, STM32F100VE and STM32F100ZE */
|
/* #define STM32F101x6 */ /*!< STM32F101C4, STM32F101R4, STM32F101T4, STM32F101C6, STM32F101R6 and STM32F101T6 Devices */
|
||||||
/* #define STM32F101x6 */ /*!< STM32F101C4, STM32F101R4, STM32F101T4, STM32F101C6, STM32F101R6 and STM32F101T6 Devices */
|
/* #define STM32F101xB */ /*!< STM32F101C8, STM32F101R8, STM32F101T8, STM32F101V8, STM32F101CB, STM32F101RB, STM32F101TB and STM32F101VB */
|
||||||
/* #define STM32F101xB */ /*!< STM32F101C8, STM32F101R8, STM32F101T8, STM32F101V8, STM32F101CB, STM32F101RB, STM32F101TB and STM32F101VB */
|
/* #define STM32F101xE */ /*!< STM32F101RC, STM32F101VC, STM32F101ZC, STM32F101RD, STM32F101VD, STM32F101ZD, STM32F101RE, STM32F101VE and STM32F101ZE */
|
||||||
/* #define STM32F101xE */ /*!< STM32F101RC, STM32F101VC, STM32F101ZC, STM32F101RD, STM32F101VD, STM32F101ZD, STM32F101RE, STM32F101VE and STM32F101ZE */
|
/* #define STM32F101xG */ /*!< STM32F101RF, STM32F101VF, STM32F101ZF, STM32F101RG, STM32F101VG and STM32F101ZG */
|
||||||
/* #define STM32F101xG */ /*!< STM32F101RF, STM32F101VF, STM32F101ZF, STM32F101RG, STM32F101VG and STM32F101ZG */
|
/* #define STM32F102x6 */ /*!< STM32F102C4, STM32F102R4, STM32F102C6 and STM32F102R6 */
|
||||||
/* #define STM32F102x6 */ /*!< STM32F102C4, STM32F102R4, STM32F102C6 and STM32F102R6 */
|
/* #define STM32F102xB */ /*!< STM32F102C8, STM32F102R8, STM32F102CB and STM32F102RB */
|
||||||
/* #define STM32F102xB */ /*!< STM32F102C8, STM32F102R8, STM32F102CB and STM32F102RB */
|
/* #define STM32F103x6 */ /*!< STM32F103C4, STM32F103R4, STM32F103T4, STM32F103C6, STM32F103R6 and STM32F103T6 */
|
||||||
/* #define STM32F103x6 */ /*!< STM32F103C4, STM32F103R4, STM32F103T4, STM32F103C6, STM32F103R6 and STM32F103T6 */
|
/* #define STM32F103xB */ /*!< STM32F103C8, STM32F103R8, STM32F103T8, STM32F103V8, STM32F103CB, STM32F103RB, STM32F103TB and STM32F103VB */
|
||||||
/* #define STM32F103xB */ /*!< STM32F103C8, STM32F103R8, STM32F103T8, STM32F103V8, STM32F103CB, STM32F103RB, STM32F103TB and STM32F103VB */
|
/* #define STM32F103xE */ /*!< STM32F103RC, STM32F103VC, STM32F103ZC, STM32F103RD, STM32F103VD, STM32F103ZD, STM32F103RE, STM32F103VE and STM32F103ZE */
|
||||||
/* #define STM32F103xE */ /*!< STM32F103RC, STM32F103VC, STM32F103ZC, STM32F103RD, STM32F103VD, STM32F103ZD, STM32F103RE, STM32F103VE and STM32F103ZE */
|
/* #define STM32F103xG */ /*!< STM32F103RF, STM32F103VF, STM32F103ZF, STM32F103RG, STM32F103VG and STM32F103ZG */
|
||||||
/* #define STM32F103xG */ /*!< STM32F103RF, STM32F103VF, STM32F103ZF, STM32F103RG, STM32F103VG and STM32F103ZG */
|
/* #define STM32F105xC */ /*!< STM32F105R8, STM32F105V8, STM32F105RB, STM32F105VB, STM32F105RC and STM32F105VC */
|
||||||
/* #define STM32F105xC */ /*!< STM32F105R8, STM32F105V8, STM32F105RB, STM32F105VB, STM32F105RC and STM32F105VC */
|
/* #define STM32F107xC */ /*!< STM32F107RB, STM32F107VB, STM32F107RC and STM32F107VC */
|
||||||
/* #define STM32F107xC */ /*!< STM32F107RB, STM32F107VB, STM32F107RC and STM32F107VC */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Tip: To avoid modifying this file each time you need to switch between these
|
/* Tip: To avoid modifying this file each time you need to switch between these
|
||||||
devices, you can define the device in your toolchain compiler preprocessor.
|
devices, you can define the device in your toolchain compiler preprocessor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined (USE_HAL_DRIVER)
|
#if !defined(USE_HAL_DRIVER)
|
||||||
/**
|
/**
|
||||||
* @brief Comment the line below if you will not use the peripherals drivers.
|
* @brief Comment the line below if you will not use the peripherals drivers.
|
||||||
In this case, these drivers will not be included and the application code will
|
In this case, these drivers will not be included and the application code will
|
||||||
be based on direct access to peripherals registers
|
be based on direct access to peripherals registers
|
||||||
*/
|
*/
|
||||||
/*#define USE_HAL_DRIVER */
|
/*#define USE_HAL_DRIVER */
|
||||||
#endif /* USE_HAL_DRIVER */
|
#endif /* USE_HAL_DRIVER */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CMSIS Device version number V4.3.2
|
* @brief CMSIS Device version number V4.3.2
|
||||||
*/
|
*/
|
||||||
#define __STM32F1_CMSIS_VERSION_MAIN (0x04) /*!< [31:24] main version */
|
#define __STM32F1_CMSIS_VERSION_MAIN (0x04) /*!< [31:24] main version */
|
||||||
#define __STM32F1_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
|
#define __STM32F1_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
|
||||||
#define __STM32F1_CMSIS_VERSION_SUB2 (0x02) /*!< [15:8] sub2 version */
|
#define __STM32F1_CMSIS_VERSION_SUB2 (0x02) /*!< [15:8] sub2 version */
|
||||||
#define __STM32F1_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
#define __STM32F1_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||||
#define __STM32F1_CMSIS_VERSION ((__STM32F1_CMSIS_VERSION_MAIN << 24)\
|
#define __STM32F1_CMSIS_VERSION ((__STM32F1_CMSIS_VERSION_MAIN << 24) | (__STM32F1_CMSIS_VERSION_SUB1 << 16) | (__STM32F1_CMSIS_VERSION_SUB2 << 8) | (__STM32F1_CMSIS_VERSION_RC))
|
||||||
|(__STM32F1_CMSIS_VERSION_SUB1 << 16)\
|
|
||||||
|(__STM32F1_CMSIS_VERSION_SUB2 << 8 )\
|
|
||||||
|(__STM32F1_CMSIS_VERSION_RC))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup Device_Included
|
/** @addtogroup Device_Included
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(STM32F100xB)
|
#if defined(STM32F100xB)
|
||||||
#include "stm32f100xb.h"
|
#include "stm32f100xb.h"
|
||||||
#elif defined(STM32F100xE)
|
#elif defined(STM32F100xE)
|
||||||
#include "stm32f100xe.h"
|
#include "stm32f100xe.h"
|
||||||
#elif defined(STM32F101x6)
|
#elif defined(STM32F101x6)
|
||||||
#include "stm32f101x6.h"
|
#include "stm32f101x6.h"
|
||||||
#elif defined(STM32F101xB)
|
#elif defined(STM32F101xB)
|
||||||
#include "stm32f101xb.h"
|
#include "stm32f101xb.h"
|
||||||
#elif defined(STM32F101xE)
|
#elif defined(STM32F101xE)
|
||||||
#include "stm32f101xe.h"
|
#include "stm32f101xe.h"
|
||||||
#elif defined(STM32F101xG)
|
#elif defined(STM32F101xG)
|
||||||
#include "stm32f101xg.h"
|
#include "stm32f101xg.h"
|
||||||
#elif defined(STM32F102x6)
|
#elif defined(STM32F102x6)
|
||||||
#include "stm32f102x6.h"
|
#include "stm32f102x6.h"
|
||||||
#elif defined(STM32F102xB)
|
#elif defined(STM32F102xB)
|
||||||
#include "stm32f102xb.h"
|
#include "stm32f102xb.h"
|
||||||
#elif defined(STM32F103x6)
|
#elif defined(STM32F103x6)
|
||||||
#include "stm32f103x6.h"
|
#include "stm32f103x6.h"
|
||||||
#elif defined(STM32F103xB)
|
#elif defined(STM32F103xB)
|
||||||
#include "stm32f103xb.h"
|
#include "stm32f103xb.h"
|
||||||
#elif defined(STM32F103xE)
|
#elif defined(STM32F103xE)
|
||||||
#include "stm32f103xe.h"
|
#include "stm32f103xe.h"
|
||||||
#elif defined(STM32F103xG)
|
#elif defined(STM32F103xG)
|
||||||
#include "stm32f103xg.h"
|
#include "stm32f103xg.h"
|
||||||
#elif defined(STM32F105xC)
|
#elif defined(STM32F105xC)
|
||||||
#include "stm32f105xc.h"
|
#include "stm32f105xc.h"
|
||||||
#elif defined(STM32F107xC)
|
#elif defined(STM32F107xC)
|
||||||
#include "stm32f107xc.h"
|
#include "stm32f107xc.h"
|
||||||
#else
|
#else
|
||||||
#error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"
|
#error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup Exported_types
|
/** @addtogroup Exported_types
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus;
|
||||||
{
|
|
||||||
RESET = 0,
|
|
||||||
SET = !RESET
|
|
||||||
} FlagStatus, ITStatus;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum { DISABLE = 0, ENABLE = !DISABLE } FunctionalState;
|
||||||
{
|
|
||||||
DISABLE = 0,
|
|
||||||
ENABLE = !DISABLE
|
|
||||||
} FunctionalState;
|
|
||||||
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
|
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
|
||||||
|
|
||||||
typedef enum
|
typedef enum { SUCCESS = 0U, ERROR = !SUCCESS } ErrorStatus;
|
||||||
{
|
|
||||||
SUCCESS = 0U,
|
|
||||||
ERROR = !SUCCESS
|
|
||||||
} ErrorStatus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @addtogroup Exported_macros
|
/** @addtogroup Exported_macros
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
|
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
|
||||||
|
|
||||||
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
|
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
|
||||||
|
|
||||||
#define READ_BIT(REG, BIT) ((REG) & (BIT))
|
#define READ_BIT(REG, BIT) ((REG) & (BIT))
|
||||||
|
|
||||||
#define CLEAR_REG(REG) ((REG) = (0x0))
|
#define CLEAR_REG(REG) ((REG) = (0x0))
|
||||||
|
|
||||||
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
|
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
|
||||||
|
|
||||||
#define READ_REG(REG) ((REG))
|
#define READ_REG(REG) ((REG))
|
||||||
|
|
||||||
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
|
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
|
||||||
|
|
||||||
#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
|
|
||||||
|
|
||||||
|
#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined (USE_HAL_DRIVER)
|
#if defined(USE_HAL_DRIVER)
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#endif /* USE_HAL_DRIVER */
|
#endif /* USE_HAL_DRIVER */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif /* __STM32F1xx_H */
|
#endif /* __STM32F1xx_H */
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
|||||||
@@ -1,86 +1,85 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @file system_stm32f10x.h
|
* @file system_stm32f10x.h
|
||||||
* @author MCD Application Team
|
* @author MCD Application Team
|
||||||
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
|
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
* @attention
|
||||||
*
|
*
|
||||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||||
* All rights reserved.</center></h2>
|
* All rights reserved.</center></h2>
|
||||||
*
|
*
|
||||||
* This software component is licensed by ST under BSD 3-Clause license,
|
* This software component is licensed by ST under BSD 3-Clause license,
|
||||||
* the "License"; You may not use this file except in compliance with the
|
* the "License"; You may not use this file except in compliance with the
|
||||||
* License. You may obtain a copy of the License at:
|
* License. You may obtain a copy of the License at:
|
||||||
* opensource.org/licenses/BSD-3-Clause
|
* opensource.org/licenses/BSD-3-Clause
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup CMSIS
|
/** @addtogroup CMSIS
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup stm32f10x_system
|
/** @addtogroup stm32f10x_system
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Define to prevent recursive inclusion
|
* @brief Define to prevent recursive inclusion
|
||||||
*/
|
*/
|
||||||
#ifndef __SYSTEM_STM32F10X_H
|
#ifndef __SYSTEM_STM32F10X_H
|
||||||
#define __SYSTEM_STM32F10X_H
|
#define __SYSTEM_STM32F10X_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @addtogroup STM32F10x_System_Includes
|
/** @addtogroup STM32F10x_System_Includes
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @addtogroup STM32F10x_System_Exported_types
|
/** @addtogroup STM32F10x_System_Exported_types
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||||
extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */
|
extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */
|
||||||
extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */
|
extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup STM32F10x_System_Exported_Constants
|
/** @addtogroup STM32F10x_System_Exported_Constants
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup STM32F10x_System_Exported_Macros
|
/** @addtogroup STM32F10x_System_Exported_Macros
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup STM32F10x_System_Exported_Functions
|
/** @addtogroup STM32F10x_System_Exported_Functions
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern void SystemInit(void);
|
extern void SystemInit(void);
|
||||||
extern void SystemCoreClockUpdate(void);
|
extern void SystemCoreClockUpdate(void);
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
@@ -89,10 +88,10 @@ extern void SystemCoreClockUpdate(void);
|
|||||||
#endif /*__SYSTEM_STM32F10X_H */
|
#endif /*__SYSTEM_STM32F10X_H */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
|||||||
/**************************************************************************//**
|
/**************************************************************************/ /**
|
||||||
* @file cmsis_compiler.h
|
* @file cmsis_compiler.h
|
||||||
* @brief CMSIS compiler generic header file
|
* @brief CMSIS compiler generic header file
|
||||||
* @version V5.0.4
|
* @version V5.0.4
|
||||||
* @date 10. January 2018
|
* @date 10. January 2018
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -30,237 +30,234 @@
|
|||||||
/*
|
/*
|
||||||
* Arm Compiler 4/5
|
* Arm Compiler 4/5
|
||||||
*/
|
*/
|
||||||
#if defined ( __CC_ARM )
|
#if defined(__CC_ARM)
|
||||||
#include "cmsis_armcc.h"
|
#include "cmsis_armcc.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Arm Compiler 6 (armclang)
|
* Arm Compiler 6 (armclang)
|
||||||
*/
|
*/
|
||||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
#include "cmsis_armclang.h"
|
#include "cmsis_armclang.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GNU Compiler
|
* GNU Compiler
|
||||||
*/
|
*/
|
||||||
#elif defined ( __GNUC__ )
|
#elif defined(__GNUC__)
|
||||||
#include "cmsis_gcc.h"
|
#include "cmsis_gcc.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IAR Compiler
|
* IAR Compiler
|
||||||
*/
|
*/
|
||||||
#elif defined ( __ICCARM__ )
|
#elif defined(__ICCARM__)
|
||||||
#include <cmsis_iccarm.h>
|
#include <cmsis_iccarm.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TI Arm Compiler
|
* TI Arm Compiler
|
||||||
*/
|
*/
|
||||||
#elif defined ( __TI_ARM__ )
|
#elif defined(__TI_ARM__)
|
||||||
#include <cmsis_ccs.h>
|
#include <cmsis_ccs.h>
|
||||||
|
|
||||||
#ifndef __ASM
|
|
||||||
#define __ASM __asm
|
|
||||||
#endif
|
|
||||||
#ifndef __INLINE
|
|
||||||
#define __INLINE inline
|
|
||||||
#endif
|
|
||||||
#ifndef __STATIC_INLINE
|
|
||||||
#define __STATIC_INLINE static inline
|
|
||||||
#endif
|
|
||||||
#ifndef __STATIC_FORCEINLINE
|
|
||||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
|
||||||
#endif
|
|
||||||
#ifndef __NO_RETURN
|
|
||||||
#define __NO_RETURN __attribute__((noreturn))
|
|
||||||
#endif
|
|
||||||
#ifndef __USED
|
|
||||||
#define __USED __attribute__((used))
|
|
||||||
#endif
|
|
||||||
#ifndef __WEAK
|
|
||||||
#define __WEAK __attribute__((weak))
|
|
||||||
#endif
|
|
||||||
#ifndef __PACKED
|
|
||||||
#define __PACKED __attribute__((packed))
|
|
||||||
#endif
|
|
||||||
#ifndef __PACKED_STRUCT
|
|
||||||
#define __PACKED_STRUCT struct __attribute__((packed))
|
|
||||||
#endif
|
|
||||||
#ifndef __PACKED_UNION
|
|
||||||
#define __PACKED_UNION union __attribute__((packed))
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
|
||||||
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
|
|
||||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT16_WRITE
|
|
||||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
|
||||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT16_READ
|
|
||||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
|
||||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT32_WRITE
|
|
||||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
|
||||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT32_READ
|
|
||||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
|
||||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
|
||||||
#endif
|
|
||||||
#ifndef __ALIGNED
|
|
||||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
|
||||||
#endif
|
|
||||||
#ifndef __RESTRICT
|
|
||||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
|
||||||
#define __RESTRICT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifndef __ASM
|
||||||
|
#define __ASM __asm
|
||||||
|
#endif
|
||||||
|
#ifndef __INLINE
|
||||||
|
#define __INLINE inline
|
||||||
|
#endif
|
||||||
|
#ifndef __STATIC_INLINE
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
#endif
|
||||||
|
#ifndef __STATIC_FORCEINLINE
|
||||||
|
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||||
|
#endif
|
||||||
|
#ifndef __NO_RETURN
|
||||||
|
#define __NO_RETURN __attribute__((noreturn))
|
||||||
|
#endif
|
||||||
|
#ifndef __USED
|
||||||
|
#define __USED __attribute__((used))
|
||||||
|
#endif
|
||||||
|
#ifndef __WEAK
|
||||||
|
#define __WEAK __attribute__((weak))
|
||||||
|
#endif
|
||||||
|
#ifndef __PACKED
|
||||||
|
#define __PACKED __attribute__((packed))
|
||||||
|
#endif
|
||||||
|
#ifndef __PACKED_STRUCT
|
||||||
|
#define __PACKED_STRUCT struct __attribute__((packed))
|
||||||
|
#endif
|
||||||
|
#ifndef __PACKED_UNION
|
||||||
|
#define __PACKED_UNION union __attribute__((packed))
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||||
|
struct __attribute__((packed)) T_UINT32 {
|
||||||
|
uint32_t v;
|
||||||
|
};
|
||||||
|
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT16_WRITE
|
||||||
|
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||||
|
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT16_READ
|
||||||
|
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||||
|
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT32_WRITE
|
||||||
|
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||||
|
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT32_READ
|
||||||
|
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||||
|
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||||
|
#endif
|
||||||
|
#ifndef __ALIGNED
|
||||||
|
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||||
|
#endif
|
||||||
|
#ifndef __RESTRICT
|
||||||
|
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||||
|
#define __RESTRICT
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TASKING Compiler
|
* TASKING Compiler
|
||||||
*/
|
*/
|
||||||
#elif defined ( __TASKING__ )
|
#elif defined(__TASKING__)
|
||||||
/*
|
/*
|
||||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||||
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||||
* Including the CMSIS ones.
|
* Including the CMSIS ones.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ASM
|
|
||||||
#define __ASM __asm
|
|
||||||
#endif
|
|
||||||
#ifndef __INLINE
|
|
||||||
#define __INLINE inline
|
|
||||||
#endif
|
|
||||||
#ifndef __STATIC_INLINE
|
|
||||||
#define __STATIC_INLINE static inline
|
|
||||||
#endif
|
|
||||||
#ifndef __STATIC_FORCEINLINE
|
|
||||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
|
||||||
#endif
|
|
||||||
#ifndef __NO_RETURN
|
|
||||||
#define __NO_RETURN __attribute__((noreturn))
|
|
||||||
#endif
|
|
||||||
#ifndef __USED
|
|
||||||
#define __USED __attribute__((used))
|
|
||||||
#endif
|
|
||||||
#ifndef __WEAK
|
|
||||||
#define __WEAK __attribute__((weak))
|
|
||||||
#endif
|
|
||||||
#ifndef __PACKED
|
|
||||||
#define __PACKED __packed__
|
|
||||||
#endif
|
|
||||||
#ifndef __PACKED_STRUCT
|
|
||||||
#define __PACKED_STRUCT struct __packed__
|
|
||||||
#endif
|
|
||||||
#ifndef __PACKED_UNION
|
|
||||||
#define __PACKED_UNION union __packed__
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
|
||||||
struct __packed__ T_UINT32 { uint32_t v; };
|
|
||||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT16_WRITE
|
|
||||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
|
||||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT16_READ
|
|
||||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
|
||||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT32_WRITE
|
|
||||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
|
||||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
|
||||||
#endif
|
|
||||||
#ifndef __UNALIGNED_UINT32_READ
|
|
||||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
|
||||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
|
||||||
#endif
|
|
||||||
#ifndef __ALIGNED
|
|
||||||
#define __ALIGNED(x) __align(x)
|
|
||||||
#endif
|
|
||||||
#ifndef __RESTRICT
|
|
||||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
|
||||||
#define __RESTRICT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifndef __ASM
|
||||||
|
#define __ASM __asm
|
||||||
|
#endif
|
||||||
|
#ifndef __INLINE
|
||||||
|
#define __INLINE inline
|
||||||
|
#endif
|
||||||
|
#ifndef __STATIC_INLINE
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
#endif
|
||||||
|
#ifndef __STATIC_FORCEINLINE
|
||||||
|
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||||
|
#endif
|
||||||
|
#ifndef __NO_RETURN
|
||||||
|
#define __NO_RETURN __attribute__((noreturn))
|
||||||
|
#endif
|
||||||
|
#ifndef __USED
|
||||||
|
#define __USED __attribute__((used))
|
||||||
|
#endif
|
||||||
|
#ifndef __WEAK
|
||||||
|
#define __WEAK __attribute__((weak))
|
||||||
|
#endif
|
||||||
|
#ifndef __PACKED
|
||||||
|
#define __PACKED __packed__
|
||||||
|
#endif
|
||||||
|
#ifndef __PACKED_STRUCT
|
||||||
|
#define __PACKED_STRUCT struct __packed__
|
||||||
|
#endif
|
||||||
|
#ifndef __PACKED_UNION
|
||||||
|
#define __PACKED_UNION union __packed__
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||||
|
struct __packed__ T_UINT32 {
|
||||||
|
uint32_t v;
|
||||||
|
};
|
||||||
|
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT16_WRITE
|
||||||
|
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||||
|
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT16_READ
|
||||||
|
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||||
|
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT32_WRITE
|
||||||
|
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||||
|
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||||
|
#endif
|
||||||
|
#ifndef __UNALIGNED_UINT32_READ
|
||||||
|
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||||
|
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||||
|
#endif
|
||||||
|
#ifndef __ALIGNED
|
||||||
|
#define __ALIGNED(x) __align(x)
|
||||||
|
#endif
|
||||||
|
#ifndef __RESTRICT
|
||||||
|
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||||
|
#define __RESTRICT
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COSMIC Compiler
|
* COSMIC Compiler
|
||||||
*/
|
*/
|
||||||
#elif defined ( __CSMC__ )
|
#elif defined(__CSMC__)
|
||||||
#include <cmsis_csm.h>
|
#include <cmsis_csm.h>
|
||||||
|
|
||||||
#ifndef __ASM
|
#ifndef __ASM
|
||||||
#define __ASM _asm
|
#define __ASM _asm
|
||||||
#endif
|
#endif
|
||||||
#ifndef __INLINE
|
#ifndef __INLINE
|
||||||
#define __INLINE inline
|
#define __INLINE inline
|
||||||
#endif
|
#endif
|
||||||
#ifndef __STATIC_INLINE
|
#ifndef __STATIC_INLINE
|
||||||
#define __STATIC_INLINE static inline
|
#define __STATIC_INLINE static inline
|
||||||
#endif
|
#endif
|
||||||
#ifndef __STATIC_FORCEINLINE
|
#ifndef __STATIC_FORCEINLINE
|
||||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||||
#endif
|
#endif
|
||||||
#ifndef __NO_RETURN
|
#ifndef __NO_RETURN
|
||||||
// NO RETURN is automatically detected hence no warning here
|
// NO RETURN is automatically detected hence no warning here
|
||||||
#define __NO_RETURN
|
#define __NO_RETURN
|
||||||
#endif
|
#endif
|
||||||
#ifndef __USED
|
#ifndef __USED
|
||||||
#warning No compiler specific solution for __USED. __USED is ignored.
|
#warning No compiler specific solution for __USED. __USED is ignored.
|
||||||
#define __USED
|
#define __USED
|
||||||
#endif
|
#endif
|
||||||
#ifndef __WEAK
|
#ifndef __WEAK
|
||||||
#define __WEAK __weak
|
#define __WEAK __weak
|
||||||
#endif
|
#endif
|
||||||
#ifndef __PACKED
|
#ifndef __PACKED
|
||||||
#define __PACKED @packed
|
#define __PACKED @packed
|
||||||
#endif
|
#endif
|
||||||
#ifndef __PACKED_STRUCT
|
#ifndef __PACKED_STRUCT
|
||||||
#define __PACKED_STRUCT @packed struct
|
#define __PACKED_STRUCT @packed struct
|
||||||
#endif
|
#endif
|
||||||
#ifndef __PACKED_UNION
|
#ifndef __PACKED_UNION
|
||||||
#define __PACKED_UNION @packed union
|
#define __PACKED_UNION @packed union
|
||||||
#endif
|
#endif
|
||||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||||
@packed struct T_UINT32 { uint32_t v; };
|
@packed struct T_UINT32 {
|
||||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
uint32_t v;
|
||||||
#endif
|
};
|
||||||
#ifndef __UNALIGNED_UINT16_WRITE
|
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
#endif
|
||||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
#ifndef __UNALIGNED_UINT16_WRITE
|
||||||
#endif
|
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||||
#ifndef __UNALIGNED_UINT16_READ
|
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
#endif
|
||||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
#ifndef __UNALIGNED_UINT16_READ
|
||||||
#endif
|
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||||
#ifndef __UNALIGNED_UINT32_WRITE
|
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
#endif
|
||||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
#ifndef __UNALIGNED_UINT32_WRITE
|
||||||
#endif
|
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||||
#ifndef __UNALIGNED_UINT32_READ
|
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
#endif
|
||||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
#ifndef __UNALIGNED_UINT32_READ
|
||||||
#endif
|
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||||
#ifndef __ALIGNED
|
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||||
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
|
#endif
|
||||||
#define __ALIGNED(x)
|
#ifndef __ALIGNED
|
||||||
#endif
|
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
|
||||||
#ifndef __RESTRICT
|
#define __ALIGNED(x)
|
||||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
#endif
|
||||||
#define __RESTRICT
|
#ifndef __RESTRICT
|
||||||
#endif
|
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||||
|
#define __RESTRICT
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler.
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error Unknown compiler.
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __CMSIS_COMPILER_H */
|
#endif /* __CMSIS_COMPILER_H */
|
||||||
|
|
||||||
|
|||||||
1453
source/Core/BSP/MHP30/Vendor/CMSIS/Include/cmsis_gcc.h
vendored
1453
source/Core/BSP/MHP30/Vendor/CMSIS/Include/cmsis_gcc.h
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
|||||||
/**************************************************************************//**
|
/**************************************************************************/ /**
|
||||||
* @file cmsis_version.h
|
* @file cmsis_version.h
|
||||||
* @brief CMSIS Core(M) Version definitions
|
* @brief CMSIS Core(M) Version definitions
|
||||||
* @version V5.0.2
|
* @version V5.0.2
|
||||||
* @date 19. April 2017
|
* @date 19. April 2017
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -22,18 +22,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined ( __ICCARM__ )
|
#if defined(__ICCARM__)
|
||||||
#pragma system_include /* treat file as system include file for MISRA check */
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
#elif defined (__clang__)
|
#elif defined(__clang__)
|
||||||
#pragma clang system_header /* treat file as system include file */
|
#pragma clang system_header /* treat file as system include file */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CMSIS_VERSION_H
|
#ifndef __CMSIS_VERSION_H
|
||||||
#define __CMSIS_VERSION_H
|
#define __CMSIS_VERSION_H
|
||||||
|
|
||||||
/* CMSIS Version definitions */
|
/* CMSIS Version definitions */
|
||||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
#define __CM_CMSIS_VERSION_MAIN (5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||||
#define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
|
#define __CM_CMSIS_VERSION_SUB (1U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | __CM_CMSIS_VERSION_SUB) /*!< CMSIS Core(M) version number */
|
||||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
1856
source/Core/BSP/MHP30/Vendor/CMSIS/Include/core_cm3.h
vendored
1856
source/Core/BSP/MHP30/Vendor/CMSIS/Include/core_cm3.h
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1836
source/Core/BSP/MHP30/Vendor/CMSIS/Include/core_sc300.h
vendored
1836
source/Core/BSP/MHP30/Vendor/CMSIS/Include/core_sc300.h
vendored
File diff suppressed because it is too large
Load Diff
@@ -22,49 +22,49 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined ( __ICCARM__ )
|
#if defined(__ICCARM__)
|
||||||
#pragma system_include /* treat file as system include file for MISRA check */
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
#elif defined (__clang__)
|
#elif defined(__clang__)
|
||||||
#pragma clang system_header /* treat file as system include file */
|
#pragma clang system_header /* treat file as system include file */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TZ_CONTEXT_H
|
#ifndef TZ_CONTEXT_H
|
||||||
#define TZ_CONTEXT_H
|
#define TZ_CONTEXT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef TZ_MODULEID_T
|
#ifndef TZ_MODULEID_T
|
||||||
#define TZ_MODULEID_T
|
#define TZ_MODULEID_T
|
||||||
/// \details Data type that identifies secure software modules called by a process.
|
/// \details Data type that identifies secure software modules called by a process.
|
||||||
typedef uint32_t TZ_ModuleId_t;
|
typedef uint32_t TZ_ModuleId_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// \details TZ Memory ID identifies an allocated memory slot.
|
/// \details TZ Memory ID identifies an allocated memory slot.
|
||||||
typedef uint32_t TZ_MemoryId_t;
|
typedef uint32_t TZ_MemoryId_t;
|
||||||
|
|
||||||
/// Initialize secure context memory system
|
/// Initialize secure context memory system
|
||||||
/// \return execution status (1: success, 0: error)
|
/// \return execution status (1: success, 0: error)
|
||||||
uint32_t TZ_InitContextSystem_S (void);
|
uint32_t TZ_InitContextSystem_S(void);
|
||||||
|
|
||||||
/// Allocate context memory for calling secure software modules in TrustZone
|
/// Allocate context memory for calling secure software modules in TrustZone
|
||||||
/// \param[in] module identifies software modules called from non-secure mode
|
/// \param[in] module identifies software modules called from non-secure mode
|
||||||
/// \return value != 0 id TrustZone memory slot identifier
|
/// \return value != 0 id TrustZone memory slot identifier
|
||||||
/// \return value 0 no memory available or internal error
|
/// \return value 0 no memory available or internal error
|
||||||
TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
|
TZ_MemoryId_t TZ_AllocModuleContext_S(TZ_ModuleId_t module);
|
||||||
|
|
||||||
/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
|
/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
|
||||||
/// \param[in] id TrustZone memory slot identifier
|
/// \param[in] id TrustZone memory slot identifier
|
||||||
/// \return execution status (1: success, 0: error)
|
/// \return execution status (1: success, 0: error)
|
||||||
uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
|
uint32_t TZ_FreeModuleContext_S(TZ_MemoryId_t id);
|
||||||
|
|
||||||
/// Load secure context (called on RTOS thread context switch)
|
/// Load secure context (called on RTOS thread context switch)
|
||||||
/// \param[in] id TrustZone memory slot identifier
|
/// \param[in] id TrustZone memory slot identifier
|
||||||
/// \return execution status (1: success, 0: error)
|
/// \return execution status (1: success, 0: error)
|
||||||
uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
|
uint32_t TZ_LoadContext_S(TZ_MemoryId_t id);
|
||||||
|
|
||||||
/// Store secure context (called on RTOS thread context switch)
|
/// Store secure context (called on RTOS thread context switch)
|
||||||
/// \param[in] id TrustZone memory slot identifier
|
/// \param[in] id TrustZone memory slot identifier
|
||||||
/// \return execution status (1: success, 0: error)
|
/// \return execution status (1: success, 0: error)
|
||||||
uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
|
uint32_t TZ_StoreContext_S(TZ_MemoryId_t id);
|
||||||
|
|
||||||
#endif // TZ_CONTEXT_H
|
#endif // TZ_CONTEXT_H
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ typedef enum { HAL_TICK_FREQ_10HZ = 100U, HAL_TICK_FREQ_100HZ = 10U, HAL_TICK_FR
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
extern volatile uint32_t uwTick;
|
extern volatile uint32_t uwTick;
|
||||||
extern uint32_t uwTickPrio;
|
extern uint32_t uwTickPrio;
|
||||||
extern HAL_TickFreqTypeDef uwTickFreq;
|
extern HAL_TickFreqTypeDef uwTickFreq;
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ typedef struct {
|
|||||||
* ADC can be either disabled or enabled without conversion on going on regular group.
|
* ADC can be either disabled or enabled without conversion on going on regular group.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
|
uint32_t
|
||||||
|
Channel; /*!< Specifies the channel to configure into ADC regular group.
|
||||||
This parameter can be a value of @ref ADC_channels
|
This parameter can be a value of @ref ADC_channels
|
||||||
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
|
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
|
||||||
Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
|
Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ extern "C" {
|
|||||||
* - For all except parameters 'ExternalTrigInjecConv': ADC enabled without conversion on going on injected group.
|
* - For all except parameters 'ExternalTrigInjecConv': ADC enabled without conversion on going on injected group.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t
|
uint32_t InjectedChannel; /*!< Selection of ADC channel to configure
|
||||||
InjectedChannel; /*!< Selection of ADC channel to configure
|
|
||||||
This parameter can be a value of @ref ADC_channels
|
This parameter can be a value of @ref ADC_channels
|
||||||
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
|
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
|
||||||
Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
|
Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
|
||||||
Note: On STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch may be generated (on ADC input 0) on the PA0 pin, when the ADC is converting with injection
|
Note: On STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch may be generated (on ADC input 0) on the PA0 pin, when the ADC is converting with
|
||||||
trigger. It is advised to distribute the analog channels so that Channel 0 is configured as an injected channel. Refer to errata sheet of these devices for more details. */
|
injection trigger. It is advised to distribute the analog channels so that Channel 0 is configured as an injected channel. Refer to errata
|
||||||
|
sheet of these devices for more details. */
|
||||||
uint32_t InjectedRank; /*!< Rank in the injected group sequencer
|
uint32_t InjectedRank; /*!< Rank in the injected group sequencer
|
||||||
This parameter must be a value of @ref ADCEx_injected_rank
|
This parameter must be a value of @ref ADCEx_injected_rank
|
||||||
Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel
|
Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel
|
||||||
|
|||||||
@@ -11,6 +11,4 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
// Initialisation to be performed with scheduler active
|
// Initialisation to be performed with scheduler active
|
||||||
void postRToSInit() {
|
void postRToSInit() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) {
|
|||||||
|
|
||||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base) {
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base) {
|
||||||
|
|
||||||
if (htim_base->Instance == TIM3) {
|
if (htim_base->Instance == TIM3) {
|
||||||
__HAL_RCC_TIM3_CLK_ENABLE();
|
__HAL_RCC_TIM3_CLK_ENABLE();
|
||||||
} else if (htim_base->Instance == TIM2) {
|
} else if (htim_base->Instance == TIM2) {
|
||||||
__HAL_RCC_TIM2_CLK_ENABLE();
|
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void DMA1_Channel1_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_adc1); }
|
|||||||
// ADC interrupt used for DMA
|
// ADC interrupt used for DMA
|
||||||
void ADC1_2_IRQHandler(void) { HAL_ADC_IRQHandler(&hadc1); }
|
void ADC1_2_IRQHandler(void) { HAL_ADC_IRQHandler(&hadc1); }
|
||||||
|
|
||||||
//used for hal ticks
|
// used for hal ticks
|
||||||
void TIM4_IRQHandler(void) { HAL_TIM_IRQHandler(&htim4); }
|
void TIM4_IRQHandler(void) { HAL_TIM_IRQHandler(&htim4); }
|
||||||
void I2C1_EV_IRQHandler(void) { HAL_I2C_EV_IRQHandler(&hi2c1); }
|
void I2C1_EV_IRQHandler(void) { HAL_I2C_EV_IRQHandler(&hi2c1); }
|
||||||
void I2C1_ER_IRQHandler(void) { HAL_I2C_ER_IRQHandler(&hi2c1); }
|
void I2C1_ER_IRQHandler(void) { HAL_I2C_ER_IRQHandler(&hi2c1); }
|
||||||
|
|||||||
@@ -5,106 +5,103 @@
|
|||||||
* Author: Ralim
|
* Author: Ralim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <WS2812.h>
|
|
||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
|
#include <WS2812.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
uint8_t WS2812::leds_colors[WS2812_LED_CHANNEL_COUNT * WS2812_LED_COUNT];
|
uint8_t WS2812::leds_colors[WS2812_LED_CHANNEL_COUNT * WS2812_LED_COUNT];
|
||||||
|
|
||||||
void WS2812::init(void) {
|
void WS2812::init(void) { memset(leds_colors, 0, sizeof(leds_colors)); }
|
||||||
memset(leds_colors, 0, sizeof(leds_colors));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812::led_update() {
|
void WS2812::led_update() {
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
//Bitbang it out as our cpu irq latency is too high
|
// Bitbang it out as our cpu irq latency is too high
|
||||||
for (unsigned int i = 0; i < sizeof(leds_colors); i++) {
|
for (unsigned int i = 0; i < sizeof(leds_colors); i++) {
|
||||||
//Shove out MSB first
|
// Shove out MSB first
|
||||||
for (int x = 0; x < 8; x++) {
|
for (int x = 0; x < 8; x++) {
|
||||||
WS2812_GPIO_Port->BSRR = WS2812_Pin;
|
WS2812_GPIO_Port->BSRR = WS2812_Pin;
|
||||||
if ((leds_colors[i] & (1 << (7 - x))) == (1 << (7 - x))) {
|
if ((leds_colors[i] & (1 << (7 - x))) == (1 << (7 - x))) {
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
}
|
}
|
||||||
WS2812_GPIO_Port->BSRR = (uint32_t) WS2812_Pin << 16u;
|
WS2812_GPIO_Port->BSRR = (uint32_t)WS2812_Pin << 16u;
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
__asm__ __volatile__("nop");
|
__asm__ __volatile__("nop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812::led_set_color(size_t index, uint8_t r, uint8_t g, uint8_t b) {
|
void WS2812::led_set_color(size_t index, uint8_t r, uint8_t g, uint8_t b) {
|
||||||
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 0] = g;
|
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 0] = g;
|
||||||
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 1] = r;
|
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 1] = r;
|
||||||
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 2] = b;
|
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 2] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812::led_set_color_all(uint8_t r, uint8_t g, uint8_t b) {
|
void WS2812::led_set_color_all(uint8_t r, uint8_t g, uint8_t b) {
|
||||||
for (int index = 0; index < WS2812_LED_COUNT; index++) {
|
for (int index = 0; index < WS2812_LED_COUNT; index++) {
|
||||||
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 0] = g;
|
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 0] = g;
|
||||||
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 1] = r;
|
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 1] = r;
|
||||||
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 2] = b;
|
leds_colors[index * WS2812_LED_CHANNEL_COUNT + 2] = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,13 @@
|
|||||||
#define WS2812_RAW_BYTES_PER_LED (WS2812_LED_CHANNEL_COUNT * 8)
|
#define WS2812_RAW_BYTES_PER_LED (WS2812_LED_CHANNEL_COUNT * 8)
|
||||||
class WS2812 {
|
class WS2812 {
|
||||||
public:
|
public:
|
||||||
static void init(void);
|
static void init(void);
|
||||||
static void led_update();
|
static void led_update();
|
||||||
static void led_set_color(size_t index, uint8_t r, uint8_t g, uint8_t b);
|
static void led_set_color(size_t index, uint8_t r, uint8_t g, uint8_t b);
|
||||||
static void led_set_color_all(uint8_t r, uint8_t g, uint8_t b);
|
static void led_set_color_all(uint8_t r, uint8_t g, uint8_t b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static uint8_t leds_colors[WS2812_LED_CHANNEL_COUNT * WS2812_LED_COUNT];
|
||||||
static uint8_t leds_colors[WS2812_LED_CHANNEL_COUNT * WS2812_LED_COUNT];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CORE_DRIVERS_WS2812_H_ */
|
#endif /* CORE_DRIVERS_WS2812_H_ */
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user