usb: remove incorrectly-ordered bits in USB registers

This commit is contained in:
Lephe 2023-01-20 13:47:43 +01:00
parent c28d06002f
commit 42853103aa
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 24 additions and 96 deletions

View File

@ -137,47 +137,11 @@ typedef volatile struct
pad(4);
/* BRDY Interrupt Enable Register */
word_union(BRDYENB,
uint16_t :6;
uint16_t PIPE9BRDYE :1;
uint16_t PIPE8BRDYE :1;
uint16_t PIPE6BRDYE :1;
uint16_t PIPE7BRDYE :1;
uint16_t PIPE5BRDYE :1;
uint16_t PIPE3BRDYE :1;
uint16_t PIPE4BRDYE :1;
uint16_t PIPE2BRDYE :1;
uint16_t PIPE1BRDYE :1;
uint16_t PIPE0BRDYE :1;
);
uint16_t BRDYENB;
/* NRDY Interrupt Enable Register */
word_union(NRDYENB,
uint16_t :6;
uint16_t PIPE9NRDYE :1;
uint16_t PIPE8NRDYE :1;
uint16_t PIPE6NRDYE :1;
uint16_t PIPE7NRDYE :1;
uint16_t PIPE5NRDYE :1;
uint16_t PIPE3NRDYE :1;
uint16_t PIPE4NRDYE :1;
uint16_t PIPE2NRDYE :1;
uint16_t PIPE1NRDYE :1;
uint16_t PIPE0NRDYE :1;
);
uint16_t NRDYENB;
/* BEMP Interrupt Enable Register */
word_union(BEMPENB,
uint16_t :6;
uint16_t PIPE9BEMPE :1;
uint16_t PIPE8BEMPE :1;
uint16_t PIPE6BEMPE :1;
uint16_t PIPE7BEMPE :1;
uint16_t PIPE5BEMPE :1;
uint16_t PIPE3BEMPE :1;
uint16_t PIPE4BEMPE :1;
uint16_t PIPE2BEMPE :1;
uint16_t PIPE1BEMPE :1;
uint16_t PIPE0BEMPE :1;
);
uint16_t BEMPENB;
/* SOF Control Register */
word_union(SOFCFG,
@ -208,53 +172,17 @@ typedef volatile struct
pad(4);
/* BRDY Interrupt Status Register */
word_union(BRDYSTS,
uint16_t :6;
uint16_t PIPE9BRDY :1;
uint16_t PIPE8BRDY :1;
uint16_t PIPE6BRDY :1;
uint16_t PIPE7BRDY :1;
uint16_t PIPE5BRDY :1;
uint16_t PIPE3BRDY :1;
uint16_t PIPE4BRDY :1;
uint16_t PIPE2BRDY :1;
uint16_t PIPE1BRDY :1;
uint16_t PIPE0BRDY :1;
);
uint16_t BRDYSTS;
/* NRDY Interrupt Status Register */
word_union(NRDYSTS,
uint16_t :6;
uint16_t PIPE9NRDY :1;
uint16_t PIPE8NRDY :1;
uint16_t PIPE6NRDY :1;
uint16_t PIPE7NRDY :1;
uint16_t PIPE5NRDY :1;
uint16_t PIPE3NRDY :1;
uint16_t PIPE4NRDY :1;
uint16_t PIPE2NRDY :1;
uint16_t PIPE1NRDY :1;
uint16_t PIPE0NRDY :1;
);
uint16_t NRDYSTS;
/* BEMP Interrupt Status Register */
word_union(BEMPSTS,
uint16_t :6;
uint16_t PIPE9BEMP :1;
uint16_t PIPE8BEMP :1;
uint16_t PIPE6BEMP :1;
uint16_t PIPE7BEMP :1;
uint16_t PIPE5BEMP :1;
uint16_t PIPE3BEMP :1;
uint16_t PIPE4BEMP :1;
uint16_t PIPE2BEMP :1;
uint16_t PIPE1BEMP :1;
uint16_t PIPE0BEMP :1;
);
uint16_t BEMPSTS;
/* Frame Number Registers */
word_union(FRMNUM,
uint16_t OVRN :1; /* Overrun/Underrun Detection Status */
uint16_t CRCE :1; /* Receive Data Error */
uint16_t cons :3;
uint16_t const :3;
uint16_t FRNM :11; /* Frame Number */
);
word_union(UFRMNUM,
@ -341,7 +269,7 @@ typedef volatile struct
/* Pipe Buffer Setting Register */
word_union(PIPEBUF,
uint16_t :1;
uint16_t BUFSIZE : 5; /* Buffer Size */
uint16_t BUFSIZE:5; /* Buffer Size */
uint16_t :2;
uint16_t BUFNMB :8; /* Buffer Number */
);

View File

@ -224,7 +224,7 @@ static void finish_transfer(struct transfer volatile *t, int pipe)
t->used = 0;
/* Disable the interrupt */
if(pipe) USB.BEMPENB.word &= ~(1 << pipe);
if(pipe) USB.BEMPENB &= ~(1 << pipe);
if(t->callback.function) gint_call(t->callback);
@ -340,7 +340,7 @@ int usb_write_async(int pipe, void const *data, int size, int unit_size,
/* Set up the Buffer Empty interrupt to refill the buffer when it gets
empty, and be notified when the transfer completes. */
if(pipe) USB.BEMPENB.word |= (1 << pipe);
if(pipe) USB.BEMPENB |= (1 << pipe);
write_round(t, pipe);
return 0;

View File

@ -181,9 +181,9 @@ int usb_open(usb_interface_t const **interfaces, gint_call_t callback)
/* VBSE=1 RSME=0 SOFE=0 DVSE=1 CTRE=1 BEMPE=1 NRDYE=0 BRDYE=0 */
USB.INTENB0.word = 0x9c00;
USB.BRDYENB.word = 0x0000;
USB.NRDYENB.word = 0x0000;
USB.BEMPENB.word = 0x0000;
USB.BRDYENB = 0x0000;
USB.NRDYENB = 0x0000;
USB.BEMPENB = 0x0000;
intc_handler_function(0xa20, GINT_CALL(usb_interrupt_handler));
intc_priority(INTC_USB, 8);
@ -258,8 +258,8 @@ static void usb_interrupt_handler(void)
else if(USB.INTSTS0.BEMP)
{
/* Invoke callbacks for each buffer-empty interrupt */
uint16_t status = USB.BEMPSTS.word;
USB.BEMPSTS.word = 0;
uint16_t status = USB.BEMPSTS;
USB.BEMPSTS = 0;
for(int i = 1; i <= 9; i++)
{
@ -288,9 +288,9 @@ void hsave(usb_state_t *s)
s->D1FIFOSEL = USB.D1FIFOSEL.word;
s->INTENB0 = USB.INTENB0.word;
s->BRDYENB = USB.BRDYENB.word;
s->NRDYENB = USB.NRDYENB.word;
s->BEMPENB = USB.BEMPENB.word;
s->BRDYENB = USB.BRDYENB;
s->NRDYENB = USB.NRDYENB;
s->BEMPENB = USB.BEMPENB;
s->SOFCFG = USB.SOFCFG.word;
s->DCPCFG = USB.DCPCFG.word;
@ -317,9 +317,9 @@ static void hrestore(usb_state_t const *s)
USB.D1FIFOSEL.word = s->D1FIFOSEL;
USB.INTENB0.word = s->INTENB0;
USB.BRDYENB.word = s->BRDYENB;
USB.NRDYENB.word = s->NRDYENB;
USB.BEMPENB.word = s->BEMPENB;
USB.BRDYENB = s->BRDYENB;
USB.NRDYENB = s->NRDYENB;
USB.BEMPENB = s->BEMPENB;
USB.SOFCFG.word = s->SOFCFG;
USB.DCPCFG.word = s->DCPCFG;
@ -328,9 +328,9 @@ static void hrestore(usb_state_t const *s)
/* Clear remaining interrupts. Read-only bits will be ignored */
USB.INTSTS0.word = 0;
USB.BRDYSTS.word = 0;
USB.NRDYSTS.word = 0;
USB.BEMPSTS.word = 0;
USB.BRDYSTS = 0;
USB.NRDYSTS = 0;
USB.BEMPSTS = 0;
/* Restore SYSCFG last as clearing SCKE disables writing */
USB.SYSCFG.word = s->SYSCFG;