Commit Graph

26 Commits

Author SHA1 Message Date
Doug Brown 0b88f61542 Mark the M258KE board as having pulldown support 2023-09-10 05:02:44 -07:00
Doug Brown c6313d0859 Hook up pulldowns in M258KE ParallelBus implementation 2023-09-10 05:02:44 -07:00
Doug Brown a4e6cf4809 Add support for GPIO pulldown control
Note that it does nothing on the AVR, which doesn't support it.
2023-09-10 05:02:44 -07:00
Doug Brown a5087e16f6 Add cmake source/options includes for M258KE port 2023-09-10 05:02:44 -07:00
Doug Brown d14ca13dd8 Disable watchdog timer when the firmware boots
If it gets this far, the firmware is at least sort of running, so the
watchdog has served its purpose of resetting to the bootloader if
there's invalid firmware flashed to the device.
2023-09-10 05:02:44 -07:00
Doug Brown 9df4cd0c84 Enable timer, use for delay functions 2023-09-10 05:02:44 -07:00
Doug Brown 6a9b75d01b Implement M258KE board functions 2023-09-10 05:02:44 -07:00
Doug Brown da015217f3 Add initial hardware.h for M258KE
Delay functions aren't implemented yet; they will be coming later.
2023-09-10 05:02:44 -07:00
Doug Brown c211ab31bf Add implementation of ParallelBus for M258KE 2023-09-10 05:02:44 -07:00
Doug Brown df5c50ffee Add GPIO driver
Provide the basic functionality for setting direction, turning on and
off, toggling, reading inputs, and enabling/disabling pullups.

This chip also provides pulldowns, so in the future I will also
implement pulldown control so we can detect shorts to 5V.
2023-09-10 05:02:44 -07:00
Doug Brown d1ef87a3f6 Implement stubbed-out SPI driver
SPI isn't needed on this platform because we don't need an I/O expander.
So this can be a bunch of stub functions that do nothing. They will be
optimized out during the linking process anyway.
2023-09-10 05:02:44 -07:00
Doug Brown 5e8224e35e Add USB CDC serial port code
This implements a USB CDC serial port using the Nuvoton USBD driver. The
USB handling is based on Nuvoton's BSP sample code, especially the IRQ
handlers and descriptor buffer configuration. The descriptors have been
adapted to be similar to the AVR version, and RX/TX functions have been
written to implement an API closer to LUFA, which is what the SIMM
programmer common code needs.
2023-09-10 05:02:44 -07:00
Doug Brown abb1352f30 Include usbd.h
Since I stripped the peripheral header includes from M251.h, I have to
include it manually instead.
2023-09-10 05:02:44 -07:00
Doug Brown c94f064340 Fix const correctness of S_USBD_INFO_T struct 2023-09-10 05:02:44 -07:00
Doug Brown 0db1710871 Disable unnecessary interrupt
I don't really need to bother with VBUS or "no-event-wake-up"
interrupts. This allows me to strip out more code in the IRQ handler.
2023-09-10 05:02:44 -07:00
Doug Brown f68c1d1d44 Change USBD_MemCopy to not be static inline
I'm sure it's slightly more efficient as a static inline function, but
it results in less flash usage as a separate function. This is important
for the bootloader where every byte matters.
2023-09-10 05:02:44 -07:00
Doug Brown 2c35f61c88 Strip out unnecessary callbacks and code in USBD driver
This is important for the bootloader. There's a bunch of stuff here we
don't need that unnecessarily bloats the code.
2023-09-10 05:02:44 -07:00
Doug Brown 2a96427047 Bypass GCC built-in startup code
Nuvoton's sample startup_M251.S file handles enough initialization for
my purposes, so I can completely bypass _start and jump directly to
main. Note that I also had to add a define to enable clearing of BSS.
2023-09-10 05:02:44 -07:00
Doug Brown 06f9bbcbe7 Strip out unnecessary clock and UART code
The default values for SystemCoreClock, CyclesPerUs, and PllClock work
fine for my purposes of running from the 48 MHz HIRC. Remove unnecessary
initialization code. This is especially useful for the bootloader where
flash space is at a premium.

Also strip out unneeded UART setup code.
2023-09-10 05:02:44 -07:00
Doug Brown 0470b9960c Don't include peripheral header files in M251.h
I don't want to include all of Nuvoton's peripheral drivers, but I do
want to use this header file. Remove the unnecessary peripheral
includes.
2023-09-10 05:02:44 -07:00
Doug Brown a702106bb3 Reserve 4 bytes at end of RAM for magic number
This will be used during firmware updates so that the main firmware can
communicate to the bootloader that it should stay in the bootloader for
a firmware update rather than run the main firmware again.
2023-09-10 05:02:44 -07:00
Doug Brown 34f2364840 Fix issue with linker script allowing data section to overflow flash 2023-09-10 05:02:44 -07:00
Doug Brown 78c4068071 Update linker scripts with correct RAM/flash sizes
Change code style so that it's easy to see the number of kilobytes too.
2023-09-10 05:02:44 -07:00
Doug Brown bc9b0245ba Add README explaining the Nuvoton directory 2023-09-10 05:02:44 -07:00
Doug Brown a4b17f6601 Initial commit of Nuvoton USBD driver 2023-09-10 05:02:44 -07:00
Doug Brown 81bba67ee3 Initial commit of register defines, CMSIS code from Nuvoton BSP 2023-09-10 05:02:44 -07:00