Skip to content

Commit 16f7c68

Browse files
KooLruvirtual-maker
authored andcommitted
Cleanup code
1 parent 9b416c7 commit 16f7c68

File tree

1 file changed

+2
-107
lines changed

1 file changed

+2
-107
lines changed

hal/architecture/STM32/MyHwSTM32.cpp

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,8 @@ bool hwInit(void)
4141
while (!MY_SERIALDEVICE) {}
4242
#endif
4343
#endif
44-
//todo EEPROM initialisation????
45-
Serial1.print("EEPROM.length ");
46-
Serial1.println(EEPROM.length());
47-
48-
//if (EEPROM.init() == EEPROM_OK) {
49-
// uint16 cnt;
50-
// EEPROM.count(&cnt);
51-
// if(cnt>=EEPROM.maxcount()) {
52-
// // tmp, WIP: format eeprom if full
53-
// EEPROM.format();
54-
// }
44+
5545
return true;
56-
//}
57-
//return false;
5846
}
5947

6048
void hwReadConfigBlock(void *buf, void *addr, size_t length)
@@ -73,7 +61,6 @@ void hwWriteConfigBlock(void *buf, void *addr, size_t length)
7361
while (length-- > 0) {
7462
EEPROM.write(offs++, *src++);
7563
}
76-
// EEPROM.commit();
7764
}
7865

7966
uint8_t hwReadConfig(const int addr)
@@ -120,61 +107,6 @@ int8_t hwSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t inte
120107
}
121108

122109

123-
//void hwRandomNumberInit(void)
124-
//{
125-
// // This function initializes the random number generator with a seed
126-
// // of 32 bits. This method is good enough to earn FIPS 140-2 conform
127-
// // random data. This should reach to generate 32 Bit for randomSeed().
128-
// uint32_t seed = 0;
129-
// uint32_t timeout = millis() + 20;
130-
//
131-
// // Trigger floating effect of an unconnected pin
132-
// pinMode(MY_SIGNING_SOFT_RANDOMSEED_PIN, INPUT_PULLUP);
133-
// pinMode(MY_SIGNING_SOFT_RANDOMSEED_PIN, INPUT);
134-
// delay(10);
135-
//
136-
// // Generate 32 bits of datas
137-
// for (uint8_t i=0; i<32; i++) {
138-
// const int pinValue = analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN);
139-
// // Wait until the analog value has changed
140-
// while ((pinValue == analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN)) && (timeout>=millis())) {
141-
// seed ^= (millis() << i);
142-
// // Check of data generation is slow
143-
// if (timeout<=millis()) {
144-
// // Trigger pin again
145-
// pinMode(MY_SIGNING_SOFT_RANDOMSEED_PIN, INPUT_PULLUP);
146-
// pinMode(MY_SIGNING_SOFT_RANDOMSEED_PIN, INPUT);
147-
// // Pause a short while
148-
// delay(seed % 10);
149-
// timeout = millis() + 20;
150-
// }
151-
// }
152-
// }
153-
// randomSeed(seed);
154-
//
155-
//// // use internal temperature sensor as noise source
156-
//// adc_reg_map *regs = ADC1->regs;
157-
//// regs->CR2 |= ADC_CR2_TSVREFE;
158-
//// regs->SMPR1 |= ADC_SMPR1_SMP16;
159-
////
160-
//// uint32_t seed = 0;
161-
//// uint16_t currentValue = 0;
162-
//// uint16_t newValue = 0;
163-
////
164-
//// for (uint8_t i = 0; i < 32; i++) {
165-
//// const uint32_t timeout = hwMillis() + 20;
166-
//// while (timeout >= hwMillis()) {
167-
//// newValue = adc_read(ADC1, 16);
168-
//// if (newValue != currentValue) {
169-
//// currentValue = newValue;
170-
//// break;
171-
//// }
172-
//// }
173-
//// seed ^= ( (newValue + hwMillis()) & 7) << i;
174-
//// }
175-
//// randomSeed(seed);
176-
//// regs->CR2 &= ~ADC_CR2_TSVREFE; // disable VREFINT and temp sensor
177-
//}
178110

179111
bool hwUniqueID(unique_id_t *uniqueID)
180112
{
@@ -186,52 +118,16 @@ uint16_t hwCPUVoltage(void)
186118
{
187119
//Not yet implemented
188120
return FUNCTION_NOT_SUPPORTED;
189-
190-
//adc_reg_map *regs = ADC1->regs;
191-
//regs->CR2 |= ADC_CR2_TSVREFE; // enable VREFINT and temp sensor
192-
//regs->SMPR1 = ADC_SMPR1_SMP17; // sample rate for VREFINT ADC channel
193-
//adc_calibrate(ADC1);
194-
//
195-
//const uint16_t vdd = adc_read(ADC1, 17);
196-
//regs->CR2 &= ~ADC_CR2_TSVREFE; // disable VREFINT and temp sensor
197-
//return (uint16_t)(1200u * 4096u / vdd);
198121
}
199122

200123
uint16_t hwCPUFrequency(void)
201124
{
202125
return F_CPU/100000UL;
203126
}
204-
//https://github.com/stm32duino/Arduino_Core_STM32/issues/5#issuecomment-411868042
127+
205128
int8_t hwCPUTemperature(void)
206129
{
207-
//STM32ADC adc(ADC1);
208-
209-
//adc.begin(PB1);
210-
211-
// adc.startConversion();
212-
213-
//uint32_t v = adc.read();
214-
//uint32_t vcc = adc.measureVcc();
215-
//int16_t temp = adc.measureTemp();
216-
//printf("ADC: %lu, vcc: %lumV temp: %dC\n", v, vcc, temp);
217-
//delay(1000);
218-
219-
// return adc.measureTemp();
220-
221-
//adc_reg_map *regs = ADC1->regs;
222-
//regs->CR2 |= ADC_CR2_TSVREFE; // enable VREFINT and Temperature sensor
223-
//regs->SMPR1 |= ADC_SMPR1_SMP16 | ADC_SMPR1_SMP17;
224-
//adc_calibrate(ADC1);
225-
//
226-
////const uint16_t adc_temp = adc_read(ADC1, 16);
227-
////const uint16_t vref = 1200 * 4096 / adc_read(ADC1, 17);
228-
//// calibrated at 25°C, ADC output = 1430mV, avg slope = 4.3mV / °C, increasing temp ~ lower voltage
229-
//const int8_t temp = static_cast<int8_t>((1430.0 - (adc_read(ADC1, 16) * 1200 / adc_read(ADC1,
230-
// 17))) / 4.3 + 25.0);
231-
//regs->CR2 &= ~ADC_CR2_TSVREFE; // disable VREFINT and temp sensor
232-
//return (temp - MY_STM32F1_TEMPERATURE_OFFSET) / MY_STM32F1_TEMPERATURE_GAIN;
233130
return FUNCTION_NOT_SUPPORTED;
234-
235131
}
236132

237133
uint16_t hwFreeMem(void)
@@ -244,7 +140,6 @@ uint16_t hwFreeMem(void)
244140
void hwWatchdogReset(void)
245141
{
246142
IWatchdog.reload();
247-
//NRF_WDT->RR[0] = WDT_RR_RR_Reload;
248143
}
249144

250145
void hwReboot(void)

0 commit comments

Comments
 (0)