dev: formatting fixes, additional Piece logic and properties, etc
This commit is contained in:
parent
cc37d834fe
commit
b0afa6cd78
7 changed files with 295 additions and 21 deletions
15
main.cpp
15
main.cpp
|
|
@ -58,6 +58,7 @@
|
|||
#define SPI_BAUD 1000000 // 1MHz hopefully
|
||||
|
||||
volatile uint8_t spi_rx_buffer[8];
|
||||
volatile uint32_t usbBDT[512] __attribute__((aligned(512))); // USB buffer description table
|
||||
|
||||
// dummy open to get rid of linker error
|
||||
|
||||
|
|
@ -130,7 +131,7 @@ uint8_t initSystem(void) {
|
|||
SPI1CONbits.ON = 1; // Enable SPI
|
||||
|
||||
/* set up UART */
|
||||
U1BRG = 19; // 9600 baud (was 38 @ 24MHz)
|
||||
U1BRG = 9; // 9600 baud (was 38 @ 24MHz)
|
||||
U1STAbits.UTXEN = 1; // enable transmitter
|
||||
U1MODEbits.ON = 1; // enable UART
|
||||
|
||||
|
|
@ -199,7 +200,7 @@ extern "C" int main(void) {
|
|||
|
||||
// === Interrupt Service Routine for DMA0 (RX complete) ===
|
||||
|
||||
extern "C" void __ISR(_DMA0_VECTOR, IPL3SOFT) DMA0Handler(void) {
|
||||
extern "C" void __ISR(_DMA0_VECTOR, IPL3AUTO) DMA0Handler(void) {
|
||||
__builtin_disable_interrupts(); // stop additional ints from firing
|
||||
if (DCH0INTbits.CHBCIF) {
|
||||
DCH0INTCLR = _DCH0INT_CHBCIF_MASK; // Clear block complete flag
|
||||
|
|
@ -207,4 +208,14 @@ extern "C" void __ISR(_DMA0_VECTOR, IPL3SOFT) DMA0Handler(void) {
|
|||
}
|
||||
|
||||
IFS1CLR = _IFS1_DMA0IF_MASK; // Clear global DMA0 IRQ flag
|
||||
}
|
||||
|
||||
extern "C" void __ISR(_USB1_VECTOR, IPL4AUTO) USBHandler(void) {
|
||||
if (USBE2CSR1bits.RXPKTRDY) {
|
||||
int count = USB_receive_EP2();
|
||||
// Echo back
|
||||
USB_send_EP2(EP[2].rx_buffer, count);
|
||||
USBCSR1bits.EP2RXIF = 0;
|
||||
}
|
||||
IFS1bits.USBIF = 0; // clear USB interrupt flag
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue