Start fixing code for real usage

This commit is contained in:
Edward Emelianov
2025-09-14 23:15:57 +03:00
parent d790a1610d
commit ec8d56c4ae
4 changed files with 202 additions and 137 deletions

View File

@@ -39,22 +39,22 @@ int main(void){
SysTick_Config((uint32_t)48000); // 1ms
}
hw_setup();
i2c_setup(I2C_SPEED_10K); // start from lowest speed
USB_setup();
uint32_t ctr = Tms;
while(1){
if(Tms - ctr > 499){
ctr = Tms;
pin_toggle(GPIOB, 1 << 1 | 1 << 0); // toggle LED @ PB0
//USND("HALO\n");
}
USB_proc();
int l = USB_receivestr(inbuff, MAXSTRLEN);
if(l < 0) USB_sendstr("ERROR: USB buffer overflow or string was too long\n");
if(l < 0) USND("ERROR: USB buffer overflow or string was too long\n");
else if(l){
const char *ans = parse_cmd(inbuff);
if(ans) USB_sendstr(ans);
if(ans) USND(ans);
}
if(I2C_scan_mode){
if(i2c_scanmode){
uint8_t addr;
int ok = i2c_scan_next_addr(&addr);
if(addr == I2C_ADDREND) USND("Scan ends\n");
@@ -64,6 +64,9 @@ int main(void){
USND(") - found device\n");
}
}
i2c_have_DMA_Rx(); // check if there's DMA Rx complete
if(i2c_got_DMA){
i2c_bufdudump();
i2c_got_DMA = 0;
}
}
}