1
0
forked from me/IronOS

Cleanup more unrequired logic

This commit is contained in:
Ben V. Brown
2020-07-28 22:27:14 +10:00
parent b6ee4207dd
commit d68eb95f50
4 changed files with 15 additions and 30 deletions

View File

@@ -18,7 +18,7 @@
#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");}}
#define SOFT_I2C_DELAY() {for(int xx=0;xx<40;xx++){asm("nop");}}
#endif

View File

@@ -149,7 +149,7 @@ void fusb_setup() {
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 10, 0);
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 12, 0);
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
@@ -157,12 +157,10 @@ void fusb_setup() {
return;
}
}
/* Fully reset the FUSB302B */
fusb_write_byte( FUSB_RESET, FUSB_RESET_SW_RES);
osDelay(2);
if (!fusb_read_id()) {
return;
}
/* Turn on all power */
fusb_write_byte( FUSB_POWER, 0x0F);
@@ -181,21 +179,14 @@ void fusb_setup() {
fusb_write_byte( FUSB_CONTROL1,
FUSB_CONTROL1_RX_FLUSH | FUSB_CONTROL1_ENSOP2 | FUSB_CONTROL1_ENSOP1);
resetWatchdog();
/* Measure CC1 */
fusb_write_byte( FUSB_SWITCHES0, 0x07);
resetWatchdog();
osDelay(10);
resetWatchdog();
uint8_t cc1 = fusb_read_byte( FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
resetWatchdog();
/* Measure CC2 */
resetWatchdog();
fusb_write_byte( FUSB_SWITCHES0, 0x0B);
resetWatchdog();
osDelay(10);
resetWatchdog();
uint8_t cc2 = fusb_read_byte( FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
/* Select the correct CC line for BMC signaling; also enable AUTO_CRC */
@@ -206,7 +197,6 @@ void fusb_setup() {
fusb_write_byte( FUSB_SWITCHES1, 0x26);
fusb_write_byte( FUSB_SWITCHES0, 0x0B);
}
resetWatchdog();
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
I2CBB::unlock2();
}