Formatting pass
This commit is contained in:
@@ -14,9 +14,7 @@ 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
|
||||||
@@ -101,9 +99,7 @@ uint16_t getHandleTemperature() {
|
|||||||
return 250; // TODO
|
return 250; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -221,22 +217,11 @@ void unstick_I2C() {
|
|||||||
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) {}
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,30 +19,17 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
|
|||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
if (hadc == &hadc1) {
|
if (hadc == &hadc1) {
|
||||||
if (pidTaskNotification) {
|
if (pidTaskNotification) {
|
||||||
vTaskNotifyGiveFromISR(pidTaskNotification,
|
vTaskNotifyGiveFromISR(pidTaskNotification, &xHigherPriorityTaskWoken);
|
||||||
&xHigherPriorityTaskWoken);
|
|
||||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
|
||||||
FRToSI2C::CpltCallback();
|
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
|
||||||
}
|
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
|
||||||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
|
||||||
FRToSI2C::CpltCallback();
|
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
|
||||||
}
|
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) { FRToSI2C::CpltCallback(); }
|
||||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
|
||||||
FRToSI2C::CpltCallback();
|
|
||||||
}
|
|
||||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c __unused) {
|
|
||||||
FRToSI2C::CpltCallback();
|
|
||||||
}
|
|
||||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
|
||||||
FRToSI2C::CpltCallback();
|
|
||||||
}
|
|
||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
|
||||||
FRToSI2C::CpltCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
|
||||||
(void)GPIO_Pin;
|
(void)GPIO_Pin;
|
||||||
|
|||||||
@@ -45,5 +45,4 @@
|
|||||||
#define HEAT_EN_Pin GPIO_PIN_3
|
#define HEAT_EN_Pin GPIO_PIN_3
|
||||||
#define HEAT_EN_GPIO_Port GPIOA
|
#define HEAT_EN_GPIO_Port GPIOA
|
||||||
|
|
||||||
|
|
||||||
#endif /* BSP_MINIWARE_PINS_H_ */
|
#endif /* BSP_MINIWARE_PINS_H_ */
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ void SystemClock_Config(void) {
|
|||||||
|
|
||||||
/**Initializes the CPU, AHB and APB busses clocks
|
/**Initializes the CPU, AHB and APB busses clocks
|
||||||
*/
|
*/
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSI;
|
||||||
| RCC_OSCILLATORTYPE_LSI;
|
|
||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
RCC_OscInitStruct.HSICalibrationValue = 16;
|
RCC_OscInitStruct.HSICalibrationValue = 16;
|
||||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||||
@@ -84,8 +83,7 @@ void SystemClock_Config(void) {
|
|||||||
|
|
||||||
/**Initializes the CPU, AHB and APB busses clocks
|
/**Initializes the CPU, AHB and APB busses clocks
|
||||||
*/
|
*/
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||||
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV16; // TIM
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV16; // TIM
|
||||||
@@ -337,16 +335,11 @@ static void MX_GPIO_Init(void) {
|
|||||||
/*
|
/*
|
||||||
* Configure All pins as analog by default
|
* Configure All pins as analog by default
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3
|
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_15;
|
||||||
| GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8
|
|
||||||
| GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_15;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 |
|
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12
|
||||||
GPIO_PIN_3 |
|
| GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
|
||||||
GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9
|
|
||||||
| GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13
|
|
||||||
| GPIO_PIN_14 | GPIO_PIN_15;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : KEY_B_Pin KEY_A_Pin */
|
/*Configure GPIO pins : KEY_B_Pin KEY_A_Pin */
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
|||||||
pEraseInit.PageAddress = (uint32_t)settings_page;
|
pEraseInit.PageAddress = (uint32_t)settings_page;
|
||||||
uint32_t failingAddress = 0;
|
uint32_t failingAddress = 0;
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
__HAL_FLASH_CLEAR_FLAG(
|
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
||||||
FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
|
||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
HAL_Delay(1);
|
HAL_Delay(1);
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
@@ -34,8 +33,7 @@ uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
|||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
for (uint16_t i = 0; i < (length / 2); i++) {
|
for (uint16_t i = 0; i < (length / 2); i++) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,
|
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, (uint32_t)&settings_page[i], data[i]);
|
||||||
(uint32_t) &settings_page[i], data[i]);
|
|
||||||
}
|
}
|
||||||
HAL_FLASH_Lock();
|
HAL_FLASH_Lock();
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
#ifdef POW_PD
|
#ifdef POW_PD
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "I2C_Wrapper.hpp"
|
#include "I2C_Wrapper.hpp"
|
||||||
|
#include "Pins.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "fusb302b.h"
|
#include "fusb302b.h"
|
||||||
#include "fusb_user.h"
|
#include "fusb_user.h"
|
||||||
#include "Pins.h"
|
|
||||||
/*
|
/*
|
||||||
* Read a single byte from the FUSB302B
|
* Read a single byte from the FUSB302B
|
||||||
*
|
*
|
||||||
@@ -30,9 +30,7 @@ uint8_t fusb_read_byte(uint8_t addr) {
|
|||||||
* size: The number of bytes to read
|
* size: The number of bytes to read
|
||||||
* buf: The buffer into which data will be read
|
* buf: The buffer into which data will be read
|
||||||
*/
|
*/
|
||||||
bool fusb_read_buf(uint8_t addr, uint8_t size, uint8_t *buf) {
|
bool fusb_read_buf(uint8_t addr, uint8_t size, uint8_t *buf) { return FRToSI2C::Mem_Read(FUSB302B_ADDR, addr, buf, size); }
|
||||||
return FRToSI2C::Mem_Read(FUSB302B_ADDR, addr, buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write a single byte to the FUSB302B
|
* Write a single byte to the FUSB302B
|
||||||
@@ -41,9 +39,7 @@ bool fusb_read_buf(uint8_t addr, uint8_t size, uint8_t *buf) {
|
|||||||
* addr: The memory address to which we will write
|
* addr: The memory address to which we will write
|
||||||
* byte: The value to write
|
* byte: The value to write
|
||||||
*/
|
*/
|
||||||
bool fusb_write_byte(uint8_t addr, uint8_t byte) {
|
bool fusb_write_byte(uint8_t addr, uint8_t byte) { return FRToSI2C::Mem_Write(FUSB302B_ADDR, addr, (uint8_t *)&byte, 1); }
|
||||||
return FRToSI2C::Mem_Write(FUSB302B_ADDR, addr, (uint8_t*) &byte, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write multiple bytes to the FUSB302B
|
* Write multiple bytes to the FUSB302B
|
||||||
@@ -53,9 +49,7 @@ bool fusb_write_byte(uint8_t addr, uint8_t byte) {
|
|||||||
* size: The number of bytes to write
|
* size: The number of bytes to write
|
||||||
* buf: The buffer to write
|
* buf: The buffer to write
|
||||||
*/
|
*/
|
||||||
bool fusb_write_buf(uint8_t addr, uint8_t size, const uint8_t *buf) {
|
bool fusb_write_buf(uint8_t addr, uint8_t size, const uint8_t *buf) { return FRToSI2C::Mem_Write(FUSB302B_ADDR, addr, (uint8_t *)buf, size); }
|
||||||
return FRToSI2C::Mem_Write(FUSB302B_ADDR, addr, (uint8_t*)buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t fusb302_detect() {
|
uint8_t fusb302_detect() {
|
||||||
// Probe the I2C bus for its address
|
// Probe the I2C bus for its address
|
||||||
|
|||||||
@@ -1,42 +1,34 @@
|
|||||||
// This is the stock standard STM interrupt file full of handlers
|
// This is the stock standard STM interrupt file full of handlers
|
||||||
#include "stm32f1xx_it.h"
|
#include "stm32f1xx_it.h"
|
||||||
|
#include "Pins.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "stm32f1xx.h"
|
#include "stm32f1xx.h"
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#include "Pins.h"
|
|
||||||
extern TIM_HandleTypeDef htim1; // used for the systick
|
extern TIM_HandleTypeDef htim1; // used for the systick
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
void NMI_Handler(void) {
|
void NMI_Handler(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
// We have the assembly for a breakpoint trigger here to halt the system when a debugger is connected
|
// We have the assembly for a breakpoint trigger here to halt the system when a debugger is connected
|
||||||
// Hardfault handler, often a screwup in the code
|
// Hardfault handler, often a screwup in the code
|
||||||
void HardFault_Handler(void) {
|
void HardFault_Handler(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
// Memory management unit had an error
|
// Memory management unit had an error
|
||||||
void MemManage_Handler(void) {
|
void MemManage_Handler(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
// Prefetcher or busfault occured
|
// Prefetcher or busfault occured
|
||||||
void BusFault_Handler(void) {
|
void BusFault_Handler(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
void UsageFault_Handler(void) {
|
void UsageFault_Handler(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
void DebugMon_Handler(void) {
|
void DebugMon_Handler(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
// Systick is used by FreeRTOS tick
|
// Systick is used by FreeRTOS tick
|
||||||
void SysTick_Handler(void) {
|
void SysTick_Handler(void) { osSystickHandler(); }
|
||||||
osSystickHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* STM32F1xx Peripheral Interrupt Handlers */
|
/* STM32F1xx Peripheral Interrupt Handlers */
|
||||||
@@ -46,33 +38,17 @@ void SysTick_Handler(void) {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// DMA used to move the ADC readings into system ram
|
// DMA used to move the ADC readings into system ram
|
||||||
void DMA1_Channel1_IRQHandler(void) {
|
void DMA1_Channel1_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_adc1); }
|
||||||
HAL_DMA_IRQHandler(&hdma_adc1);
|
|
||||||
}
|
|
||||||
// ADC interrupt used for DMA
|
// ADC interrupt used for DMA
|
||||||
void ADC1_2_IRQHandler(void) {
|
void ADC1_2_IRQHandler(void) { HAL_ADC_IRQHandler(&hadc1); }
|
||||||
HAL_ADC_IRQHandler(&hadc1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timer 1 has overflowed, used for HAL ticks
|
// Timer 1 has overflowed, used for HAL ticks
|
||||||
void TIM1_UP_IRQHandler(void) {
|
void TIM1_UP_IRQHandler(void) { HAL_TIM_IRQHandler(&htim1); }
|
||||||
HAL_TIM_IRQHandler(&htim1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2C1_EV_IRQHandler(void) {
|
void I2C1_EV_IRQHandler(void) { HAL_I2C_EV_IRQHandler(&hi2c1); }
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DMA1_Channel6_IRQHandler(void) {
|
void DMA1_Channel6_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_tx); }
|
||||||
HAL_DMA_IRQHandler(&hdma_i2c1_tx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DMA1_Channel7_IRQHandler(void) {
|
void DMA1_Channel7_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_rx); }
|
||||||
HAL_DMA_IRQHandler(&hdma_i2c1_rx);
|
void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(INT_PD_Pin); }
|
||||||
}
|
|
||||||
void EXTI9_5_IRQHandler(void) {
|
|
||||||
HAL_GPIO_EXTI_IRQHandler(INT_PD_Pin);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ bool I2CBB::probe(uint8_t address) {
|
|||||||
return ack;
|
return ack;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool I2CBB::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData,
|
bool I2CBB::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t Size) {
|
||||||
uint16_t Size) {
|
|
||||||
if (!lock())
|
if (!lock())
|
||||||
return false;
|
return false;
|
||||||
start();
|
start();
|
||||||
@@ -77,8 +76,7 @@ bool I2CBB::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool I2CBB::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
bool I2CBB::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, const uint8_t *pData, uint16_t Size) {
|
||||||
const uint8_t *pData, uint16_t Size) {
|
|
||||||
if (!lock())
|
if (!lock())
|
||||||
return false;
|
return false;
|
||||||
start();
|
start();
|
||||||
@@ -156,8 +154,7 @@ void I2CBB::Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
|||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CBB::TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx,
|
void I2CBB::TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx, uint16_t Size_tx, uint8_t *pData_rx, uint16_t Size_rx) {
|
||||||
uint16_t Size_tx, uint8_t *pData_rx, uint16_t Size_rx) {
|
|
||||||
if (Size_tx == 0 && Size_rx == 0)
|
if (Size_tx == 0 && Size_rx == 0)
|
||||||
return;
|
return;
|
||||||
if (lock() == false)
|
if (lock() == false)
|
||||||
@@ -267,9 +264,7 @@ uint8_t I2CBB::read_bit() {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CBB::unlock() {
|
void I2CBB::unlock() { xSemaphoreGive(I2CSemaphore); }
|
||||||
xSemaphoreGive(I2CSemaphore);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool I2CBB::lock() {
|
bool I2CBB::lock() {
|
||||||
if (I2CSemaphore == NULL) {
|
if (I2CSemaphore == NULL) {
|
||||||
@@ -279,9 +274,7 @@ bool I2CBB::lock() {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool I2CBB::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) {
|
bool I2CBB::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) { return Mem_Write(address, reg, &data, 1); }
|
||||||
return Mem_Write(address, reg, &data, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t I2CBB::I2C_RegisterRead(uint8_t address, uint8_t reg) {
|
uint8_t I2CBB::I2C_RegisterRead(uint8_t address, uint8_t reg) {
|
||||||
uint8_t temp = 0;
|
uint8_t temp = 0;
|
||||||
@@ -302,11 +295,9 @@ void I2CBB::write_bit(uint8_t val) {
|
|||||||
SOFT_SCL_LOW();
|
SOFT_SCL_LOW();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool I2CBB::writeRegistersBulk(const uint8_t address, const I2C_REG *registers,
|
bool I2CBB::writeRegistersBulk(const uint8_t address, const I2C_REG *registers, const uint8_t registersLength) {
|
||||||
const uint8_t registersLength) {
|
|
||||||
for (int index = 0; index < registersLength; index++) {
|
for (int index = 0; index < registersLength; index++) {
|
||||||
if (!I2C_RegisterWrite(address, registers[index].reg,
|
if (!I2C_RegisterWrite(address, registers[index].reg, registers[index].val)) {
|
||||||
registers[index].val)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (registers[index].pause_ms)
|
if (registers[index].pause_ms)
|
||||||
|
|||||||
@@ -22,15 +22,12 @@ public:
|
|||||||
// Probe if device ACK's address or not
|
// Probe if device ACK's address or not
|
||||||
static bool probe(uint8_t address);
|
static bool probe(uint8_t address);
|
||||||
// Issues a complete 8bit register read
|
// Issues a complete 8bit register read
|
||||||
static bool Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
static bool Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t Size);
|
||||||
uint8_t *pData, uint16_t Size);
|
|
||||||
// Implements a register write
|
// Implements a register write
|
||||||
static bool Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
static bool Mem_Write(uint16_t DevAddress, uint16_t MemAddress, const uint8_t *pData, uint16_t Size);
|
||||||
const uint8_t *pData, uint16_t Size);
|
|
||||||
static void Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
static void Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||||
static void Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
static void Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||||
static void TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx,
|
static void TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx, uint16_t Size_tx, uint8_t *pData_rx, uint16_t Size_rx);
|
||||||
uint16_t Size_tx, uint8_t *pData_rx, uint16_t Size_rx);
|
|
||||||
static bool I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data);
|
static bool I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data);
|
||||||
static uint8_t I2C_RegisterRead(uint8_t address, uint8_t reg);
|
static uint8_t I2C_RegisterRead(uint8_t address, uint8_t reg);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -38,8 +35,8 @@ public:
|
|||||||
uint8_t val; // The value to write to this register
|
uint8_t val; // The value to write to this register
|
||||||
const uint8_t pause_ms; // How many ms to pause _after_ writing this reg
|
const uint8_t pause_ms; // How many ms to pause _after_ writing this reg
|
||||||
} I2C_REG;
|
} I2C_REG;
|
||||||
static bool writeRegistersBulk(const uint8_t address,
|
static bool writeRegistersBulk(const uint8_t address, const I2C_REG *registers, const uint8_t registersLength);
|
||||||
const I2C_REG *registers, const uint8_t registersLength);
|
|
||||||
private:
|
private:
|
||||||
static SemaphoreHandle_t I2CSemaphore;
|
static SemaphoreHandle_t I2CSemaphore;
|
||||||
static StaticSemaphore_t xSemaphoreBuffer;
|
static StaticSemaphore_t xSemaphoreBuffer;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
#ifndef OLED_HPP_
|
#ifndef OLED_HPP_
|
||||||
#define OLED_HPP_
|
#define OLED_HPP_
|
||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
#include <BSP.h>
|
|
||||||
#include "Model_Config.h"
|
#include "Model_Config.h"
|
||||||
|
#include <BSP.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -22,7 +22,6 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef OLED_I2CBB
|
#ifdef OLED_I2CBB
|
||||||
#include "I2CBB.hpp"
|
#include "I2CBB.hpp"
|
||||||
#define I2C_CLASS I2CBB
|
#define I2C_CLASS I2CBB
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "configuration.h"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include "power.hpp"
|
#include "power.hpp"
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -195,9 +195,7 @@ const uint32_t tipMass = 40;
|
|||||||
const uint8_t tipResistance = 45; // x10 ohms, 4.5 typical for ts80 tips
|
const uint8_t tipResistance = 45; // x10 ohms, 4.5 typical for ts80 tips
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODEL_MHP30
|
#ifdef MODEL_MHP30
|
||||||
const uint32_t tipMass = 80; // TODO
|
const uint32_t tipMass = 80; // TODO
|
||||||
const uint8_t tipResistance = 65; // x10 ohms, 6 typical
|
const uint8_t tipResistance = 65; // x10 ohms, 6 typical
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user