Add timer1 on pi4 for blinky
this get usb irq triggered even without ISB() in previous commit
This commit is contained in:
parent
b51d038b65
commit
4a8ac71711
|
@ -35,7 +35,7 @@ The stack supports the following MCUs:
|
||||||
- **Dialog:** DA1469x
|
- **Dialog:** DA1469x
|
||||||
- **Espressif:** ESP32-S2, ESP32-S3
|
- **Espressif:** ESP32-S2, ESP32-S3
|
||||||
- **MicroChip:** SAMD11, SAMD21, SAMD51, SAME5x, SAMG55, SAML21, SAML22, SAME7x
|
- **MicroChip:** SAMD11, SAMD21, SAMD51, SAME5x, SAMG55, SAML21, SAML22, SAME7x
|
||||||
- **NordicSemi:** nRF52833, nRF52840
|
- **NordicSemi:** nRF52833, nRF52840, nRF5340
|
||||||
- **Nuvoton:** NUC120, NUC121/NUC125, NUC126, NUC505
|
- **Nuvoton:** NUC120, NUC121/NUC125, NUC126, NUC505
|
||||||
- **NXP:**
|
- **NXP:**
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ The stack supports the following MCUs:
|
||||||
|
|
||||||
- **Raspberry Pi:** RP2040
|
- **Raspberry Pi:** RP2040
|
||||||
- **Renesas:** RX63N, RX65N
|
- **Renesas:** RX63N, RX65N
|
||||||
- **Silabs:** EFM32GG12
|
- **Silabs:** EFM32GG
|
||||||
- **Sony:** CXD56
|
- **Sony:** CXD56
|
||||||
- **ST:** STM32 series: L0, L1, L4, F0, F1, F2, F3, F4, F7, H7 both FullSpeed and HighSpeed
|
- **ST:** STM32 series: L0, L1, L4, L4+, F0, F1, F2, F3, F4, F7, H7
|
||||||
- **TI:** MSP430
|
- **TI:** MSP430
|
||||||
- **ValentyUSB:** eptri
|
- **ValentyUSB:** eptri
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,14 @@
|
||||||
#include "broadcom/caches.h"
|
#include "broadcom/caches.h"
|
||||||
#include "broadcom/vcmailbox.h"
|
#include "broadcom/vcmailbox.h"
|
||||||
|
|
||||||
|
// LED
|
||||||
|
#define LED_PIN 18
|
||||||
|
#define LED_STATE_ON 1
|
||||||
|
|
||||||
|
// Button
|
||||||
|
#define BUTTON_PIN 16
|
||||||
|
#define BUTTON_STATE_ACTIVE 0
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -50,63 +58,27 @@ void USB_IRQHandler(void)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void board_init(void)
|
void board_init(void)
|
||||||
{
|
{
|
||||||
gpio_initOutputPinWithPullNone(18);
|
|
||||||
gpio_initOutputPinWithPullNone(19);
|
|
||||||
gpio_initOutputPinWithPullNone(20);
|
|
||||||
gpio_initOutputPinWithPullNone(21);
|
|
||||||
gpio_setPinOutputBool(18, true);
|
|
||||||
gpio_initOutputPinWithPullNone(42);
|
|
||||||
setup_mmu_flat_map();
|
setup_mmu_flat_map();
|
||||||
init_caches();
|
init_caches();
|
||||||
|
|
||||||
// gpio_initOutputPinWithPullNone(23);
|
// LED
|
||||||
// gpio_initOutputPinWithPullNone(24);
|
gpio_initOutputPinWithPullNone(LED_PIN);
|
||||||
// gpio_initOutputPinWithPullNone(25);
|
board_led_write(true);
|
||||||
gpio_setPinOutputBool(18, false);
|
|
||||||
|
// Button
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
// Uart
|
||||||
uart_init();
|
uart_init();
|
||||||
gpio_setPinOutputBool(18, true);
|
|
||||||
gpio_setPinOutputBool(18, false);
|
|
||||||
for (size_t i = 0; i < 5; i++) {
|
|
||||||
// while (true) {
|
|
||||||
for (size_t j = 0; j < 1000000; j++) {
|
|
||||||
__asm__("nop");
|
|
||||||
}
|
|
||||||
gpio_setPinOutputBool(42, true);
|
|
||||||
gpio_setPinOutputBool(18, true);
|
|
||||||
gpio_setPinOutputBool(19, true);
|
|
||||||
gpio_setPinOutputBool(20, true);
|
|
||||||
gpio_setPinOutputBool(21, true);
|
|
||||||
for (size_t j = 0; j < 1000000; j++) {
|
|
||||||
__asm__("nop");
|
|
||||||
}
|
|
||||||
gpio_setPinOutputBool(42, false);
|
|
||||||
gpio_setPinOutputBool(18, false);
|
|
||||||
gpio_setPinOutputBool(19, false);
|
|
||||||
gpio_setPinOutputBool(20, false);
|
|
||||||
gpio_setPinOutputBool(21, false);
|
|
||||||
}
|
|
||||||
// uart_writeText("hello from io\n");
|
|
||||||
// gpio_setPinOutputBool(24, true);
|
|
||||||
// gpio_setPinOutputBool(24, false);
|
|
||||||
// gpio_setPinOutputBool(25, true);
|
|
||||||
// print();
|
|
||||||
// gpio_setPinOutputBool(25, false);
|
|
||||||
// while (true) {
|
|
||||||
// // for (size_t i = 0; i < 5; i++) {
|
|
||||||
// for (size_t j = 0; j < 10000000000; j++) {
|
|
||||||
// __asm__("nop");
|
|
||||||
// }
|
|
||||||
// gpio_setPinOutputBool(42, true);
|
|
||||||
// for (size_t j = 0; j < 10000000000; j++) {
|
|
||||||
// __asm__("nop");
|
|
||||||
// }
|
|
||||||
// gpio_setPinOutputBool(42, false);
|
|
||||||
// }
|
|
||||||
// while (1) uart_update();
|
|
||||||
|
|
||||||
// Turn on USB peripheral.
|
// Turn on USB peripheral.
|
||||||
vcmailbox_set_power_state(VCMAILBOX_DEVICE_USB_HCD, true);
|
vcmailbox_set_power_state(VCMAILBOX_DEVICE_USB_HCD, true);
|
||||||
|
|
||||||
|
// Timer 1/1024 second tick
|
||||||
|
SYSTMR->CS_b.M1 = 1;
|
||||||
|
SYSTMR->C1 = SYSTMR->CLO + 977;
|
||||||
|
BP_EnableIRQ(TIMER_1_IRQn);
|
||||||
|
|
||||||
BP_SetPriority(USB_IRQn, 0x00);
|
BP_SetPriority(USB_IRQn, 0x00);
|
||||||
BP_ClearPendingIRQ(USB_IRQn);
|
BP_ClearPendingIRQ(USB_IRQn);
|
||||||
BP_EnableIRQ(USB_IRQn);
|
BP_EnableIRQ(USB_IRQn);
|
||||||
|
@ -115,7 +87,7 @@ void board_init(void)
|
||||||
|
|
||||||
void board_led_write(bool state)
|
void board_led_write(bool state)
|
||||||
{
|
{
|
||||||
gpio_setPinOutputBool(42, state);
|
gpio_setPinOutputBool(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_button_read(void)
|
uint32_t board_button_read(void)
|
||||||
|
@ -145,9 +117,12 @@ int board_uart_write(void const * buf, int len)
|
||||||
|
|
||||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||||
volatile uint32_t system_ticks = 0;
|
volatile uint32_t system_ticks = 0;
|
||||||
void SysTick_Handler (void)
|
|
||||||
|
void TIMER_1_IRQHandler(void)
|
||||||
{
|
{
|
||||||
system_ticks++;
|
system_ticks++;
|
||||||
|
SYSTMR->C1 += 977;
|
||||||
|
SYSTMR->CS_b.M1 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_millis(void)
|
uint32_t board_millis(void)
|
||||||
|
|
|
@ -48,4 +48,4 @@ $(BUILD)/kernel8.img: $(BUILD)/$(PROJECT).elf
|
||||||
# Copy to kernel to netboot drive or SD card
|
# Copy to kernel to netboot drive or SD card
|
||||||
# Change destinaation to fit your need
|
# Change destinaation to fit your need
|
||||||
flash: $(BUILD)/kernel8.img
|
flash: $(BUILD)/kernel8.img
|
||||||
@$(CP) $< /home/$(USER)/Documents/code/pi4_tinyusb/boot_cpy
|
$(CP) $< /home/$(USER)/Documents/code/pi4_tinyusb/boot_cpy
|
||||||
|
|
Loading…
Reference in New Issue