add I2C for F303, fix bug in USB (some variables wasn't volatile)

This commit is contained in:
eddyem
2023-01-22 21:55:49 +03:00
parent c6e3acc460
commit b415b94b55
35 changed files with 2605 additions and 27 deletions

View File

@@ -29,7 +29,7 @@ uint8_t ep0dbuflen = 0;
usb_LineCoding getLineCoding(){return lineCoding;}
uint8_t usbON = 0; // device disconnected from terminal
volatile uint8_t usbON = 0; // device disconnected from terminal
// definition of parts common for USB_DeviceDescriptor & USB_DeviceQualifierDescriptor
#define bcdUSB_L 0x10
@@ -149,8 +149,8 @@ void WEAK break_handler(){
// handler of vendor requests
void WEAK vendor_handler(config_pack_t *packet){
uint16_t c;
if(packet->bmRequestType & 0x80){ // read
uint8_t c;
switch(packet->wValue){
case 0x8484:
c = 2;
@@ -164,9 +164,10 @@ void WEAK vendor_handler(config_pack_t *packet){
default:
c = 0;
}
EP_WriteIRQ(0, &c, 1);
EP_WriteIRQ(0, (uint8_t*)&c, 1);
}else{ // write ZLP
EP_WriteIRQ(0, (uint8_t *)0, 0);
c = 0;
EP_WriteIRQ(0, (uint8_t *)&c, 0);
}
}
@@ -226,7 +227,7 @@ static inline void get_descriptor(){
}
}
static uint8_t configuration = 0; // reply for GET_CONFIGURATION (==1 if configured)
static uint16_t configuration = 0; // reply for GET_CONFIGURATION (==1 if configured)
static inline void std_d2h_req(){
uint16_t status = 0; // bus powered
switch(setup_packet.bRequest){
@@ -237,7 +238,7 @@ static inline void std_d2h_req(){
EP_WriteIRQ(0, (uint8_t *)&status, 2); // send status: Bus Powered
break;
case GET_CONFIGURATION:
EP_WriteIRQ(0, &configuration, 1);
EP_WriteIRQ(0, (uint8_t*)&configuration, 1);
break;
default:
break;