[style] mass reformat all the non external code to 4 space indents

Ran everything through scripts/codestyle.space, which uses astyle
to generally follow K&R style.

Biggest non whitespace change is pulling brackets down on function
declarations, which I'm pretty ambivalent about, but astyle insists
on taking a stance
This commit is contained in:
Travis Geiselbrecht
2016-02-14 12:24:01 -08:00
parent 6659d28a4f
commit 2eb32a4369
276 changed files with 11152 additions and 10886 deletions

View File

@@ -42,76 +42,76 @@ static cbuf_t debug_rx_buf;
void stellaris_uart0_irq(void)
{
arm_cm_irq_entry();
arm_cm_irq_entry();
//
// Get the interrrupt status.
//
unsigned long ulStatus = UARTIntStatus(DEBUG_UART, true);
//
// Get the interrrupt status.
//
unsigned long ulStatus = UARTIntStatus(DEBUG_UART, true);
//
// Clear the asserted interrupts.
//
UARTIntClear(DEBUG_UART, ulStatus);
//
// Clear the asserted interrupts.
//
UARTIntClear(DEBUG_UART, ulStatus);
//
// Loop while there are characters in the receive FIFO.
//
bool resched = false;
while (UARTCharsAvail(DEBUG_UART)) {
//
// Read the next character from the UART and write it back to the UART.
//
unsigned char c = UARTCharGetNonBlocking(DEBUG_UART);
cbuf_write_char(&debug_rx_buf, c, false);
//
// Loop while there are characters in the receive FIFO.
//
bool resched = false;
while (UARTCharsAvail(DEBUG_UART)) {
//
// Read the next character from the UART and write it back to the UART.
//
unsigned char c = UARTCharGetNonBlocking(DEBUG_UART);
cbuf_write_char(&debug_rx_buf, c, false);
resched = true;
}
resched = true;
}
arm_cm_irq_exit(resched);
arm_cm_irq_exit(resched);
}
void stellaris_debug_early_init(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
/* we only support UART0 right now */
STATIC_ASSERT(DEBUG_UART == UART0_BASE);
/* we only support UART0 right now */
STATIC_ASSERT(DEBUG_UART == UART0_BASE);
if (DEBUG_UART == UART0_BASE) {
/* Set GPIO A0 and A1 as UART pins. */
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_AHB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
}
if (DEBUG_UART == UART0_BASE) {
/* Set GPIO A0 and A1 as UART pins. */
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_AHB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
}
UARTConfigSetExpClk(DEBUG_UART, SysCtlClockGet(), 115200, UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE);
UARTConfigSetExpClk(DEBUG_UART, SysCtlClockGet(), 115200, UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE);
UARTEnable(DEBUG_UART);
UARTEnable(DEBUG_UART);
}
void stellaris_debug_init(void)
{
cbuf_initialize(&debug_rx_buf, 16);
cbuf_initialize(&debug_rx_buf, 16);
/* Enable the UART interrupt. */
UARTIntEnable(DEBUG_UART, UART_INT_RX | UART_INT_RT);
/* Enable the UART interrupt. */
UARTIntEnable(DEBUG_UART, UART_INT_RX | UART_INT_RT);
NVIC_EnableIRQ(INT_UART0 - 16);
NVIC_EnableIRQ(INT_UART0 - 16);
}
void platform_dputc(char c)
{
if (c == '\n') {
platform_dputc('\r');
}
if (c == '\n') {
platform_dputc('\r');
}
UARTCharPut(DEBUG_UART, c);
UARTCharPut(DEBUG_UART, c);
}
int platform_dgetc(char *c, bool wait)
{
return cbuf_read_char(&debug_rx_buf, c, wait);
return cbuf_read_char(&debug_rx_buf, c, wait);
}

View File

@@ -28,61 +28,61 @@
static void *port_to_pointer(unsigned int port)
{
switch (port) {
default:
case GPIO_PORT_A:
return (void *)GPIO_PORTA_AHB_BASE;
case GPIO_PORT_B:
return (void *)GPIO_PORTB_AHB_BASE;
case GPIO_PORT_C:
return (void *)GPIO_PORTC_AHB_BASE;
case GPIO_PORT_D:
return (void *)GPIO_PORTD_AHB_BASE;
case GPIO_PORT_E:
return (void *)GPIO_PORTE_AHB_BASE;
case GPIO_PORT_F:
return (void *)GPIO_PORTF_AHB_BASE;
case GPIO_PORT_G:
return (void *)GPIO_PORTG_AHB_BASE;
case GPIO_PORT_H:
return (void *)GPIO_PORTH_AHB_BASE;
case GPIO_PORT_J:
return (void *)GPIO_PORTJ_BASE;
case GPIO_PORT_K:
return (void *)GPIO_PORTK_BASE;
case GPIO_PORT_L:
return (void *)GPIO_PORTL_BASE;
case GPIO_PORT_M:
return (void *)GPIO_PORTM_BASE;
case GPIO_PORT_N:
return (void *)GPIO_PORTN_BASE;
case GPIO_PORT_P:
return (void *)GPIO_PORTP_BASE;
case GPIO_PORT_Q:
return (void *)GPIO_PORTQ_BASE;
}
switch (port) {
default:
case GPIO_PORT_A:
return (void *)GPIO_PORTA_AHB_BASE;
case GPIO_PORT_B:
return (void *)GPIO_PORTB_AHB_BASE;
case GPIO_PORT_C:
return (void *)GPIO_PORTC_AHB_BASE;
case GPIO_PORT_D:
return (void *)GPIO_PORTD_AHB_BASE;
case GPIO_PORT_E:
return (void *)GPIO_PORTE_AHB_BASE;
case GPIO_PORT_F:
return (void *)GPIO_PORTF_AHB_BASE;
case GPIO_PORT_G:
return (void *)GPIO_PORTG_AHB_BASE;
case GPIO_PORT_H:
return (void *)GPIO_PORTH_AHB_BASE;
case GPIO_PORT_J:
return (void *)GPIO_PORTJ_BASE;
case GPIO_PORT_K:
return (void *)GPIO_PORTK_BASE;
case GPIO_PORT_L:
return (void *)GPIO_PORTL_BASE;
case GPIO_PORT_M:
return (void *)GPIO_PORTM_BASE;
case GPIO_PORT_N:
return (void *)GPIO_PORTN_BASE;
case GPIO_PORT_P:
return (void *)GPIO_PORTP_BASE;
case GPIO_PORT_Q:
return (void *)GPIO_PORTQ_BASE;
}
}
void stellaris_gpio_early_init(void)
{
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOB);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOC);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOE);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOF);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOG);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOH);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOB);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOC);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOE);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOF);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOG);
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
}
void stellaris_gpio_init(void)
@@ -92,50 +92,50 @@ void stellaris_gpio_init(void)
#if 0
int gpio_config(unsigned nr, unsigned flags)
{
uint port = GPIO_PORT(nr);
uint pin = GPIO_PIN(nr);
uint port = GPIO_PORT(nr);
uint pin = GPIO_PIN(nr);
enable_port(port);
enable_port(port);
GPIO_InitTypeDef init;
init.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitTypeDef init;
init.GPIO_Speed = GPIO_Speed_50MHz;
init.GPIO_Pin = (1 << pin);
init.GPIO_Pin = (1 << pin);
if (flags & GPIO_STM32_AF) {
if (flags & GPIO_STM32_OD)
init.GPIO_Mode = GPIO_Mode_Out_OD;
else
init.GPIO_Mode = GPIO_Mode_AF_PP;
} else if (flags & GPIO_OUTPUT) {
if (flags & GPIO_STM32_OD)
init.GPIO_Mode = GPIO_Mode_Out_OD;
else
init.GPIO_Mode = GPIO_Mode_Out_PP;
} else { // GPIO_INPUT
if (flags & GPIO_PULLUP) {
init.GPIO_Mode = GPIO_Mode_IPU;
} else if (flags & GPIO_PULLDOWN) {
init.GPIO_Mode = GPIO_Mode_IPD;
} else {
init.GPIO_Mode = GPIO_Mode_IN_FLOATING;
}
}
if (flags & GPIO_STM32_AF) {
if (flags & GPIO_STM32_OD)
init.GPIO_Mode = GPIO_Mode_Out_OD;
else
init.GPIO_Mode = GPIO_Mode_AF_PP;
} else if (flags & GPIO_OUTPUT) {
if (flags & GPIO_STM32_OD)
init.GPIO_Mode = GPIO_Mode_Out_OD;
else
init.GPIO_Mode = GPIO_Mode_Out_PP;
} else { // GPIO_INPUT
if (flags & GPIO_PULLUP) {
init.GPIO_Mode = GPIO_Mode_IPU;
} else if (flags & GPIO_PULLDOWN) {
init.GPIO_Mode = GPIO_Mode_IPD;
} else {
init.GPIO_Mode = GPIO_Mode_IN_FLOATING;
}
}
GPIO_Init(port_to_pointer(port), &init);
GPIO_Init(port_to_pointer(port), &init);
return 0;
return 0;
}
#endif
void gpio_set(unsigned nr, unsigned on)
{
GPIOPinWrite((unsigned int)port_to_pointer(GPIO_PORT(nr)), 1 << GPIO_PIN(nr), on ? (1 << GPIO_PIN(nr)) : 0);
GPIOPinWrite((unsigned int)port_to_pointer(GPIO_PORT(nr)), 1 << GPIO_PIN(nr), on ? (1 << GPIO_PIN(nr)) : 0);
}
int gpio_get(unsigned nr)
{
return GPIOPinRead((unsigned int)port_to_pointer(GPIO_PORT(nr)), 1 << GPIO_PIN(nr));
return GPIOPinRead((unsigned int)port_to_pointer(GPIO_PORT(nr)), 1 << GPIO_PIN(nr));
}

View File

@@ -43,51 +43,51 @@ void stellaris_usbc_init(void);
void platform_early_init(void)
{
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
// FPULazyStackingEnable();
//
// Set the clocking to run directly from the crystal.
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
//
// Set the clocking to run directly from the crystal.
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
// start the generic systick timer
arm_cm_systick_init(SysCtlClockGet());
// start the generic systick timer
arm_cm_systick_init(SysCtlClockGet());
stellaris_gpio_early_init();
stellaris_gpio_early_init();
stellaris_debug_early_init();
stellaris_debug_early_init();
stellaris_usbc_early_init();
stellaris_usbc_early_init();
}
void platform_init(void)
{
stellaris_gpio_init();
stellaris_debug_init();
stellaris_usbc_init();
stellaris_gpio_init();
stellaris_debug_init();
stellaris_usbc_init();
// print device information
printf("raw revision registers: 0x%lx 0x%lx\n", HWREG(SYSCTL_DID0), HWREG(SYSCTL_DID1));
// print device information
printf("raw revision registers: 0x%lx 0x%lx\n", HWREG(SYSCTL_DID0), HWREG(SYSCTL_DID1));
printf("stellaris device class: ");
if (CLASS_IS_SANDSTORM) printf("sandstorm");
if (CLASS_IS_FURY) printf("fury");
if (CLASS_IS_DUSTDEVIL) printf("dustdevil");
if (CLASS_IS_TEMPEST) printf("tempst");
if (CLASS_IS_FIRESTORM) printf("firestorm");
if (CLASS_IS_BLIZZARD) printf("blizzard");
printf("\n");
printf("stellaris device class: ");
if (CLASS_IS_SANDSTORM) printf("sandstorm");
if (CLASS_IS_FURY) printf("fury");
if (CLASS_IS_DUSTDEVIL) printf("dustdevil");
if (CLASS_IS_TEMPEST) printf("tempst");
if (CLASS_IS_FIRESTORM) printf("firestorm");
if (CLASS_IS_BLIZZARD) printf("blizzard");
printf("\n");
printf("revision register: ");
uint rev = (HWREG(SYSCTL_DID0) & SYSCTL_DID0_MAJ_M) >> 8;
printf("%c", rev + 'A');
printf("%ld", HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MIN_M));
printf("\n");
printf("revision register: ");
uint rev = (HWREG(SYSCTL_DID0) & SYSCTL_DID0_MAJ_M) >> 8;
printf("%c", rev + 'A');
printf("%ld", HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MIN_M));
printf("\n");
}

View File

@@ -41,44 +41,44 @@ static uint8_t addr;
static void usbc_dump_regs(void)
{
printf("USB0 reg dump:\n");
printf("USB0 reg dump:\n");
#define DUMPREG8(r) printf("\t" #r ": 0x%hhx\n", *REG8(USB0_BASE + (r)));
#define DUMPREG16(r) printf("\t" #r ": 0x%hx\n", *REG16(USB0_BASE + (r)));
#define DUMPREG32(r) printf("\t" #r ": 0x%x\n", *REG32(USB0_BASE + (r)));
DUMPREG8(USB_O_FADDR);
DUMPREG8(USB_O_POWER);
DUMPREG16(USB_O_TXIS);
DUMPREG16(USB_O_RXIS);
DUMPREG16(USB_O_TXIE);
DUMPREG16(USB_O_RXIE);
DUMPREG8(USB_O_IS);
DUMPREG8(USB_O_IE);
DUMPREG16(USB_O_FRAME);
DUMPREG8(USB_O_EPIDX);
DUMPREG8(USB_O_TEST);
DUMPREG32(USB_O_FIFO0);
DUMPREG32(USB_O_FIFO1);
DUMPREG32(USB_O_FIFO2);
DUMPREG32(USB_O_FIFO3);
DUMPREG32(USB_O_FIFO4);
DUMPREG32(USB_O_FIFO5);
DUMPREG32(USB_O_FIFO6);
DUMPREG32(USB_O_FIFO7);
DUMPREG32(USB_O_FIFO8);
DUMPREG32(USB_O_FIFO9);
DUMPREG32(USB_O_FIFO10);
DUMPREG32(USB_O_FIFO11);
DUMPREG32(USB_O_FIFO12);
DUMPREG32(USB_O_FIFO13);
DUMPREG32(USB_O_FIFO14);
DUMPREG32(USB_O_FIFO15);
DUMPREG16(USB_O_DEVCTL);
DUMPREG8(USB_O_TXFIFOSZ);
DUMPREG8(USB_O_RXFIFOSZ);
DUMPREG16(USB_O_TXFIFOADD);
DUMPREG16(USB_O_RXFIFOADD);
DUMPREG32(USB_O_PP);
DUMPREG8(USB_O_FADDR);
DUMPREG8(USB_O_POWER);
DUMPREG16(USB_O_TXIS);
DUMPREG16(USB_O_RXIS);
DUMPREG16(USB_O_TXIE);
DUMPREG16(USB_O_RXIE);
DUMPREG8(USB_O_IS);
DUMPREG8(USB_O_IE);
DUMPREG16(USB_O_FRAME);
DUMPREG8(USB_O_EPIDX);
DUMPREG8(USB_O_TEST);
DUMPREG32(USB_O_FIFO0);
DUMPREG32(USB_O_FIFO1);
DUMPREG32(USB_O_FIFO2);
DUMPREG32(USB_O_FIFO3);
DUMPREG32(USB_O_FIFO4);
DUMPREG32(USB_O_FIFO5);
DUMPREG32(USB_O_FIFO6);
DUMPREG32(USB_O_FIFO7);
DUMPREG32(USB_O_FIFO8);
DUMPREG32(USB_O_FIFO9);
DUMPREG32(USB_O_FIFO10);
DUMPREG32(USB_O_FIFO11);
DUMPREG32(USB_O_FIFO12);
DUMPREG32(USB_O_FIFO13);
DUMPREG32(USB_O_FIFO14);
DUMPREG32(USB_O_FIFO15);
DUMPREG16(USB_O_DEVCTL);
DUMPREG8(USB_O_TXFIFOSZ);
DUMPREG8(USB_O_RXFIFOSZ);
DUMPREG16(USB_O_TXFIFOADD);
DUMPREG16(USB_O_RXFIFOADD);
DUMPREG32(USB_O_PP);
#undef DUMPREG8
#undef DUMPREG16
@@ -87,168 +87,168 @@ static void usbc_dump_regs(void)
void stellaris_usbc_early_init(void)
{
LTRACE_ENTRY;
LTRACE_EXIT;
LTRACE_ENTRY;
LTRACE_EXIT;
}
void stellaris_usbc_init(void)
{
LTRACE_ENTRY;
LTRACE_ENTRY;
SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
SysCtlUSBPLLEnable();
SysCtlUSBPLLEnable();
GPIOPinTypeUSBAnalog(GPIO_PORTD_AHB_BASE, GPIO_PIN_4 | GPIO_PIN_5);
GPIOPinTypeUSBAnalog(GPIO_PORTD_AHB_BASE, GPIO_PIN_4 | GPIO_PIN_5);
USBDevMode(USB0_BASE);
USBPHYPowerOn(USB0_BASE);
USBDevMode(USB0_BASE);
USBPHYPowerOn(USB0_BASE);
#if LOCAL_TRACE
usbc_dump_regs();
usbc_dump_regs();
printf("addr %lu\n", USBDevAddrGet(USB0_BASE));
printf("ep0 status 0x%lx\n", USBEndpointStatus(USB0_BASE, USB_EP_0));
printf("addr %lu\n", USBDevAddrGet(USB0_BASE));
printf("ep0 status 0x%lx\n", USBEndpointStatus(USB0_BASE, USB_EP_0));
#endif
NVIC_EnableIRQ(INT_USB0 - 16);
USBIntDisableControl(USB0_BASE, USB_INTCTRL_ALL);
NVIC_EnableIRQ(INT_USB0 - 16);
USBIntDisableControl(USB0_BASE, USB_INTCTRL_ALL);
LTRACE_EXIT;
LTRACE_EXIT;
}
static void ep0_irq(void)
{
uint status = USBEndpointStatus(USB0_BASE, USB_EP_0);
uint status = USBEndpointStatus(USB0_BASE, USB_EP_0);
LTRACEF("ep0 status 0x%x\n", status);
LTRACEF("ep0 status 0x%x\n", status);
/* delay setting the address until the ack as completed */
if (pending_addr_change) {
LTRACEF("pending addr change\n");
USBDevAddrSet(USB0_BASE, addr);
pending_addr_change = false;
}
/* delay setting the address until the ack as completed */
if (pending_addr_change) {
LTRACEF("pending addr change\n");
USBDevAddrSet(USB0_BASE, addr);
pending_addr_change = false;
}
if (status & USB_DEV_EP0_OUT_PKTRDY) {
LTRACEF("pktrdy\n");
if (status & USB_DEV_EP0_OUT_PKTRDY) {
LTRACEF("pktrdy\n");
uchar buf[sizeof(struct usb_setup)];
ulong avail = sizeof(buf);
uchar buf[sizeof(struct usb_setup)];
ulong avail = sizeof(buf);
if (USBEndpointDataGet(USB0_BASE, USB_EP_0, buf, &avail) < 0 || avail != sizeof(buf)) {
LTRACEF("short setup packet, size %lu\n", avail);
} else {
union usb_callback_args args;
args.setup = (void *)buf;
usbc_callback(USB_CB_SETUP_MSG, &args);
}
}
if (status & USB_DEV_EP0_SENT_STALL) {
LTRACEF("stall complete\n");
USBDevEndpointStallClear(USB0_BASE, USB_EP_0, 0);
}
if (USBEndpointDataGet(USB0_BASE, USB_EP_0, buf, &avail) < 0 || avail != sizeof(buf)) {
LTRACEF("short setup packet, size %lu\n", avail);
} else {
union usb_callback_args args;
args.setup = (void *)buf;
usbc_callback(USB_CB_SETUP_MSG, &args);
}
}
if (status & USB_DEV_EP0_SENT_STALL) {
LTRACEF("stall complete\n");
USBDevEndpointStallClear(USB0_BASE, USB_EP_0, 0);
}
}
void stellaris_usb0_irq(void)
{
arm_cm_irq_entry();
arm_cm_irq_entry();
uint status = USBIntStatusControl(USB0_BASE);
uint status = USBIntStatusControl(USB0_BASE);
//LTRACEF("usb irq, status 0x%x\n", status);
//LTRACEF("usb irq, status 0x%x\n", status);
if (status & USB_INTCTRL_RESET) {
// reset
LTRACEF("reset\n");
pending_addr_change = false;
usbc_callback(USB_CB_RESET, NULL);
}
if (status & USB_INTCTRL_CONNECT) {
// reset
LTRACEF("connect\n");
}
if (status & USB_INTCTRL_RESET) {
// reset
LTRACEF("reset\n");
pending_addr_change = false;
usbc_callback(USB_CB_RESET, NULL);
}
if (status & USB_INTCTRL_CONNECT) {
// reset
LTRACEF("connect\n");
}
status = USBIntStatusEndpoint(USB0_BASE);
status = USBIntStatusEndpoint(USB0_BASE);
if (status & USB_INTEP_0) {
// ep0
//LTRACEF("ep0\n");
ep0_irq();
}
if (status & USB_INTEP_0) {
// ep0
//LTRACEF("ep0\n");
ep0_irq();
}
arm_cm_irq_exit(true);
arm_cm_irq_exit(true);
}
void usbc_ep0_ack(void)
{
LTRACE_ENTRY;
LTRACE_ENTRY;
USBDevEndpointDataAck(USB0_BASE, USB_EP_0, true);
USBDevEndpointDataAck(USB0_BASE, USB_EP_0, true);
}
void usbc_ep0_stall(void)
{
LTRACE_ENTRY;
LTRACE_ENTRY;
USBDevEndpointStall(USB0_BASE, USB_EP_0, 0);
USBDevEndpointStall(USB0_BASE, USB_EP_0, 0);
}
void usbc_ep0_send(const void *buf, size_t len, size_t maxlen)
{
LTRACEF("buf %p, len %zu, maxlen %zu\n", buf, len, maxlen);
LTRACEF("buf %p, len %zu, maxlen %zu\n", buf, len, maxlen);
USBEndpointDataPut(USB0_BASE, USB_EP_0, (void *)buf, MIN(len, maxlen));
USBEndpointDataPut(USB0_BASE, USB_EP_0, (void *)buf, MIN(len, maxlen));
USBEndpointDataSend(USB0_BASE, USB_EP_0, USB_TRANS_SETUP);
USBEndpointDataSend(USB0_BASE, USB_EP_0, USB_TRANS_SETUP);
}
void usbc_set_address(uint8_t address)
{
LTRACEF("address 0x%hhx\n", address);
LTRACEF("address 0x%hhx\n", address);
addr = address;
pending_addr_change = true;
addr = address;
pending_addr_change = true;
}
void usbc_ep0_recv(void *buf, size_t len, ep_callback cb)
{
PANIC_UNIMPLEMENTED;
PANIC_UNIMPLEMENTED;
}
bool usbc_is_highspeed(void)
{
return false;
return false;
}
status_t usbc_set_active(bool active)
{
LTRACEF("active %d\n", active);
if (active) {
USBIntEnableControl(USB0_BASE, USB_INTCTRL_CONNECT | USB_INTCTRL_RESET);
USBIntEnableEndpoint(USB0_BASE, USB_INTEP_0);
USBDevConnect(USB0_BASE);
} else {
USBDevDisconnect(USB0_BASE);
}
LTRACEF("active %d\n", active);
if (active) {
USBIntEnableControl(USB0_BASE, USB_INTCTRL_CONNECT | USB_INTCTRL_RESET);
USBIntEnableEndpoint(USB0_BASE, USB_INTEP_0);
USBDevConnect(USB0_BASE);
} else {
USBDevDisconnect(USB0_BASE);
}
return NO_ERROR;
return NO_ERROR;
}
status_t usbc_setup_endpoint(ep_t ep, ep_dir_t dir, uint width)
{
PANIC_UNIMPLEMENTED;
PANIC_UNIMPLEMENTED;
}
status_t usbc_queue_rx(ep_t ep, usbc_transfer_t *transfer)
{
PANIC_UNIMPLEMENTED;
PANIC_UNIMPLEMENTED;
}
status_t usbc_queue_tx(ep_t ep, usbc_transfer_t *transfer)
{
PANIC_UNIMPLEMENTED;
PANIC_UNIMPLEMENTED;
}
// vim: set ts=4 sw=4 noexpandtab:

View File

@@ -28,9 +28,9 @@
/* un-overridden irq handler */
void stellaris_dummy_irq(void)
{
arm_cm_irq_entry();
arm_cm_irq_entry();
panic("unhandled irq\n");
panic("unhandled irq\n");
}
extern void stellaris_uart_irq(void);
@@ -156,146 +156,146 @@ DEFAULT_HANDLER(pwm1_fault);
#define VECTAB_ENTRY(x) stellaris_##x##_irq
const void * const __SECTION(".text.boot.vectab2") vectab2[] = {
VECTAB_ENTRY(gpio_porta), // GPIO Port A
VECTAB_ENTRY(gpio_portb), // GPIO Port B
VECTAB_ENTRY(gpio_portc), // GPIO Port C
VECTAB_ENTRY(gpio_portd), // GPIO Port D
VECTAB_ENTRY(gpio_porte), // GPIO Port E
VECTAB_ENTRY(uart0), // UART0 Rx and Tx
VECTAB_ENTRY(uart1), // UART1 Rx and Tx
VECTAB_ENTRY(ssi0), // SSI0 Rx and Tx
VECTAB_ENTRY(i2c0), // I2C0 Master and Slave
VECTAB_ENTRY(pwm_fault), // PWM Fault
VECTAB_ENTRY(pwm_gen0), // PWM Generator 0
VECTAB_ENTRY(pwm_gen1), // PWM Generator 1
VECTAB_ENTRY(pwm_gen2), // PWM Generator 2
VECTAB_ENTRY(quad_encoder0), // Quadrature Encoder 0
VECTAB_ENTRY(adc_seq0), // ADC Sequence 0
VECTAB_ENTRY(adc_seq1), // ADC Sequence 1
VECTAB_ENTRY(adc_seq2), // ADC Sequence 2
VECTAB_ENTRY(adc_seq3), // ADC Sequence 3
VECTAB_ENTRY(watchdog_timer), // Watchdog timer
VECTAB_ENTRY(timer0_subtimerA), // Timer 0 subtimer A
VECTAB_ENTRY(timer0_subtimerB), // Timer 0 subtimer B
VECTAB_ENTRY(timer1_subtimerA), // Timer 1 subtimer A
VECTAB_ENTRY(timer1_subtimerB), // Timer 1 subtimer B
VECTAB_ENTRY(timer2_subtimerA), // Timer 2 subtimer A
VECTAB_ENTRY(timer2_subtimerB), // Timer 2 subtimer B
VECTAB_ENTRY(analog_comp0), // Analog Comparator 0
VECTAB_ENTRY(analog_comp1), // Analog Comparator 1
VECTAB_ENTRY(analog_comp2), // Analog Comparator 2
VECTAB_ENTRY(sys_control), // System Control (PLL, OSC, BO)
VECTAB_ENTRY(flash_control), // FLASH Control
VECTAB_ENTRY(gpio_portf), // GPIO Port F
VECTAB_ENTRY(gpio_portg), // GPIO Port G
VECTAB_ENTRY(gpio_porth), // GPIO Port H
VECTAB_ENTRY(uart2), // UART2 Rx and Tx
VECTAB_ENTRY(ssi1), // SSI1 Rx and Tx
VECTAB_ENTRY(timer3_subtimerA), // Timer 3 subtimer A
VECTAB_ENTRY(timer3_subtimerB), // Timer 3 subtimer B
VECTAB_ENTRY(i2c1), // I2C1 Master and Slave
VECTAB_ENTRY(quad_encoder1), // Quadrature Encoder 1
VECTAB_ENTRY(can0), // CAN0
VECTAB_ENTRY(can1), // CAN1
VECTAB_ENTRY(can2), // CAN2
VECTAB_ENTRY(ethernet), // Ethernet
VECTAB_ENTRY(hibernate), // Hibernate
VECTAB_ENTRY(usb0), // USB0
VECTAB_ENTRY(pwm_gen3), // PWM Generator 3
VECTAB_ENTRY(udma_software), // uDMA Software Transfer
VECTAB_ENTRY(udma_error), // uDMA Error
VECTAB_ENTRY(ad1_seq0), // ADC1 Sequence 0
VECTAB_ENTRY(ad1_seq1), // ADC1 Sequence 1
VECTAB_ENTRY(ad1_seq2), // ADC1 Sequence 2
VECTAB_ENTRY(ad1_seq3), // ADC1 Sequence 3
VECTAB_ENTRY(i2s0), // I2S0
VECTAB_ENTRY(ext_bus0), // External Bus Interface 0
VECTAB_ENTRY(gpio_portj), // GPIO Port J
VECTAB_ENTRY(gpio_portk), // GPIO Port K
VECTAB_ENTRY(gpio_portl), // GPIO Port L
VECTAB_ENTRY(ssi2), // SSI2 Rx and Tx
VECTAB_ENTRY(ssi3), // SSI3 Rx and Tx
VECTAB_ENTRY(uart3), // UART3 Rx and Tx
VECTAB_ENTRY(uart4), // UART4 Rx and Tx
VECTAB_ENTRY(uart5), // UART5 Rx and Tx
VECTAB_ENTRY(uart6), // UART6 Rx and Tx
VECTAB_ENTRY(uart7), // UART7 Rx and Tx
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(i2c2), // I2C2 Master and Slave
VECTAB_ENTRY(i2c3), // I2C3 Master and Slave
VECTAB_ENTRY(timer4_subtimerA), // Timer 4 subtimer A
VECTAB_ENTRY(timer4_subtimerB), // Timer 4 subtimer B
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(timer5_subtimerA), // Timer 5 subtimer A
VECTAB_ENTRY(timer5_subtimerB), // Timer 5 subtimer B
VECTAB_ENTRY(wide_timer0_subtimerA), // Wide Timer 0 subtimer A
VECTAB_ENTRY(wide_timer0_subtimerB), // Wide Timer 0 subtimer B
VECTAB_ENTRY(wide_timer1_subtimerA), // Wide Timer 1 subtimer A
VECTAB_ENTRY(wide_timer1_subtimerB), // Wide Timer 1 subtimer B
VECTAB_ENTRY(wide_timer2_subtimerA), // Wide Timer 2 subtimer A
VECTAB_ENTRY(wide_timer2_subtimerB), // Wide Timer 2 subtimer B
VECTAB_ENTRY(wide_timer3_subtimerA), // Wide Timer 3 subtimer A
VECTAB_ENTRY(wide_timer3_subtimerB), // Wide Timer 3 subtimer B
VECTAB_ENTRY(wide_timer4_subtimerA), // Wide Timer 4 subtimer A
VECTAB_ENTRY(wide_timer4_subtimerB), // Wide Timer 4 subtimer B
VECTAB_ENTRY(wide_timer5_subtimerA), // Wide Timer 5 subtimer A
VECTAB_ENTRY(wide_timer6_subtimerB), // Wide Timer 5 subtimer B
VECTAB_ENTRY(fpu), // FPU
VECTAB_ENTRY(peci0), // PECI 0
VECTAB_ENTRY(lpc0), // LPC 0
VECTAB_ENTRY(i2c4), // I2C4 Master and Slave
VECTAB_ENTRY(i2c5), // I2C5 Master and Slave
VECTAB_ENTRY(gpio_portm), // GPIO Port M
VECTAB_ENTRY(gpio_portn), // GPIO Port N
VECTAB_ENTRY(quad_encoder2), // Quadrature Encoder 2
VECTAB_ENTRY(fan0), // Fan 0
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(gpio_portp0), // GPIO Port P (Summary or P0)
VECTAB_ENTRY(gpio_portp1), // GPIO Port P1
VECTAB_ENTRY(gpio_portp2), // GPIO Port P2
VECTAB_ENTRY(gpio_portp3), // GPIO Port P3
VECTAB_ENTRY(gpio_portp4), // GPIO Port P4
VECTAB_ENTRY(gpio_portp5), // GPIO Port P5
VECTAB_ENTRY(gpio_portp6), // GPIO Port P6
VECTAB_ENTRY(gpio_portp7), // GPIO Port P7
VECTAB_ENTRY(gpio_portq0), // GPIO Port Q (Summary or Q0)
VECTAB_ENTRY(gpio_portq1), // GPIO Port Q1
VECTAB_ENTRY(gpio_portq2), // GPIO Port Q2
VECTAB_ENTRY(gpio_portq3), // GPIO Port Q3
VECTAB_ENTRY(gpio_portq4), // GPIO Port Q4
VECTAB_ENTRY(gpio_portq5), // GPIO Port Q5
VECTAB_ENTRY(gpio_portq6), // GPIO Port Q6
VECTAB_ENTRY(gpio_portq7), // GPIO Port Q7
VECTAB_ENTRY(gpio_portr), // GPIO Port R
VECTAB_ENTRY(gpio_ports), // GPIO Port S
VECTAB_ENTRY(pwm1_gen0), // PWM 1 Generator 0
VECTAB_ENTRY(pwm1_gen1), // PWM 1 Generator 1
VECTAB_ENTRY(pwm1_gen2), // PWM 1 Generator 2
VECTAB_ENTRY(pwm1_gen3), // PWM 1 Generator 3
VECTAB_ENTRY(pwm1_fault) // PWM 1 Fault
const void *const __SECTION(".text.boot.vectab2") vectab2[] = {
VECTAB_ENTRY(gpio_porta), // GPIO Port A
VECTAB_ENTRY(gpio_portb), // GPIO Port B
VECTAB_ENTRY(gpio_portc), // GPIO Port C
VECTAB_ENTRY(gpio_portd), // GPIO Port D
VECTAB_ENTRY(gpio_porte), // GPIO Port E
VECTAB_ENTRY(uart0), // UART0 Rx and Tx
VECTAB_ENTRY(uart1), // UART1 Rx and Tx
VECTAB_ENTRY(ssi0), // SSI0 Rx and Tx
VECTAB_ENTRY(i2c0), // I2C0 Master and Slave
VECTAB_ENTRY(pwm_fault), // PWM Fault
VECTAB_ENTRY(pwm_gen0), // PWM Generator 0
VECTAB_ENTRY(pwm_gen1), // PWM Generator 1
VECTAB_ENTRY(pwm_gen2), // PWM Generator 2
VECTAB_ENTRY(quad_encoder0), // Quadrature Encoder 0
VECTAB_ENTRY(adc_seq0), // ADC Sequence 0
VECTAB_ENTRY(adc_seq1), // ADC Sequence 1
VECTAB_ENTRY(adc_seq2), // ADC Sequence 2
VECTAB_ENTRY(adc_seq3), // ADC Sequence 3
VECTAB_ENTRY(watchdog_timer), // Watchdog timer
VECTAB_ENTRY(timer0_subtimerA), // Timer 0 subtimer A
VECTAB_ENTRY(timer0_subtimerB), // Timer 0 subtimer B
VECTAB_ENTRY(timer1_subtimerA), // Timer 1 subtimer A
VECTAB_ENTRY(timer1_subtimerB), // Timer 1 subtimer B
VECTAB_ENTRY(timer2_subtimerA), // Timer 2 subtimer A
VECTAB_ENTRY(timer2_subtimerB), // Timer 2 subtimer B
VECTAB_ENTRY(analog_comp0), // Analog Comparator 0
VECTAB_ENTRY(analog_comp1), // Analog Comparator 1
VECTAB_ENTRY(analog_comp2), // Analog Comparator 2
VECTAB_ENTRY(sys_control), // System Control (PLL, OSC, BO)
VECTAB_ENTRY(flash_control), // FLASH Control
VECTAB_ENTRY(gpio_portf), // GPIO Port F
VECTAB_ENTRY(gpio_portg), // GPIO Port G
VECTAB_ENTRY(gpio_porth), // GPIO Port H
VECTAB_ENTRY(uart2), // UART2 Rx and Tx
VECTAB_ENTRY(ssi1), // SSI1 Rx and Tx
VECTAB_ENTRY(timer3_subtimerA), // Timer 3 subtimer A
VECTAB_ENTRY(timer3_subtimerB), // Timer 3 subtimer B
VECTAB_ENTRY(i2c1), // I2C1 Master and Slave
VECTAB_ENTRY(quad_encoder1), // Quadrature Encoder 1
VECTAB_ENTRY(can0), // CAN0
VECTAB_ENTRY(can1), // CAN1
VECTAB_ENTRY(can2), // CAN2
VECTAB_ENTRY(ethernet), // Ethernet
VECTAB_ENTRY(hibernate), // Hibernate
VECTAB_ENTRY(usb0), // USB0
VECTAB_ENTRY(pwm_gen3), // PWM Generator 3
VECTAB_ENTRY(udma_software), // uDMA Software Transfer
VECTAB_ENTRY(udma_error), // uDMA Error
VECTAB_ENTRY(ad1_seq0), // ADC1 Sequence 0
VECTAB_ENTRY(ad1_seq1), // ADC1 Sequence 1
VECTAB_ENTRY(ad1_seq2), // ADC1 Sequence 2
VECTAB_ENTRY(ad1_seq3), // ADC1 Sequence 3
VECTAB_ENTRY(i2s0), // I2S0
VECTAB_ENTRY(ext_bus0), // External Bus Interface 0
VECTAB_ENTRY(gpio_portj), // GPIO Port J
VECTAB_ENTRY(gpio_portk), // GPIO Port K
VECTAB_ENTRY(gpio_portl), // GPIO Port L
VECTAB_ENTRY(ssi2), // SSI2 Rx and Tx
VECTAB_ENTRY(ssi3), // SSI3 Rx and Tx
VECTAB_ENTRY(uart3), // UART3 Rx and Tx
VECTAB_ENTRY(uart4), // UART4 Rx and Tx
VECTAB_ENTRY(uart5), // UART5 Rx and Tx
VECTAB_ENTRY(uart6), // UART6 Rx and Tx
VECTAB_ENTRY(uart7), // UART7 Rx and Tx
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(i2c2), // I2C2 Master and Slave
VECTAB_ENTRY(i2c3), // I2C3 Master and Slave
VECTAB_ENTRY(timer4_subtimerA), // Timer 4 subtimer A
VECTAB_ENTRY(timer4_subtimerB), // Timer 4 subtimer B
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(timer5_subtimerA), // Timer 5 subtimer A
VECTAB_ENTRY(timer5_subtimerB), // Timer 5 subtimer B
VECTAB_ENTRY(wide_timer0_subtimerA), // Wide Timer 0 subtimer A
VECTAB_ENTRY(wide_timer0_subtimerB), // Wide Timer 0 subtimer B
VECTAB_ENTRY(wide_timer1_subtimerA), // Wide Timer 1 subtimer A
VECTAB_ENTRY(wide_timer1_subtimerB), // Wide Timer 1 subtimer B
VECTAB_ENTRY(wide_timer2_subtimerA), // Wide Timer 2 subtimer A
VECTAB_ENTRY(wide_timer2_subtimerB), // Wide Timer 2 subtimer B
VECTAB_ENTRY(wide_timer3_subtimerA), // Wide Timer 3 subtimer A
VECTAB_ENTRY(wide_timer3_subtimerB), // Wide Timer 3 subtimer B
VECTAB_ENTRY(wide_timer4_subtimerA), // Wide Timer 4 subtimer A
VECTAB_ENTRY(wide_timer4_subtimerB), // Wide Timer 4 subtimer B
VECTAB_ENTRY(wide_timer5_subtimerA), // Wide Timer 5 subtimer A
VECTAB_ENTRY(wide_timer6_subtimerB), // Wide Timer 5 subtimer B
VECTAB_ENTRY(fpu), // FPU
VECTAB_ENTRY(peci0), // PECI 0
VECTAB_ENTRY(lpc0), // LPC 0
VECTAB_ENTRY(i2c4), // I2C4 Master and Slave
VECTAB_ENTRY(i2c5), // I2C5 Master and Slave
VECTAB_ENTRY(gpio_portm), // GPIO Port M
VECTAB_ENTRY(gpio_portn), // GPIO Port N
VECTAB_ENTRY(quad_encoder2), // Quadrature Encoder 2
VECTAB_ENTRY(fan0), // Fan 0
VECTAB_ENTRY(dummy), // Reserved
VECTAB_ENTRY(gpio_portp0), // GPIO Port P (Summary or P0)
VECTAB_ENTRY(gpio_portp1), // GPIO Port P1
VECTAB_ENTRY(gpio_portp2), // GPIO Port P2
VECTAB_ENTRY(gpio_portp3), // GPIO Port P3
VECTAB_ENTRY(gpio_portp4), // GPIO Port P4
VECTAB_ENTRY(gpio_portp5), // GPIO Port P5
VECTAB_ENTRY(gpio_portp6), // GPIO Port P6
VECTAB_ENTRY(gpio_portp7), // GPIO Port P7
VECTAB_ENTRY(gpio_portq0), // GPIO Port Q (Summary or Q0)
VECTAB_ENTRY(gpio_portq1), // GPIO Port Q1
VECTAB_ENTRY(gpio_portq2), // GPIO Port Q2
VECTAB_ENTRY(gpio_portq3), // GPIO Port Q3
VECTAB_ENTRY(gpio_portq4), // GPIO Port Q4
VECTAB_ENTRY(gpio_portq5), // GPIO Port Q5
VECTAB_ENTRY(gpio_portq6), // GPIO Port Q6
VECTAB_ENTRY(gpio_portq7), // GPIO Port Q7
VECTAB_ENTRY(gpio_portr), // GPIO Port R
VECTAB_ENTRY(gpio_ports), // GPIO Port S
VECTAB_ENTRY(pwm1_gen0), // PWM 1 Generator 0
VECTAB_ENTRY(pwm1_gen1), // PWM 1 Generator 1
VECTAB_ENTRY(pwm1_gen2), // PWM 1 Generator 2
VECTAB_ENTRY(pwm1_gen3), // PWM 1 Generator 3
VECTAB_ENTRY(pwm1_fault) // PWM 1 Fault
};
// vim: ts=4 sw=4 noexpandtab: