summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-11-04 12:31:16 +0700
committerhathach <[email protected]>2021-11-04 12:31:16 +0700
commit4a8ac71711a70ccb122fdb59d731dc01cfed1464 (patch)
tree098a97ef5a9441c255324211d646839a728f583f
parentb51d038b656688b6150470d23752a306ee150da3 (diff)
Add timer1 on pi4 for blinky
this get usb irq triggered even without ISB() in previous commit
-rw-r--r--README.rst6
-rw-r--r--hw/bsp/raspberrypi4/family.c77
-rw-r--r--hw/bsp/raspberrypi4/family.mk2
3 files changed, 30 insertions, 55 deletions
diff --git a/README.rst b/README.rst
index 329c0da53..1db022fc8 100644
--- a/README.rst
+++ b/README.rst
@@ -35,7 +35,7 @@ The stack supports the following MCUs:
- **Dialog:** DA1469x
- **Espressif:** ESP32-S2, ESP32-S3
- **MicroChip:** SAMD11, SAMD21, SAMD51, SAME5x, SAMG55, SAML21, SAML22, SAME7x
-- **NordicSemi:** nRF52833, nRF52840
+- **NordicSemi:** nRF52833, nRF52840, nRF5340
- **Nuvoton:** NUC120, NUC121/NUC125, NUC126, NUC505
- **NXP:**
@@ -45,9 +45,9 @@ The stack supports the following MCUs:
- **Raspberry Pi:** RP2040
- **Renesas:** RX63N, RX65N
-- **Silabs:** EFM32GG12
+- **Silabs:** EFM32GG
- **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
- **ValentyUSB:** eptri
diff --git a/hw/bsp/raspberrypi4/family.c b/hw/bsp/raspberrypi4/family.c
index 7a7a0e9ff..ba0b2700a 100644
--- a/hw/bsp/raspberrypi4/family.c
+++ b/hw/bsp/raspberrypi4/family.c
@@ -33,6 +33,14 @@
#include "broadcom/caches.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
//--------------------------------------------------------------------+
@@ -50,63 +58,27 @@ void USB_IRQHandler(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();
init_caches();
- // gpio_initOutputPinWithPullNone(23);
- // gpio_initOutputPinWithPullNone(24);
- // gpio_initOutputPinWithPullNone(25);
- gpio_setPinOutputBool(18, false);
+ // LED
+ gpio_initOutputPinWithPullNone(LED_PIN);
+ board_led_write(true);
+
+ // Button
+ // TODO
+
+ // Uart
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.
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_ClearPendingIRQ(USB_IRQn);
BP_EnableIRQ(USB_IRQn);
@@ -115,7 +87,7 @@ void board_init(void)
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)
@@ -145,9 +117,12 @@ int board_uart_write(void const * buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
-void SysTick_Handler (void)
+
+void TIMER_1_IRQHandler(void)
{
system_ticks++;
+ SYSTMR->C1 += 977;
+ SYSTMR->CS_b.M1 = 1;
}
uint32_t board_millis(void)
diff --git a/hw/bsp/raspberrypi4/family.mk b/hw/bsp/raspberrypi4/family.mk
index 475cfa4ff..c65070a71 100644
--- a/hw/bsp/raspberrypi4/family.mk
+++ b/hw/bsp/raspberrypi4/family.mk
@@ -48,4 +48,4 @@ $(BUILD)/kernel8.img: $(BUILD)/$(PROJECT).elf
# Copy to kernel to netboot drive or SD card
# Change destinaation to fit your need
flash: $(BUILD)/kernel8.img
- @$(CP) $< /home/$(USER)/Documents/code/pi4_tinyusb/boot_cpy
+ $(CP) $< /home/$(USER)/Documents/code/pi4_tinyusb/boot_cpy