Cleanup model selection
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include "BSP_Power.h"
|
#include "BSP_Power.h"
|
||||||
#include "BSP_QC.h"
|
#include "BSP_QC.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
#include "UnitSettings.h"
|
#include "Model_Config.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
/*
|
/*
|
||||||
* BSP.h -- Board Support
|
* BSP.h -- Board Support
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
|
#include "Model_Config.h"
|
||||||
#include "I2C_Wrapper.hpp"
|
#include "I2C_Wrapper.hpp"
|
||||||
volatile uint16_t PWMSafetyTimer = 0;
|
volatile uint16_t PWMSafetyTimer = 0;
|
||||||
volatile uint8_t pendingPWM = 0;
|
volatile uint8_t pendingPWM = 0;
|
||||||
@@ -16,7 +17,7 @@ history<uint16_t, PID_TIM_HZ> rawTempFilter = { { 0 }, 0, 0 };
|
|||||||
void resetWatchdog() {
|
void resetWatchdog() {
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
}
|
}
|
||||||
#ifdef MODEL_TS80P
|
#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[] = {
|
||||||
@@ -85,7 +86,7 @@ static const uint16_t NTCHandleLookup[] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
uint16_t getHandleTemperature() {
|
uint16_t getHandleTemperature() {
|
||||||
#ifdef MODEL_TS80P
|
#ifdef TEMP_NTC
|
||||||
//TS80P uses 100k NTC resistors instead
|
//TS80P uses 100k NTC resistors instead
|
||||||
//NTCG104EF104FT1X from TDK
|
//NTCG104EF104FT1X from TDK
|
||||||
//For now not doing interpolation
|
//For now not doing interpolation
|
||||||
@@ -97,7 +98,8 @@ uint16_t getHandleTemperature() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#endif
|
||||||
|
#ifdef TEMP_TMP36
|
||||||
// We return the current handle temperature in X10 C
|
// We return the current handle temperature in X10 C
|
||||||
// TMP36 in handle, 0.5V offset and then 10mV per deg C (0.75V @ 25C for
|
// TMP36 in handle, 0.5V offset and then 10mV per deg C (0.75V @ 25C for
|
||||||
// example) STM32 = 4096 count @ 3.3V input -> But We oversample by 32/(2^2) =
|
// example) STM32 = 4096 count @ 3.3V input -> But We oversample by 32/(2^2) =
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BSP_PD.h"
|
#include "BSP_PD.h"
|
||||||
|
#include "Model_Config.h"
|
||||||
|
#ifdef POW_PD
|
||||||
/*
|
/*
|
||||||
* An array of all of the desired voltages & minimum currents in preferred order
|
* An array of all of the desired voltages & minimum currents in preferred order
|
||||||
*/
|
*/
|
||||||
@@ -18,3 +19,4 @@ const uint16_t USB_PD_Desired_Levels[] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
const uint8_t USB_PD_Desired_Levels_Len = 3;
|
const uint8_t USB_PD_Desired_Levels_Len = 3;
|
||||||
|
#endif
|
||||||
|
|||||||
44
workspace/TS100/Core/BSP/Miniware/Model_Config.h
Normal file
44
workspace/TS100/Core/BSP/Miniware/Model_Config.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Model_Config.h
|
||||||
|
*
|
||||||
|
* Created on: 25 Jul 2020
|
||||||
|
* Author: Ralim
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BSP_MINIWARE_MODEL_CONFIG_H_
|
||||||
|
#define BSP_MINIWARE_MODEL_CONFIG_H_
|
||||||
|
/*
|
||||||
|
* Lookup for mapping features <-> Models
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(MODEL_TS100) + defined(MODEL_TS80)+defined(MODEL_TS80P) > 1
|
||||||
|
#error "Multiple models defined!"
|
||||||
|
#elif defined(MODEL_TS100) + defined(MODEL_TS80)+ defined(MODEL_TS80P) == 0
|
||||||
|
#error "No model defined!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS100
|
||||||
|
#define ACCEL_MMA
|
||||||
|
#define ACCEL_LIS
|
||||||
|
#define TEMP_TMP36
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS80
|
||||||
|
#define ACCEL_LIS
|
||||||
|
#define POW_QC
|
||||||
|
#define TEMP_TMP36
|
||||||
|
#define LIS_ORI_FLIP
|
||||||
|
#define OLED_FLIP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS80P
|
||||||
|
#define ACCEL_LIS
|
||||||
|
#define POW_PD
|
||||||
|
#define POW_QC
|
||||||
|
#define TEMP_NTC
|
||||||
|
#define I2C_SOFT
|
||||||
|
#define LIS_ORI_FLIP
|
||||||
|
#define OLED_FLIP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* BSP_MINIWARE_MODEL_CONFIG_H_ */
|
||||||
@@ -7,12 +7,7 @@
|
|||||||
|
|
||||||
#ifndef BSP_MINIWARE_PINS_H_
|
#ifndef BSP_MINIWARE_PINS_H_
|
||||||
#define BSP_MINIWARE_PINS_H_
|
#define BSP_MINIWARE_PINS_H_
|
||||||
|
#include "Model_Config.h"
|
||||||
#if defined(MODEL_TS100) + defined(MODEL_TS80)+defined(MODEL_TS80P) > 1
|
|
||||||
#error "Multiple models defined!"
|
|
||||||
#elif defined(MODEL_TS100) + defined(MODEL_TS80)+ defined(MODEL_TS80P) == 0
|
|
||||||
#error "No model defined!"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,13 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "fusbpd.h"
|
#include "fusbpd.h"
|
||||||
|
#include "Model_Config.h"
|
||||||
#include "int_n.h"
|
#include "int_n.h"
|
||||||
bool FUSB302_present = false;
|
bool FUSB302_present = false;
|
||||||
void power_probe() {
|
void power_probe() {
|
||||||
// If TS80 probe for QC
|
// If TS80(p) probe for QC
|
||||||
// If TS100 - noop
|
// If TS100 - noop
|
||||||
#if defined(MODEL_TS80)+defined(MODEL_TS80P)>0
|
#ifdef POW_QC
|
||||||
|
|
||||||
startQC(systemSettings.voltageDiv);
|
startQC(systemSettings.voltageDiv);
|
||||||
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
||||||
@@ -19,12 +20,12 @@ void power_probe() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void power_check() {
|
void power_check() {
|
||||||
#if defined(MODEL_TS80)+defined(MODEL_TS80P)>0
|
#ifdef POW_QC
|
||||||
QC_resync();
|
QC_resync();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
uint8_t usb_pd_detect() {
|
uint8_t usb_pd_detect() {
|
||||||
#ifdef MODEL_TS80P
|
#ifdef POW_PD
|
||||||
FUSB302_present = fusb302_detect();
|
FUSB302_present = fusb302_detect();
|
||||||
|
|
||||||
return FUSB302_present;
|
return FUSB302_present;
|
||||||
@@ -32,7 +33,7 @@ uint8_t usb_pd_detect() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t pd_irq_read() {
|
uint8_t pd_irq_read() {
|
||||||
#ifdef MODEL_TS80P
|
#ifdef POW_PD
|
||||||
return HAL_GPIO_ReadPin(INT_PD_GPIO_Port, INT_PD_Pin) == GPIO_PIN_SET ?
|
return HAL_GPIO_ReadPin(INT_PD_GPIO_Port, INT_PD_Pin) == GPIO_PIN_SET ?
|
||||||
1 : 0;
|
1 : 0;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "QC3.h"
|
#include "QC3.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
|
#include "Model_Config.h"
|
||||||
|
#ifdef POW_QC
|
||||||
void QC_DPlusZero_Six() {
|
void QC_DPlusZero_Six() {
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); // pull down D+
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); // pull down D+
|
||||||
}
|
}
|
||||||
@@ -65,9 +67,9 @@ void QC_Post_Probe_En() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET ? 1 : 0; }
|
uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET ? 1 : 0; }
|
||||||
|
#endif
|
||||||
void QC_resync() {
|
void QC_resync() {
|
||||||
#if defined(MODEL_TS80) + defined(MODEL_TS80P) >0
|
#ifdef POW_QC
|
||||||
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
||||||
systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
|
systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
27
workspace/TS100/Core/BSP/Miniware/Software_I2C.h
Normal file
27
workspace/TS100/Core/BSP/Miniware/Software_I2C.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Software_I2C.h
|
||||||
|
*
|
||||||
|
* Created on: 25 Jul 2020
|
||||||
|
* Author: Ralim
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BSP_MINIWARE_SOFTWARE_I2C_H_
|
||||||
|
#define BSP_MINIWARE_SOFTWARE_I2C_H_
|
||||||
|
#include "Model_Config.h"
|
||||||
|
#include "BSP.h"
|
||||||
|
#include "stm32f1xx_hal.h"
|
||||||
|
#ifdef I2C_SOFT
|
||||||
|
|
||||||
|
#define SOFT_SCL_HIGH() HAL_GPIO_WritePin(SCL2_GPIO_Port, SCL2_Pin, GPIO_PIN_SET)
|
||||||
|
#define SOFT_SCL_LOW() HAL_GPIO_WritePin(SCL2_GPIO_Port, SCL2_Pin, GPIO_PIN_RESET)
|
||||||
|
#define SOFT_SDA_HIGH() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_SET)
|
||||||
|
#define SOFT_SDA_LOW() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_RESET)
|
||||||
|
#define SOFT_SDA_READ() (HAL_GPIO_ReadPin(SDA2_GPIO_Port,SDA2_Pin)==GPIO_PIN_SET?1:0)
|
||||||
|
#define SOFT_SCL_READ() (HAL_GPIO_ReadPin(SCL2_GPIO_Port,SCL2_Pin)==GPIO_PIN_SET?1:0)
|
||||||
|
#define SOFT_I2C_DELAY() {for(int xx=0;xx<100;xx++){asm("nop");}}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* BSP_MINIWARE_SOFTWARE_I2C_H_ */
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* UnitSettings.h
|
|
||||||
*
|
|
||||||
* Created on: 29 May 2020
|
|
||||||
* Author: Ralim
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BSP_MINIWARE_UNITSETTINGS_H_
|
|
||||||
#define BSP_MINIWARE_UNITSETTINGS_H_
|
|
||||||
//On the TS80, the LIS accel is mounted backwards
|
|
||||||
#if defined(MODEL_TS80)+defined(MODEL_TS80P)>0
|
|
||||||
#define LIS_ORI_FLIP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* BSP_MINIWARE_UNITSETTINGS_H_ */
|
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#include "Model_Config.h"
|
||||||
|
#ifdef POW_PD
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "fusb302b.h"
|
#include "fusb302b.h"
|
||||||
#include "I2CBB.hpp"
|
#include "I2CBB.hpp"
|
||||||
@@ -272,3 +274,9 @@ bool fusb_read_id() {
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
uint8_t fusb302_detect() {
|
||||||
|
//Probe the I2C bus for its address
|
||||||
|
return I2CBB::probe(FUSB302B_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "I2CBB.hpp"
|
#include "I2CBB.hpp"
|
||||||
#include "fusbpd.h"
|
#include "fusbpd.h"
|
||||||
|
#include "Model_Config.h"
|
||||||
void preRToSInit() {
|
void preRToSInit() {
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
||||||
*/
|
*/
|
||||||
@@ -20,8 +21,11 @@ void preRToSInit() {
|
|||||||
HAL_Delay(50);
|
HAL_Delay(50);
|
||||||
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
|
||||||
HAL_Delay(50);
|
HAL_Delay(50);
|
||||||
#ifdef MODEL_TS80P
|
#ifdef I2C_SOFT
|
||||||
I2CBB::init();
|
I2CBB::init();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef POW_PD
|
||||||
//Spawn all of the USB-C processors
|
//Spawn all of the USB-C processors
|
||||||
fusb302_start_processing();
|
fusb302_start_processing();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
* Created on: 13 Jun 2020
|
* Created on: 13 Jun 2020
|
||||||
* Author: Ralim
|
* Author: Ralim
|
||||||
*/
|
*/
|
||||||
|
#include "Model_Config.h"
|
||||||
#ifdef MODEL_TS80P
|
#ifdef POW_PD
|
||||||
#include <fusbpd.h>
|
#include <fusbpd.h>
|
||||||
#include <pd.h>
|
#include <pd.h>
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
@@ -17,10 +17,7 @@
|
|||||||
#include "int_n.h"
|
#include "int_n.h"
|
||||||
#include "hard_reset.h"
|
#include "hard_reset.h"
|
||||||
|
|
||||||
uint8_t fusb302_detect() {
|
|
||||||
//Probe the I2C bus for its address
|
|
||||||
return I2CBB::probe(FUSB302B_ADDR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void fusb302_start_processing() {
|
void fusb302_start_processing() {
|
||||||
/* Initialize the FUSB302B */
|
/* Initialize the FUSB302B */
|
||||||
|
|||||||
@@ -4,17 +4,10 @@
|
|||||||
* Created on: 12 Jun 2020
|
* Created on: 12 Jun 2020
|
||||||
* Author: Ralim
|
* Author: Ralim
|
||||||
*/
|
*/
|
||||||
|
#include "Model_Config.h"
|
||||||
#ifdef MODEL_TS80P
|
#ifdef I2C_SOFT
|
||||||
#include <I2CBB.hpp>
|
#include <I2CBB.hpp>
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#define SCL_HIGH() HAL_GPIO_WritePin(SCL2_GPIO_Port, SCL2_Pin, GPIO_PIN_SET)
|
|
||||||
#define SCL_LOW() HAL_GPIO_WritePin(SCL2_GPIO_Port, SCL2_Pin, GPIO_PIN_RESET)
|
|
||||||
#define SDA_HIGH() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_SET)
|
|
||||||
#define SDA_LOW() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_RESET)
|
|
||||||
#define SDA_READ() (HAL_GPIO_ReadPin(SDA2_GPIO_Port,SDA2_Pin)==GPIO_PIN_SET?1:0)
|
|
||||||
#define SCL_READ() (HAL_GPIO_ReadPin(SCL2_GPIO_Port,SCL2_Pin)==GPIO_PIN_SET?1:0)
|
|
||||||
#define I2C_DELAY() {for(int xx=0;xx<100;xx++){asm("nop");}}
|
|
||||||
SemaphoreHandle_t I2CBB::I2CSemaphore = NULL;
|
SemaphoreHandle_t I2CBB::I2CSemaphore = NULL;
|
||||||
StaticSemaphore_t I2CBB::xSemaphoreBuffer;
|
StaticSemaphore_t I2CBB::xSemaphoreBuffer;
|
||||||
SemaphoreHandle_t I2CBB::I2CSemaphore2 = NULL;
|
SemaphoreHandle_t I2CBB::I2CSemaphore2 = NULL;
|
||||||
@@ -28,8 +21,8 @@ void I2CBB::init() {
|
|||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
HAL_GPIO_Init(SDA2_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(SDA2_GPIO_Port, &GPIO_InitStruct);
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
SCL_HIGH();
|
SOFT_SCL_HIGH();
|
||||||
I2CSemaphore = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer);
|
I2CSemaphore = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer);
|
||||||
I2CSemaphore2 = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer2);
|
I2CSemaphore2 = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer2);
|
||||||
unlock();
|
unlock();
|
||||||
@@ -66,8 +59,8 @@ bool I2CBB::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData,
|
|||||||
unlock();
|
unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SCL_LOW();
|
SOFT_SCL_LOW();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
// stop();
|
// stop();
|
||||||
start();
|
start();
|
||||||
ack = send(DevAddress | 1);
|
ack = send(DevAddress | 1);
|
||||||
@@ -107,7 +100,7 @@ bool I2CBB::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
|||||||
}
|
}
|
||||||
while (Size) {
|
while (Size) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
bool ack = send(pData[0]);
|
ack = send(pData[0]);
|
||||||
if (!ack) {
|
if (!ack) {
|
||||||
stop();
|
stop();
|
||||||
asm("bkpt");
|
asm("bkpt");
|
||||||
@@ -133,7 +126,7 @@ void I2CBB::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (Size) {
|
while (Size) {
|
||||||
bool ack = send(pData[0]);
|
ack = send(pData[0]);
|
||||||
if (!ack) {
|
if (!ack) {
|
||||||
stop();
|
stop();
|
||||||
unlock();
|
unlock();
|
||||||
@@ -181,7 +174,7 @@ void I2CBB::TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (Size_tx) {
|
while (Size_tx) {
|
||||||
bool ack = send(pData_tx[0]);
|
ack = send(pData_tx[0]);
|
||||||
if (!ack) {
|
if (!ack) {
|
||||||
stop();
|
stop();
|
||||||
unlock();
|
unlock();
|
||||||
@@ -211,24 +204,24 @@ void I2CBB::TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx,
|
|||||||
|
|
||||||
void I2CBB::start() {
|
void I2CBB::start() {
|
||||||
/* I2C Start condition, data line goes low when clock is high */
|
/* I2C Start condition, data line goes low when clock is high */
|
||||||
SCL_HIGH();
|
SOFT_SCL_HIGH();
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SDA_LOW();
|
SOFT_SDA_LOW();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SCL_LOW();
|
SOFT_SCL_LOW();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CBB::stop() {
|
void I2CBB::stop() {
|
||||||
/* I2C Stop condition, clock goes high when data is low */
|
/* I2C Stop condition, clock goes high when data is low */
|
||||||
SDA_LOW();
|
SOFT_SDA_LOW();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SCL_HIGH();
|
SOFT_SCL_HIGH();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool I2CBB::send(uint8_t value) {
|
bool I2CBB::send(uint8_t value) {
|
||||||
@@ -238,7 +231,7 @@ bool I2CBB::send(uint8_t value) {
|
|||||||
value <<= 1;
|
value <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
bool ack = (read_bit() == 0);
|
bool ack = (read_bit() == 0);
|
||||||
return ack;
|
return ack;
|
||||||
}
|
}
|
||||||
@@ -252,7 +245,7 @@ uint8_t I2CBB::read(bool ack) {
|
|||||||
B |= read_bit();
|
B |= read_bit();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
if (ack)
|
if (ack)
|
||||||
write_bit(0);
|
write_bit(0);
|
||||||
else
|
else
|
||||||
@@ -263,17 +256,17 @@ uint8_t I2CBB::read(bool ack) {
|
|||||||
uint8_t I2CBB::read_bit() {
|
uint8_t I2CBB::read_bit() {
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
|
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SCL_HIGH();
|
SOFT_SCL_HIGH();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
|
|
||||||
if (SDA_READ())
|
if (SOFT_SDA_READ())
|
||||||
b = 1;
|
b = 1;
|
||||||
else
|
else
|
||||||
b = 0;
|
b = 0;
|
||||||
|
|
||||||
SCL_LOW();
|
SOFT_SCL_LOW();
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,15 +287,15 @@ bool I2CBB::lock() {
|
|||||||
|
|
||||||
void I2CBB::write_bit(uint8_t val) {
|
void I2CBB::write_bit(uint8_t val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
SDA_HIGH();
|
SOFT_SDA_HIGH();
|
||||||
} else {
|
} else {
|
||||||
SDA_LOW();
|
SOFT_SDA_LOW();
|
||||||
}
|
}
|
||||||
|
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SCL_HIGH();
|
SOFT_SCL_HIGH();
|
||||||
I2C_DELAY();
|
SOFT_I2C_DELAY();
|
||||||
SCL_LOW();
|
SOFT_SCL_LOW();
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CBB::unlock2() {
|
void I2CBB::unlock2() {
|
||||||
@@ -7,17 +7,15 @@
|
|||||||
|
|
||||||
#ifndef BSP_MINIWARE_I2CBB_HPP_
|
#ifndef BSP_MINIWARE_I2CBB_HPP_
|
||||||
#define BSP_MINIWARE_I2CBB_HPP_
|
#define BSP_MINIWARE_I2CBB_HPP_
|
||||||
#ifdef MODEL_TS80P
|
#include "Model_Config.h"
|
||||||
|
#ifdef I2C_SOFT
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
/*
|
#include "Software_I2C.h"
|
||||||
* Simple static I2C bit-bang class used on the TS80P
|
|
||||||
* SCL = PA5
|
|
||||||
* SDA = PA1
|
|
||||||
*/
|
|
||||||
class I2CBB {
|
class I2CBB {
|
||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
@@ -191,9 +191,9 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
|||||||
offset = progress;
|
offset = progress;
|
||||||
|
|
||||||
memmove(&firstStripPtr[oldStart], &firstStripPtr[oldPrevious],
|
memmove(&firstStripPtr[oldStart], &firstStripPtr[oldPrevious],
|
||||||
OLED_WIDTH - progress);
|
OLED_WIDTH - progress);
|
||||||
memmove(&secondStripPtr[oldStart], &secondStripPtr[oldPrevious],
|
memmove(&secondStripPtr[oldStart], &secondStripPtr[oldPrevious],
|
||||||
OLED_WIDTH - progress);
|
OLED_WIDTH - progress);
|
||||||
|
|
||||||
memmove(&firstStripPtr[newStart], &firstBackStripPtr[newEnd], progress);
|
memmove(&firstStripPtr[newStart], &firstBackStripPtr[newEnd], progress);
|
||||||
memmove(&secondStripPtr[newStart], &secondBackStripPtr[newEnd],
|
memmove(&secondStripPtr[newStart], &secondBackStripPtr[newEnd],
|
||||||
@@ -213,7 +213,7 @@ void OLED::useSecondaryFramebuffer(bool useSecondary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OLED::setRotation(bool leftHanded) {
|
void OLED::setRotation(bool leftHanded) {
|
||||||
#if defined( MODEL_TS80) +defined( MODEL_TS80P) > 0
|
#ifdef OLED_FLIP
|
||||||
leftHanded = !leftHanded;
|
leftHanded = !leftHanded;
|
||||||
#endif
|
#endif
|
||||||
if (inLeftHandedMode == leftHanded) {
|
if (inLeftHandedMode == leftHanded) {
|
||||||
|
|||||||
@@ -59,11 +59,13 @@ void gui_drawTipTemp(bool symbol) {
|
|||||||
// Draw tip temp handling unit conversion & tolerance near setpoint
|
// Draw tip temp handling unit conversion & tolerance near setpoint
|
||||||
uint16_t Temp = 0;
|
uint16_t Temp = 0;
|
||||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||||
if (systemSettings.temperatureInF)
|
if (systemSettings.temperatureInF){
|
||||||
Temp = TipThermoModel::getTipInF();
|
Temp = TipThermoModel::getTipInF();
|
||||||
else
|
}else
|
||||||
#endif
|
#endif
|
||||||
Temp = TipThermoModel::getTipInC();
|
{
|
||||||
|
Temp = TipThermoModel::getTipInC();
|
||||||
|
}
|
||||||
|
|
||||||
OLED::printNumber(Temp, 3); // Draw the tip temp out finally
|
OLED::printNumber(Temp, 3); // Draw the tip temp out finally
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
@@ -247,7 +249,7 @@ static void gui_solderingTempAdjust() {
|
|||||||
if (xTaskGetTickCount() - lastChange > 200)
|
if (xTaskGetTickCount() - lastChange > 200)
|
||||||
return; // exit if user just doesn't press anything for a bit
|
return; // exit if user just doesn't press anything for a bit
|
||||||
|
|
||||||
#if defined (MODEL_TS80P)+defined(MODEL_TS80)>0
|
#ifdef OLED_FLIP
|
||||||
if (!OLED::getRotation()) {
|
if (!OLED::getRotation()) {
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
@@ -272,7 +274,7 @@ static void gui_solderingTempAdjust() {
|
|||||||
OLED::drawSymbol(1);
|
OLED::drawSymbol(1);
|
||||||
}
|
}
|
||||||
OLED::print(SymbolSpace);
|
OLED::print(SymbolSpace);
|
||||||
#if defined (MODEL_TS80P)+defined(MODEL_TS80)>0
|
#ifdef OLED_FLIP
|
||||||
if (!OLED::getRotation()) {
|
if (!OLED::getRotation()) {
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
@@ -646,9 +648,10 @@ void startGUITask(void const *argument __unused) {
|
|||||||
{
|
{
|
||||||
//Generate the flipped screen into ram for later use
|
//Generate the flipped screen into ram for later use
|
||||||
//flipped is generated by flipping each row
|
//flipped is generated by flipping each row
|
||||||
for(int row=0;row<2;row++){
|
for (int row = 0; row < 2; row++) {
|
||||||
for (int x =0;x<84;x++){
|
for (int x = 0; x < 84; x++) {
|
||||||
idleScreenBGF[(row*84)+x] =idleScreenBG[(row*84)+(83-x)];
|
idleScreenBGF[(row * 84) + x] = idleScreenBG[(row * 84)
|
||||||
|
+ (83 - x)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -769,7 +772,7 @@ void startGUITask(void const *argument __unused) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
OLED::setFont(0);
|
OLED::setFont(0);
|
||||||
#if defined (MODEL_TS80P)+defined(MODEL_TS80)>0
|
#ifdef OLED_FLIP
|
||||||
if (!OLED::getRotation()) {
|
if (!OLED::getRotation()) {
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
@@ -790,7 +793,7 @@ void startGUITask(void const *argument __unused) {
|
|||||||
if (tempOnDisplay) {
|
if (tempOnDisplay) {
|
||||||
// draw temp over the start soldering button
|
// draw temp over the start soldering button
|
||||||
// Location changes on screen rotation
|
// Location changes on screen rotation
|
||||||
#if defined (MODEL_TS80P)+defined(MODEL_TS80)>0
|
#ifdef OLED_FLIP
|
||||||
if (!OLED::getRotation()) {
|
if (!OLED::getRotation()) {
|
||||||
#else
|
#else
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Model_Config.h"
|
||||||
/**
|
/**
|
||||||
* Configuration.h
|
* Configuration.h
|
||||||
* Define here your default pre settings for TS80 or TS100
|
* Define here your default pre settings for TS80 or TS100
|
||||||
|
|||||||
Reference in New Issue
Block a user