mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
usb: remove incorrectly-ordered bits in USB registers
This commit is contained in:
parent
c28d06002f
commit
42853103aa
3 changed files with 24 additions and 96 deletions
|
@ -137,47 +137,11 @@ typedef volatile struct
|
||||||
pad(4);
|
pad(4);
|
||||||
|
|
||||||
/* BRDY Interrupt Enable Register */
|
/* BRDY Interrupt Enable Register */
|
||||||
word_union(BRDYENB,
|
uint16_t 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;
|
|
||||||
);
|
|
||||||
/* NRDY Interrupt Enable Register */
|
/* NRDY Interrupt Enable Register */
|
||||||
word_union(NRDYENB,
|
uint16_t 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;
|
|
||||||
);
|
|
||||||
/* BEMP Interrupt Enable Register */
|
/* BEMP Interrupt Enable Register */
|
||||||
word_union(BEMPENB,
|
uint16_t 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;
|
|
||||||
);
|
|
||||||
|
|
||||||
/* SOF Control Register */
|
/* SOF Control Register */
|
||||||
word_union(SOFCFG,
|
word_union(SOFCFG,
|
||||||
|
@ -208,53 +172,17 @@ typedef volatile struct
|
||||||
pad(4);
|
pad(4);
|
||||||
|
|
||||||
/* BRDY Interrupt Status Register */
|
/* BRDY Interrupt Status Register */
|
||||||
word_union(BRDYSTS,
|
uint16_t 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;
|
|
||||||
);
|
|
||||||
/* NRDY Interrupt Status Register */
|
/* NRDY Interrupt Status Register */
|
||||||
word_union(NRDYSTS,
|
uint16_t 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;
|
|
||||||
);
|
|
||||||
/* BEMP Interrupt Status Register */
|
/* BEMP Interrupt Status Register */
|
||||||
word_union(BEMPSTS,
|
uint16_t 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;
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Frame Number Registers */
|
/* Frame Number Registers */
|
||||||
word_union(FRMNUM,
|
word_union(FRMNUM,
|
||||||
uint16_t OVRN :1; /* Overrun/Underrun Detection Status */
|
uint16_t OVRN :1; /* Overrun/Underrun Detection Status */
|
||||||
uint16_t CRCE :1; /* Receive Data Error */
|
uint16_t CRCE :1; /* Receive Data Error */
|
||||||
uint16_t cons :3;
|
uint16_t const :3;
|
||||||
uint16_t FRNM :11; /* Frame Number */
|
uint16_t FRNM :11; /* Frame Number */
|
||||||
);
|
);
|
||||||
word_union(UFRMNUM,
|
word_union(UFRMNUM,
|
||||||
|
@ -341,7 +269,7 @@ typedef volatile struct
|
||||||
/* Pipe Buffer Setting Register */
|
/* Pipe Buffer Setting Register */
|
||||||
word_union(PIPEBUF,
|
word_union(PIPEBUF,
|
||||||
uint16_t :1;
|
uint16_t :1;
|
||||||
uint16_t BUFSIZE : 5; /* Buffer Size */
|
uint16_t BUFSIZE:5; /* Buffer Size */
|
||||||
uint16_t :2;
|
uint16_t :2;
|
||||||
uint16_t BUFNMB :8; /* Buffer Number */
|
uint16_t BUFNMB :8; /* Buffer Number */
|
||||||
);
|
);
|
||||||
|
|
|
@ -224,7 +224,7 @@ static void finish_transfer(struct transfer volatile *t, int pipe)
|
||||||
t->used = 0;
|
t->used = 0;
|
||||||
|
|
||||||
/* Disable the interrupt */
|
/* Disable the interrupt */
|
||||||
if(pipe) USB.BEMPENB.word &= ~(1 << pipe);
|
if(pipe) USB.BEMPENB &= ~(1 << pipe);
|
||||||
|
|
||||||
if(t->callback.function) gint_call(t->callback);
|
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
|
/* Set up the Buffer Empty interrupt to refill the buffer when it gets
|
||||||
empty, and be notified when the transfer completes. */
|
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);
|
write_round(t, pipe);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -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 */
|
/* VBSE=1 RSME=0 SOFE=0 DVSE=1 CTRE=1 BEMPE=1 NRDYE=0 BRDYE=0 */
|
||||||
USB.INTENB0.word = 0x9c00;
|
USB.INTENB0.word = 0x9c00;
|
||||||
USB.BRDYENB.word = 0x0000;
|
USB.BRDYENB = 0x0000;
|
||||||
USB.NRDYENB.word = 0x0000;
|
USB.NRDYENB = 0x0000;
|
||||||
USB.BEMPENB.word = 0x0000;
|
USB.BEMPENB = 0x0000;
|
||||||
|
|
||||||
intc_handler_function(0xa20, GINT_CALL(usb_interrupt_handler));
|
intc_handler_function(0xa20, GINT_CALL(usb_interrupt_handler));
|
||||||
intc_priority(INTC_USB, 8);
|
intc_priority(INTC_USB, 8);
|
||||||
|
@ -258,8 +258,8 @@ static void usb_interrupt_handler(void)
|
||||||
else if(USB.INTSTS0.BEMP)
|
else if(USB.INTSTS0.BEMP)
|
||||||
{
|
{
|
||||||
/* Invoke callbacks for each buffer-empty interrupt */
|
/* Invoke callbacks for each buffer-empty interrupt */
|
||||||
uint16_t status = USB.BEMPSTS.word;
|
uint16_t status = USB.BEMPSTS;
|
||||||
USB.BEMPSTS.word = 0;
|
USB.BEMPSTS = 0;
|
||||||
|
|
||||||
for(int i = 1; i <= 9; i++)
|
for(int i = 1; i <= 9; i++)
|
||||||
{
|
{
|
||||||
|
@ -288,9 +288,9 @@ void hsave(usb_state_t *s)
|
||||||
s->D1FIFOSEL = USB.D1FIFOSEL.word;
|
s->D1FIFOSEL = USB.D1FIFOSEL.word;
|
||||||
|
|
||||||
s->INTENB0 = USB.INTENB0.word;
|
s->INTENB0 = USB.INTENB0.word;
|
||||||
s->BRDYENB = USB.BRDYENB.word;
|
s->BRDYENB = USB.BRDYENB;
|
||||||
s->NRDYENB = USB.NRDYENB.word;
|
s->NRDYENB = USB.NRDYENB;
|
||||||
s->BEMPENB = USB.BEMPENB.word;
|
s->BEMPENB = USB.BEMPENB;
|
||||||
s->SOFCFG = USB.SOFCFG.word;
|
s->SOFCFG = USB.SOFCFG.word;
|
||||||
|
|
||||||
s->DCPCFG = USB.DCPCFG.word;
|
s->DCPCFG = USB.DCPCFG.word;
|
||||||
|
@ -317,9 +317,9 @@ static void hrestore(usb_state_t const *s)
|
||||||
USB.D1FIFOSEL.word = s->D1FIFOSEL;
|
USB.D1FIFOSEL.word = s->D1FIFOSEL;
|
||||||
|
|
||||||
USB.INTENB0.word = s->INTENB0;
|
USB.INTENB0.word = s->INTENB0;
|
||||||
USB.BRDYENB.word = s->BRDYENB;
|
USB.BRDYENB = s->BRDYENB;
|
||||||
USB.NRDYENB.word = s->NRDYENB;
|
USB.NRDYENB = s->NRDYENB;
|
||||||
USB.BEMPENB.word = s->BEMPENB;
|
USB.BEMPENB = s->BEMPENB;
|
||||||
USB.SOFCFG.word = s->SOFCFG;
|
USB.SOFCFG.word = s->SOFCFG;
|
||||||
|
|
||||||
USB.DCPCFG.word = s->DCPCFG;
|
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 */
|
/* Clear remaining interrupts. Read-only bits will be ignored */
|
||||||
USB.INTSTS0.word = 0;
|
USB.INTSTS0.word = 0;
|
||||||
USB.BRDYSTS.word = 0;
|
USB.BRDYSTS = 0;
|
||||||
USB.NRDYSTS.word = 0;
|
USB.NRDYSTS = 0;
|
||||||
USB.BEMPSTS.word = 0;
|
USB.BEMPSTS = 0;
|
||||||
|
|
||||||
/* Restore SYSCFG last as clearing SCKE disables writing */
|
/* Restore SYSCFG last as clearing SCKE disables writing */
|
||||||
USB.SYSCFG.word = s->SYSCFG;
|
USB.SYSCFG.word = s->SYSCFG;
|
||||||
|
|
Loading…
Reference in a new issue