mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Fix watchdog timeouts && get unit to boot
This commit is contained in:
@@ -94,6 +94,9 @@ uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
||||
sum += samples[i];
|
||||
|
||||
sum /= BATTFILTERDEPTH;
|
||||
if (divisor == 0) {
|
||||
divisor = 1;
|
||||
}
|
||||
return sum * 4 / divisor;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#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() HAL_Delay(1);
|
||||
#define I2C_DELAY() {for(int xx=0;xx<100;xx++){asm("nop");}}
|
||||
void I2CBB::init() {
|
||||
//Set GPIO's to output open drain
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
@@ -70,6 +70,7 @@ bool I2CBB::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData,
|
||||
return false;
|
||||
}
|
||||
while (Size) {
|
||||
resetWatchdog();
|
||||
bool ack = send(pData[0]);
|
||||
if (!ack) {
|
||||
stop();
|
||||
@@ -182,7 +183,7 @@ bool I2CBB::send(uint8_t value) {
|
||||
value <<= 1;
|
||||
}
|
||||
|
||||
bool ack = read_bit()==0;
|
||||
bool ack = read_bit() == 0;
|
||||
return ack;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,14 +152,21 @@ void fusb_setup() {
|
||||
/* Flush the RX buffer */
|
||||
fusb_write_byte( FUSB_CONTROL1, FUSB_CONTROL1_RX_FLUSH);
|
||||
|
||||
resetWatchdog();
|
||||
/* Measure CC1 */
|
||||
fusb_write_byte( FUSB_SWITCHES0, 0x07);
|
||||
osDelay(1);
|
||||
resetWatchdog();
|
||||
delay_ms(1);
|
||||
resetWatchdog();
|
||||
uint8_t cc1 = fusb_read_byte( FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
||||
resetWatchdog();
|
||||
|
||||
/* Measure CC2 */
|
||||
resetWatchdog();
|
||||
fusb_write_byte( FUSB_SWITCHES0, 0x0B);
|
||||
osDelay(1);
|
||||
resetWatchdog();
|
||||
delay_ms(1);
|
||||
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 */
|
||||
@@ -170,6 +177,7 @@ void fusb_setup() {
|
||||
fusb_write_byte( FUSB_SWITCHES1, 0x26);
|
||||
fusb_write_byte( FUSB_SWITCHES0, 0x0B);
|
||||
}
|
||||
resetWatchdog();
|
||||
|
||||
/* Reset the PD logic */
|
||||
fusb_write_byte( FUSB_RESET, FUSB_RESET_PD_RESET);
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
#include <pdb_msg.h>
|
||||
|
||||
/* I2C addresses of the FUSB302B chips */
|
||||
#define FUSB302B_ADDR 0x22
|
||||
#define FUSB302B01_ADDR 0x23
|
||||
#define FUSB302B10_ADDR 0x24
|
||||
#define FUSB302B11_ADDR 0x25
|
||||
#define FUSB302B_ADDR (0x22<<1)
|
||||
#define FUSB302B01_ADDR (0x23<<1)
|
||||
#define FUSB302B10_ADDR (0x24<<1)
|
||||
#define FUSB302B11_ADDR (0x25<<1)
|
||||
|
||||
/* Device ID register */
|
||||
#define FUSB_DEVICE_ID 0x01
|
||||
|
||||
Reference in New Issue
Block a user