1
0
forked from me/IronOS

Split I2C + startup logo

This commit is contained in:
Ben V. Brown
2020-05-29 23:07:59 +10:00
parent d2dacf990c
commit a32e245789
6 changed files with 45 additions and 27 deletions

View File

@@ -41,6 +41,10 @@ void unstick_I2C();
//Reboot the IC when things go seriously wrong
void reboot();
//If the user has programmed in a bootup logo, draw it to the screen from flash
//Returns 1 if the logo was printed so that the unit waits for the timeout or button
uint8_t showBootLogoIfavailable();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,27 @@
/*
* logo.c
*
* Created on: 29 May 2020
* Author: Ralim
*/
#include "BSP.h"
#include "OLED.hpp"
// Second last page of flash set aside for logo image.
#define FLASH_LOGOADDR (0x8000000 | 0xF800)
// Logo header signature.
#define LOGO_HEADER_VALUE 0xF00DAA55
uint8_t showBootLogoIfavailable() {
// Do not show logo data if signature is not found.
if (LOGO_HEADER_VALUE
!= *(reinterpret_cast<const uint32_t*>(FLASH_LOGOADDR))) {
return 0;
}
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4));
OLED::refresh();
return 1;
}

View File

@@ -8,12 +8,15 @@
#include "BSP.h"
#include "Setup.h"
#include "Pins.h"
#include "FRTosI2C.hpp"
void preRToSInit() {
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
*/
HAL_Init();
Setup_HAL(); // Setup all the HAL objects
FRToSI2C::init(&hi2c1);
HAL_Delay(50);
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
HAL_Delay(50);
}

View File

@@ -10,6 +10,14 @@
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"
/*
* Wrapper class to work with the device I2C bus
*
* This provides mutex protection of the peripheral
* Also allows hardware to use DMA should it want to
*
*
*/
class FRToSI2C {
public:

View File

@@ -42,7 +42,7 @@ typedef struct {
uint8_t temperatureInF :1; // Should the temp be in F or C (true is F)
#endif
uint8_t descriptionScrollSpeed :1; // Description scroll speed
uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
uint16_t voltageDiv; // Voltage divisor factor
uint16_t BoostTemp; // Boost mode set point for the iron
@@ -51,7 +51,7 @@ typedef struct {
uint8_t powerLimitEnable; // Allow toggling of power limit without changing value
uint8_t powerLimit; // Maximum power iron allowed to output
uint16_t TipGain; // uV/C * 10, it can be used to convert tip thermocouple voltage to temperateture TipV/TipGain = TipTemp
uint8_t ReverseButtonTempChangeEnabled; // Change the plus and minus button assigment
@@ -70,5 +70,5 @@ void saveSettings();
bool restoreSettings();
uint8_t lookupVoltageLevel(uint8_t level);
void resetSettings();
bool showBootLogoIfavailable();
#endif /* SETTINGS_H_ */

View File

@@ -43,7 +43,6 @@ int main(void) {
preRToSInit();
setTipX10Watts(0); // force tip off
FRToSI2C::init(&hi2c1);
OLED::initialize(); // start up the LCD
OLED::setFont(0); // default to bigger font
// Testing for which accelerometer is mounted
@@ -86,28 +85,5 @@ int main(void) {
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
while (1) {
}
}
// Second last page of flash set aside for logo image.
#define FLASH_LOGOADDR (0x8000000 | 0xF800)
// Logo header signature.
#define LOGO_HEADER_VALUE 0xF00DAA55
bool showBootLogoIfavailable() {
// Do not show logo data if signature is not found.
if (LOGO_HEADER_VALUE
!= *(reinterpret_cast<const uint32_t*>(FLASH_LOGOADDR))) {
return false;
}
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4));
OLED::refresh();
return true;
}