-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflash_stm32.c
More file actions
33 lines (28 loc) · 1.28 KB
/
flash_stm32.c
File metadata and controls
33 lines (28 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "stm32f0xx.h"
#include "flash_stm32.h"
//#include "usart_stm32_console.h"
//#include "oled_stm32_ssd1306.h"
// A self-reset feature of the electronic would be nice to allow the device to reboot after changing the maximum ampere setting in the flash.
void FLASH_STM32_setNewMaximumAmpere(uint8_t newValue) {
//OLED_STM32_clearDisplay();
FLASH_Unlock();
FLASH_Status eraseResponse = FLASH_ErasePage(MAXIMUM_AMPERE_ADDRESS);
if (eraseResponse != FLASH_COMPLETE) {
//USART_STM32_sendStringToUSART("DEBUG: Could not erase memory page from flash memory for MAXIMUM_AMPERE.");
//OLED_STM32_drawMonospaceString(0,0,"ERASE FAIL");
//OLED_STM32_updateDisplay();
}
FLASH_Status flashResponse = FLASH_ProgramWord(MAXIMUM_AMPERE_ADDRESS, newValue);
if (flashResponse != FLASH_COMPLETE) {
//USART_STM32_sendStringToUSART("DEBUG: Could not write new MAXIMUM_AMPERE value to flash memory.");
//OLED_STM32_drawMonospaceString(0,10,"FLASH FAIL");
//OLED_STM32_updateDisplay();
}
FLASH_Lock();
//USART_STM32_sendStringToUSART("A new MAXIMUM_AMPERE value has been flashed. Please restart the device to take effect.");
//OLED_STM32_drawMonospaceString(0,20,"FLASH SUCCESS");
//OLED_STM32_updateDisplay();
}
uint8_t FLASH_STM32_getMaximumAmpere(void) {
return (uint8_t)(*MAXIMUM_AMPERE_ADDRPTR);
}