mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Better messages flowing
This commit is contained in:
@@ -8,9 +8,9 @@
|
|||||||
#ifndef BSP_MINIWARE_PINS_H_
|
#ifndef BSP_MINIWARE_PINS_H_
|
||||||
#define BSP_MINIWARE_PINS_H_
|
#define BSP_MINIWARE_PINS_H_
|
||||||
|
|
||||||
#if defined(MODEL_TS100) + defined(MODEL_TS80) > 1
|
#if defined(MODEL_TS100) + defined(MODEL_TS80)+defined(MODEL_TS80P) > 1
|
||||||
#error "Multiple models defined!"
|
#error "Multiple models defined!"
|
||||||
#elif defined(MODEL_TS100) + defined(MODEL_TS80) == 0
|
#elif defined(MODEL_TS100) + defined(MODEL_TS80)+ defined(MODEL_TS80P) == 0
|
||||||
#error "No model defined!"
|
#error "No model defined!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
#define SCL_GPIO_Port GPIOB
|
#define SCL_GPIO_Port GPIOB
|
||||||
#define SDA_Pin GPIO_PIN_7
|
#define SDA_Pin GPIO_PIN_7
|
||||||
#define SDA_GPIO_Port GPIOB
|
#define SDA_GPIO_Port GPIOB
|
||||||
|
#endif
|
||||||
#else
|
#ifdef MODEL_TS80
|
||||||
// TS80 pin map
|
// TS80 pin map
|
||||||
#define KEY_B_Pin GPIO_PIN_0
|
#define KEY_B_Pin GPIO_PIN_0
|
||||||
#define KEY_B_GPIO_Port GPIOB
|
#define KEY_B_GPIO_Port GPIOB
|
||||||
@@ -84,6 +84,45 @@
|
|||||||
#define INT_PD_Pin GPIO_PIN_9
|
#define INT_PD_Pin GPIO_PIN_9
|
||||||
#define INT_PD_GPIO_Port GPIOA
|
#define INT_PD_GPIO_Port GPIOA
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef MODEL_TS80P
|
||||||
|
// TS80P pin map
|
||||||
|
#define KEY_B_Pin GPIO_PIN_0
|
||||||
|
#define KEY_B_GPIO_Port GPIOB
|
||||||
|
#define TMP36_INPUT_Pin GPIO_PIN_4
|
||||||
|
#define TMP36_INPUT_GPIO_Port GPIOA
|
||||||
|
#define TMP36_ADC1_CHANNEL ADC_CHANNEL_4
|
||||||
|
#define TIP_TEMP_Pin GPIO_PIN_3
|
||||||
|
#define TIP_TEMP_GPIO_Port GPIOA
|
||||||
|
#define TIP_TEMP_ADC1_CHANNEL ADC_CHANNEL_3
|
||||||
|
#define TIP_TEMP_ADC2_CHANNEL ADC_CHANNEL_3
|
||||||
|
|
||||||
|
#define VIN_Pin GPIO_PIN_2
|
||||||
|
#define VIN_GPIO_Port GPIOA
|
||||||
|
#define VIN_ADC1_CHANNEL ADC_CHANNEL_2
|
||||||
|
#define VIN_ADC2_CHANNEL ADC_CHANNEL_2
|
||||||
|
#define OLED_RESET_Pin GPIO_PIN_15
|
||||||
|
#define OLED_RESET_GPIO_Port GPIOA
|
||||||
|
#define KEY_A_Pin GPIO_PIN_1
|
||||||
|
#define KEY_A_GPIO_Port GPIOB
|
||||||
|
#define INT_Orientation_Pin GPIO_PIN_4
|
||||||
|
#define INT_Orientation_GPIO_Port GPIOB
|
||||||
|
#define PWM_Out_Pin GPIO_PIN_6
|
||||||
|
#define PWM_Out_GPIO_Port GPIOA
|
||||||
|
#define PWM_Out_CHANNEL TIM_CHANNEL_1
|
||||||
|
#define INT_Movement_Pin GPIO_PIN_5
|
||||||
|
#define INT_Movement_GPIO_Port GPIOB
|
||||||
|
#define SCL_Pin GPIO_PIN_6
|
||||||
|
#define SCL_GPIO_Port GPIOB
|
||||||
|
#define SDA_Pin GPIO_PIN_7
|
||||||
|
#define SDA_GPIO_Port GPIOB
|
||||||
|
#define SCL2_Pin GPIO_PIN_5
|
||||||
|
#define SCL2_GPIO_Port GPIOA
|
||||||
|
#define SDA2_Pin GPIO_PIN_1
|
||||||
|
#define SDA2_GPIO_Port GPIOA
|
||||||
|
#define INT_PD_Pin GPIO_PIN_9
|
||||||
|
#define INT_PD_GPIO_Port GPIOA
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* BSP_MINIWARE_PINS_H_ */
|
#endif /* BSP_MINIWARE_PINS_H_ */
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ bool FUSB302_present = false;
|
|||||||
void power_probe() {
|
void power_probe() {
|
||||||
// If TS80 probe for QC
|
// If TS80 probe for QC
|
||||||
// If TS100 - noop
|
// If TS100 - noop
|
||||||
#ifdef MODEL_TS80
|
#ifdef defined(MODEL_TS80)+defined(MODEL_TS80P)>0
|
||||||
|
|
||||||
startQC(systemSettings.voltageDiv);
|
startQC(systemSettings.voltageDiv);
|
||||||
|
|
||||||
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
||||||
systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
|
systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
|
||||||
|
|
||||||
@@ -19,12 +18,12 @@ void power_probe() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void power_check() {
|
void power_check() {
|
||||||
#ifdef MODEL_TS80
|
#ifdef defined(MODEL_TS80)+defined(MODEL_TS80P)>0
|
||||||
QC_resync();
|
QC_resync();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
uint8_t usb_pd_detect() {
|
uint8_t usb_pd_detect() {
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80P
|
||||||
FUSB302_present = fusb302_detect();
|
FUSB302_present = fusb302_detect();
|
||||||
if (FUSB302_present) {
|
if (FUSB302_present) {
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
@@ -39,9 +38,11 @@ uint8_t usb_pd_detect() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t pd_irq_read() {
|
uint8_t pd_irq_read() {
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80P
|
||||||
return HAL_GPIO_ReadPin(INT_PD_GPIO_Port, INT_PD_Pin) == GPIO_PIN_SET ?
|
if (FUSB302_present) {
|
||||||
1 : 0;
|
return HAL_GPIO_ReadPin(INT_PD_GPIO_Port, INT_PD_Pin) == GPIO_PIN_SET ?
|
||||||
|
1 : 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ 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; }
|
||||||
|
|
||||||
void QC_resync() {
|
void QC_resync() {
|
||||||
#ifdef MODEL_TS80
|
#if defined(MODEL_TS80) + defined(MODEL_TS80P) >0
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#ifndef BSP_MINIWARE_UNITSETTINGS_H_
|
#ifndef BSP_MINIWARE_UNITSETTINGS_H_
|
||||||
#define BSP_MINIWARE_UNITSETTINGS_H_
|
#define BSP_MINIWARE_UNITSETTINGS_H_
|
||||||
//On the TS80, the LIS accel is mounted backwards
|
//On the TS80, the LIS accel is mounted backwards
|
||||||
#ifdef MODEL_TS80
|
#if defined(MODEL_TS80)+defined(MODEL_TS80P)>0
|
||||||
#define LIS_ORI_FLIP
|
#define LIS_ORI_FLIP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ 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_TS80
|
#ifdef MODEL_TS80P
|
||||||
I2CBB::init();
|
I2CBB::init();
|
||||||
//Spawn all of the USB-C processors
|
//Spawn all of the USB-C processors
|
||||||
fusb302_start_processing();
|
fusb302_start_processing();
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ static uint8_t fusb_read_byte(uint8_t addr) {
|
|||||||
* buf: The buffer into which data will be read
|
* buf: The buffer into which data will be read
|
||||||
*/
|
*/
|
||||||
static void fusb_read_buf(uint8_t addr, uint8_t size, uint8_t *buf) {
|
static void fusb_read_buf(uint8_t addr, uint8_t size, uint8_t *buf) {
|
||||||
I2CBB::Mem_Read(FUSB302B_ADDR, addr, (uint8_t*) buf, size);
|
if(!I2CBB::Mem_Read(FUSB302B_ADDR, addr, (uint8_t*) buf, size)){
|
||||||
|
asm("bkpt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +56,9 @@ static void fusb_read_buf(uint8_t addr, uint8_t size, uint8_t *buf) {
|
|||||||
* byte: The value to write
|
* byte: The value to write
|
||||||
*/
|
*/
|
||||||
static void fusb_write_byte(uint8_t addr, uint8_t byte) {
|
static void fusb_write_byte(uint8_t addr, uint8_t byte) {
|
||||||
I2CBB::Mem_Write(FUSB302B_ADDR, addr, (uint8_t*) &byte, 1);
|
if(!I2CBB::Mem_Write(FUSB302B_ADDR, addr, (uint8_t*) &byte, 1)){
|
||||||
|
asm("bkpt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +71,9 @@ static void fusb_write_byte(uint8_t addr, uint8_t byte) {
|
|||||||
* buf: The buffer to write
|
* buf: The buffer to write
|
||||||
*/
|
*/
|
||||||
static void fusb_write_buf(uint8_t addr, uint8_t size, const uint8_t *buf) {
|
static void fusb_write_buf(uint8_t addr, uint8_t size, const uint8_t *buf) {
|
||||||
I2CBB::Mem_Write(FUSB302B_ADDR, addr, (uint8_t*) &buf, size);
|
if(!I2CBB::Mem_Write(FUSB302B_ADDR, addr, (uint8_t*) &buf, size)){
|
||||||
|
asm("bkpt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ uint8_t fusb302_detect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fusb302_start_processing() {
|
void fusb302_start_processing() {
|
||||||
|
HAL_Delay(30);
|
||||||
/* Initialize the FUSB302B */
|
/* Initialize the FUSB302B */
|
||||||
fusb_setup();
|
fusb_setup();
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void ResetHandler::init() {
|
|||||||
|
|
||||||
void ResetHandler::notify(uint32_t notification) {
|
void ResetHandler::notify(uint32_t notification) {
|
||||||
xTaskNotify(TaskHandle, notification,
|
xTaskNotify(TaskHandle, notification,
|
||||||
eNotifyAction::eSetValueWithOverwrite);
|
eNotifyAction::eSetBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetHandler::Thread(const void *arg) {
|
void ResetHandler::Thread(const void *arg) {
|
||||||
|
|||||||
@@ -278,15 +278,13 @@
|
|||||||
#define PD_T_PS_TRANSITION (500)
|
#define PD_T_PS_TRANSITION (500)
|
||||||
#define PD_T_SENDER_RESPONSE (27)
|
#define PD_T_SENDER_RESPONSE (27)
|
||||||
#define PD_T_SINK_REQUEST (100)
|
#define PD_T_SINK_REQUEST (100)
|
||||||
#define PD_T_TYPEC_SINK_WAIT_CAP (465)
|
#define PD_T_TYPEC_SINK_WAIT_CAP (465+100)
|
||||||
#define PD_T_PPS_REQUEST TIME_S2I(10)
|
|
||||||
/* This is actually from Type-C, not Power Delivery, but who cares? */
|
|
||||||
#define PD_T_PD_DEBOUNCE (15)
|
#define PD_T_PD_DEBOUNCE (15)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Counter maximums
|
* Counter maximums
|
||||||
*/
|
*/
|
||||||
#define PD_N_HARD_RESET_COUNT 2
|
#define PD_N_HARD_RESET_COUNT 10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Value parameters
|
* Value parameters
|
||||||
|
|||||||
@@ -22,21 +22,6 @@
|
|||||||
/* Number of messages in the message pool */
|
/* Number of messages in the message pool */
|
||||||
#define PDB_MSG_POOL_SIZE 4
|
#define PDB_MSG_POOL_SIZE 4
|
||||||
|
|
||||||
/* Size of the Policy Engine thread's working area */
|
|
||||||
#define PDB_PE_WA_SIZE 256
|
|
||||||
|
|
||||||
/* Size of the protocol layer RX thread's working area */
|
|
||||||
#define PDB_PRLRX_WA_SIZE 256
|
|
||||||
|
|
||||||
/* Size of the protocol layer TX thread's working area */
|
|
||||||
#define PDB_PRLTX_WA_SIZE 256
|
|
||||||
|
|
||||||
/* Size of the protocol layer hard reset thread's working area */
|
|
||||||
#define PDB_HARDRST_WA_SIZE 256
|
|
||||||
|
|
||||||
/* Size of the INT_N thread's working area */
|
|
||||||
#define PDB_INT_N_WA_SIZE 128
|
|
||||||
|
|
||||||
#define EVENT_MASK(x) (1<<x)
|
#define EVENT_MASK(x) (1<<x)
|
||||||
#define eventmask_t uint32_t
|
#define eventmask_t uint32_t
|
||||||
/* PD Buddy thread priorities */
|
/* PD Buddy thread priorities */
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void PolicyEngine::init() {
|
|||||||
|
|
||||||
void PolicyEngine::notify(uint32_t notification) {
|
void PolicyEngine::notify(uint32_t notification) {
|
||||||
xTaskNotify(TaskHandle, notification,
|
xTaskNotify(TaskHandle, notification,
|
||||||
eNotifyAction::eSetValueWithOverwrite);
|
eNotifyAction::eSetBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolicyEngine::pe_task(const void *arg) {
|
void PolicyEngine::pe_task(const void *arg) {
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ bool PolicyEngine::pdbs_dpm_evaluate_capability(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
/* If we have a PPS APDO, our desired V lies within its range, and
|
/* If we have a PPS APDO, our desired V lies within its range, and
|
||||||
* its I is at least our desired I */
|
* its I is at least our desired I */
|
||||||
if ((capabilities->obj[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED
|
if ((capabilities->obj[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED
|
||||||
@@ -108,6 +109,7 @@ bool PolicyEngine::pdbs_dpm_evaluate_capability(
|
|||||||
//
|
//
|
||||||
// return true;
|
// return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* If there's a PDO in the voltage range, use it */
|
/* If there's a PDO in the voltage range, use it */
|
||||||
// int8_t i = dpm_get_range_fixed_pdo_index(caps, scfg);
|
// int8_t i = dpm_get_range_fixed_pdo_index(caps, scfg);
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ uint8_t ProtocolReceive::_tx_messageidcounter;
|
|||||||
*/
|
*/
|
||||||
ProtocolReceive::protocol_rx_state ProtocolReceive::protocol_rx_wait_phy() {
|
ProtocolReceive::protocol_rx_state ProtocolReceive::protocol_rx_wait_phy() {
|
||||||
/* Wait for an event */
|
/* Wait for an event */
|
||||||
|
_rx_messageid = 0;
|
||||||
eventmask_t evt = waitForEvent(0xFFFFFFFF);
|
eventmask_t evt = waitForEvent(0xFFFFFFFF);
|
||||||
|
|
||||||
/* If we got a reset event, reset */
|
/* If we got a reset event, reset */
|
||||||
if (evt & PDB_EVT_PRLRX_RESET) {
|
if (evt & PDB_EVT_PRLRX_RESET) {
|
||||||
|
waitForEvent(PDB_EVT_PRLRX_RESET, 0);
|
||||||
return PRLRxWaitPHY;
|
return PRLRxWaitPHY;
|
||||||
}
|
}
|
||||||
/* If we got an I_GCRCSENT event, read the message and decide what to do */
|
/* If we got an I_GCRCSENT event, read the message and decide what to do */
|
||||||
@@ -75,7 +77,7 @@ ProtocolReceive::protocol_rx_state ProtocolReceive::protocol_rx_reset() {
|
|||||||
taskYIELD();
|
taskYIELD();
|
||||||
|
|
||||||
/* If we got a RESET signal, reset the machine */
|
/* If we got a RESET signal, reset the machine */
|
||||||
if (waitForEvent(PDB_EVT_PRLRX_RESET) != 0) {
|
if (waitForEvent(PDB_EVT_PRLRX_RESET, 0) != 0) {
|
||||||
return PRLRxWaitPHY;
|
return PRLRxWaitPHY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,17 +90,16 @@ ProtocolReceive::protocol_rx_state ProtocolReceive::protocol_rx_reset() {
|
|||||||
*/
|
*/
|
||||||
ProtocolReceive::protocol_rx_state ProtocolReceive::protocol_rx_check_messageid() {
|
ProtocolReceive::protocol_rx_state ProtocolReceive::protocol_rx_check_messageid() {
|
||||||
/* If we got a RESET signal, reset the machine */
|
/* If we got a RESET signal, reset the machine */
|
||||||
if (waitForEvent(PDB_EVT_PRLRX_RESET) != 0) {
|
if (waitForEvent(PDB_EVT_PRLRX_RESET, 0) == PDB_EVT_PRLRX_RESET) {
|
||||||
|
|
||||||
return PRLRxWaitPHY;
|
return PRLRxWaitPHY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the message has the stored ID, we've seen this message before. Free
|
/* If the message has the stored ID, we've seen this message before. Free
|
||||||
* it and don't pass it to the policy engine. */
|
* it and don't pass it to the policy engine. */
|
||||||
|
|
||||||
|
/* Otherwise, there's either no stored ID or this message has an ID we
|
||||||
|
* haven't just seen. Transition to the Store_MessageID state. */
|
||||||
if (PD_MESSAGEID_GET(&tempMessage) == _rx_messageid) {
|
if (PD_MESSAGEID_GET(&tempMessage) == _rx_messageid) {
|
||||||
return PRLRxWaitPHY;
|
return PRLRxWaitPHY;
|
||||||
/* Otherwise, there's either no stored ID or this message has an ID we
|
|
||||||
* haven't just seen. Transition to the Store_MessageID state. */
|
|
||||||
} else {
|
} else {
|
||||||
return PRLRxStoreMessageID;
|
return PRLRxStoreMessageID;
|
||||||
}
|
}
|
||||||
@@ -160,12 +161,11 @@ void ProtocolReceive::thread(const void *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolReceive::notify(uint32_t notification) {
|
void ProtocolReceive::notify(uint32_t notification) {
|
||||||
xTaskNotify(TaskHandle, notification,
|
xTaskNotify(TaskHandle, notification, eNotifyAction::eSetBits);
|
||||||
eNotifyAction::eSetValueWithOverwrite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ProtocolReceive::waitForEvent(uint32_t mask, uint32_t ticksToWait) {
|
uint32_t ProtocolReceive::waitForEvent(uint32_t mask, uint32_t ticksToWait) {
|
||||||
uint32_t pulNotificationValue;
|
uint32_t pulNotificationValue;
|
||||||
xTaskNotifyWait(0x00, mask, &pulNotificationValue, ticksToWait);
|
xTaskNotifyWait(0x00, mask, &pulNotificationValue, ticksToWait);
|
||||||
return pulNotificationValue;
|
return pulNotificationValue & mask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ ProtocolTransmit::protocol_tx_state ProtocolTransmit::protocol_tx_phy_reset() {
|
|||||||
/* Tell the policy engine that we failed */
|
/* Tell the policy engine that we failed */
|
||||||
PolicyEngine::notify( PDB_EVT_PE_TX_ERR);
|
PolicyEngine::notify( PDB_EVT_PE_TX_ERR);
|
||||||
/* Finish failing to send the message */
|
/* Finish failing to send the message */
|
||||||
getMessage(); //Discard
|
while (messagePending()) {
|
||||||
|
getMessage(); //Discard
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for a message request */
|
/* Wait for a message request */
|
||||||
@@ -103,7 +105,7 @@ ProtocolTransmit::protocol_tx_state ProtocolTransmit::protocol_tx_reset() {
|
|||||||
ProtocolTransmit::protocol_tx_state ProtocolTransmit::protocol_tx_construct_message() {
|
ProtocolTransmit::protocol_tx_state ProtocolTransmit::protocol_tx_construct_message() {
|
||||||
/* Make sure nobody wants us to reset */
|
/* Make sure nobody wants us to reset */
|
||||||
eventmask_t evt = waitForEvent(
|
eventmask_t evt = waitForEvent(
|
||||||
PDB_EVT_PRLTX_RESET | PDB_EVT_PRLTX_DISCARD);
|
PDB_EVT_PRLTX_RESET | PDB_EVT_PRLTX_DISCARD, 0);
|
||||||
|
|
||||||
if (evt & PDB_EVT_PRLTX_RESET) {
|
if (evt & PDB_EVT_PRLTX_RESET) {
|
||||||
return PRLTxPHYReset;
|
return PRLTxPHYReset;
|
||||||
@@ -119,7 +121,7 @@ ProtocolTransmit::protocol_tx_state ProtocolTransmit::protocol_tx_construct_mess
|
|||||||
/* PD 3.0 collision avoidance */
|
/* PD 3.0 collision avoidance */
|
||||||
if (PolicyEngine::isPD3_0()) {
|
if (PolicyEngine::isPD3_0()) {
|
||||||
/* If we're starting an AMS, wait for permission to transmit */
|
/* If we're starting an AMS, wait for permission to transmit */
|
||||||
evt = waitForEvent(PDB_EVT_PRLTX_START_AMS);
|
evt = waitForEvent(PDB_EVT_PRLTX_START_AMS, 0);
|
||||||
if (evt & PDB_EVT_PRLTX_START_AMS) {
|
if (evt & PDB_EVT_PRLTX_START_AMS) {
|
||||||
while (fusb_get_typec_current() != fusb_sink_tx_ok) {
|
while (fusb_get_typec_current() != fusb_sink_tx_ok) {
|
||||||
osDelay(1);
|
osDelay(1);
|
||||||
@@ -253,14 +255,14 @@ void ProtocolTransmit::thread(const void *args) {
|
|||||||
|
|
||||||
void ProtocolTransmit::notify(uint32_t notification) {
|
void ProtocolTransmit::notify(uint32_t notification) {
|
||||||
xTaskNotify(TaskHandle, notification,
|
xTaskNotify(TaskHandle, notification,
|
||||||
eNotifyAction::eSetValueWithOverwrite);
|
eNotifyAction::eSetBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolTransmit::init() {
|
void ProtocolTransmit::init() {
|
||||||
messagesWaiting = xQueueCreateStatic(PDB_MSG_POOL_SIZE,
|
messagesWaiting = xQueueCreateStatic(PDB_MSG_POOL_SIZE,
|
||||||
sizeof(union pd_msg), ucQueueStorageArea, &xStaticQueue);
|
sizeof(union pd_msg), ucQueueStorageArea, &xStaticQueue);
|
||||||
|
|
||||||
osThreadStaticDef(pd_txTask, thread, PDB_PRIO_PRL, 0, TaskStackSize,
|
osThreadStaticDef(pd_txTask, thread,osPriorityAboveNormal, 0, TaskStackSize,
|
||||||
TaskBuffer, &TaskControlBlock);
|
TaskBuffer, &TaskControlBlock);
|
||||||
TaskHandle = osThreadCreate(osThread(pd_txTask), NULL);
|
TaskHandle = osThreadCreate(osThread(pd_txTask), NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <history.hpp>
|
#include <history.hpp>
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "expMovingAverage.h"
|
#include "expMovingAverage.h"
|
||||||
|
#include "../../configuration.h"
|
||||||
#ifndef POWER_HPP_
|
#ifndef POWER_HPP_
|
||||||
#define POWER_HPP_
|
#define POWER_HPP_
|
||||||
|
|
||||||
@@ -18,16 +19,6 @@
|
|||||||
// This is necessary because of the temp noise and thermal lag in the system.
|
// This is necessary because of the temp noise and thermal lag in the system.
|
||||||
// Once we have feed-forward temp estimation we should be able to better tune this.
|
// Once we have feed-forward temp estimation we should be able to better tune this.
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
|
||||||
const int32_t tipMass = 45; // X10 watts to raise 1 deg C in 1 second
|
|
||||||
const uint8_t tipResistance = 85; //x10 ohms, 8.5 typical for ts100, 4.5 typical for ts80
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef MODEL_TS80
|
|
||||||
const uint32_t tipMass = 40;
|
|
||||||
const uint8_t tipResistance = 45; //x10 ohms, 8.5 typical for ts100, 4.5 typical for ts80
|
|
||||||
|
|
||||||
#endif
|
|
||||||
const uint8_t wattHistoryFilter = 24; // I term look back weighting
|
const uint8_t wattHistoryFilter = 24; // I term look back weighting
|
||||||
extern expMovingAverage<uint32_t, wattHistoryFilter> x10WattHistory;
|
extern expMovingAverage<uint32_t, wattHistoryFilter> x10WattHistory;
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ int main(void) {
|
|||||||
OLED::setFont(0); // default to bigger font
|
OLED::setFont(0); // default to bigger font
|
||||||
// Testing for which accelerometer is mounted
|
// Testing for which accelerometer is mounted
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
|
usb_pd_available = usb_pd_detect();
|
||||||
|
resetWatchdog();
|
||||||
settingsWereReset = restoreSettings(); // load the settings from flash
|
settingsWereReset = restoreSettings(); // load the settings from flash
|
||||||
if (MMA8652FC::detect()) {
|
if (MMA8652FC::detect()) {
|
||||||
PCBVersion = 1;
|
PCBVersion = 1;
|
||||||
@@ -58,8 +60,6 @@ int main(void) {
|
|||||||
systemSettings.sensitivity = 0;
|
systemSettings.sensitivity = 0;
|
||||||
}
|
}
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
usb_pd_available = usb_pd_detect();
|
|
||||||
resetWatchdog();
|
|
||||||
|
|
||||||
/* Create the thread(s) */
|
/* Create the thread(s) */
|
||||||
/* definition and creation of GUITask */
|
/* definition and creation of GUITask */
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
|
|||||||
FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
|
FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
|
||||||
FRTOS_GCC_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3
|
FRTOS_GCC_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3
|
||||||
DRIVER_INC_DIR =./Core/Drivers
|
DRIVER_INC_DIR =./Core/Drivers
|
||||||
|
FUSB_DRIVERS_INC_DIR = ./Core/Drivers/FUSB302
|
||||||
BSP_INC_DIR = ./Core/BSP
|
BSP_INC_DIR = ./Core/BSP
|
||||||
MINIWARE_INC_DIR = ./Core/BSP/Miniware
|
MINIWARE_INC_DIR = ./Core/BSP/Miniware
|
||||||
THREADS_INC_DIR = ./Core/Threads
|
THREADS_INC_DIR = ./Core/Threads
|
||||||
@@ -37,7 +38,8 @@ INCLUDES = -I$(APP_INC_DIR) \
|
|||||||
-I$(DRIVER_INC_DIR) \
|
-I$(DRIVER_INC_DIR) \
|
||||||
-I$(BSP_INC_DIR) \
|
-I$(BSP_INC_DIR) \
|
||||||
-I$(MINIWARE_INC_DIR) \
|
-I$(MINIWARE_INC_DIR) \
|
||||||
-I$(THREADS_INC_DIR)
|
-I$(THREADS_INC_DIR) \
|
||||||
|
-I$(FUSB_DRIVERS_INC_DIR)
|
||||||
# output folder
|
# output folder
|
||||||
HEXFILE_DIR=Hexfile
|
HEXFILE_DIR=Hexfile
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,6 @@
|
|||||||
#define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0
|
#define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0
|
||||||
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
|
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
|
||||||
|
|
||||||
|
|
||||||
#define CUT_OUT_SETTING 0 // default to no cut-off voltage (or 18W for TS80)
|
#define CUT_OUT_SETTING 0 // default to no cut-off voltage (or 18W for TS80)
|
||||||
#define TEMPERATURE_INF 0 // default to 0
|
#define TEMPERATURE_INF 0 // default to 0
|
||||||
#define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow
|
#define DESCRIPTION_SCROLL_SPEED 0 // 0: Slow 1: Fast - default to slow
|
||||||
@@ -94,6 +93,10 @@
|
|||||||
|
|
||||||
#define OP_AMP_GAIN_STAGE_TS80 (1+(OP_AMP_Rf_TS80/OP_AMP_Rin_TS80))
|
#define OP_AMP_GAIN_STAGE_TS80 (1+(OP_AMP_Rf_TS80/OP_AMP_Rin_TS80))
|
||||||
|
|
||||||
|
//Deriving the Voltage div:
|
||||||
|
// Vin_max = (3.3*(r1+r2))/(r2)
|
||||||
|
//vdiv = (32768*4)/(vin_max*10)
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
#define VOLTAGE_DIV 467 // 467 - Default divider from schematic
|
#define VOLTAGE_DIV 467 // 467 - Default divider from schematic
|
||||||
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
|
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
|
||||||
@@ -105,11 +108,39 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
#define VOLTAGE_DIV 780 // Default divider from schematic
|
#define VOLTAGE_DIV_TS80P 768 // Default for TS80P with slightly different resistors
|
||||||
#define PID_POWER_LIMIT 24 // Sets the max pwm power limit
|
#define VOLTAGE_DIV 780 // Default divider from schematic
|
||||||
#define CALIBRATION_OFFSET 900 // the adc offset in uV
|
#define PID_POWER_LIMIT 24 // Sets the max pwm power limit
|
||||||
#define POWER_LIMIT 24 // 24 watts default power limit
|
#define CALIBRATION_OFFSET 900 // the adc offset in uV
|
||||||
#define MAX_POWER_LIMIT 30 //
|
#define POWER_LIMIT 24 // 24 watts default power limit
|
||||||
#define POWER_LIMIT_STEPS 2
|
#define MAX_POWER_LIMIT 30 //
|
||||||
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80
|
#define POWER_LIMIT_STEPS 2
|
||||||
|
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS80P
|
||||||
|
#define VOLTAGE_DIV 768 // Default for TS80P with slightly different resistors
|
||||||
|
#define PID_POWER_LIMIT 30 // Sets the max pwm power limit
|
||||||
|
#define CALIBRATION_OFFSET 900 // the adc offset in uV
|
||||||
|
#define POWER_LIMIT 24 // 24 watts default power limit
|
||||||
|
#define MAX_POWER_LIMIT 30 //
|
||||||
|
#define POWER_LIMIT_STEPS 2
|
||||||
|
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MODEL_TS100
|
||||||
|
const int32_t tipMass = 45; // X10 watts to raise 1 deg C in 1 second
|
||||||
|
const uint8_t tipResistance = 85; //x10 ohms, 8.5 typical for ts100, 4.5 typical for ts80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS80
|
||||||
|
const uint32_t tipMass = 40;
|
||||||
|
const uint8_t tipResistance = 45; //x10 ohms, 4.5 typical for ts80 tips
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS80P
|
||||||
|
const uint32_t tipMass = 40;
|
||||||
|
const uint8_t tipResistance = 45; //x10 ohms, 4.5 typical for ts80 tips
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user