Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonix SN32 series support #317

Merged
merged 70 commits into from
Apr 18, 2022
Merged

Conversation

dexter93
Copy link
Contributor

@dexter93 dexter93 commented Mar 3, 2022

Preliminary support for SONIX SN32F2XX series

Supports most 32bit SONIX chips. Includes native ChibiOS drivers for the most part and placeholders using reference code for the not-yet-implemented ones. Still under development, but having them in a common -Contrib will improve portability and aid future development

Closes #225

smplman and others added 30 commits February 12, 2022 13:51
move isr mapping to the lld
This is taken from the latest pack file called:

"SONiX.SN32F2_DFP.1.2.11.pack"

This pack file is found in an archive named:

"SN32F260_Startkit_Package_V1.6R.zip"

download from here:

http://www.sonix.com.tw/article-en-998-24753 or
http://www.sonix.com.tw/files/1/9BB279642CFC9359E050007F01007A12

(extract that zip file and look in the "Pack" folder)

if you rename "SONiX.SN32F2_DFP.1.2.11.pack" to "SONiX.SN32F2_DFP.1.2.11.zip" you can extract it with a normal zip program

You find the file "SN32F260.h" in the folder "Device/Include"
This is inspired/copy-pasted from:

toastdb@be7396a
* sn32 hal: update flash from latest CMSIS

* sn32: build flash

* sn32: fix compilation

* sn32 flash: add half word flashing

* sn32 flash: adaptation time
IsaacDynamo and others added 18 commits February 12, 2022 13:51
* Fix misconfiguration, and cleanup board.h

* Update 240B as well
* add preliminary support for the whole SN32F2XX series
* unify CMSIS support, no more ugly hacks
* rename the unified hal to SN32F2XX
* common header amongst the hal, points to device
* add board files for the series
* 240 gets to keep it's own hal for now
* sn32: 2xx: centralize peripheral clock functions

* sn32: export HCLK for all boards

* sn32: support tickless mode for systick

* sn32: CT: cleanup inclusions

* Revert "sn32: export HCLK for all boards"

This reverts commit 1cae889.

* sn32: export HCLK in hal level

* ST: inherit the SN32_HCLK

* 2xx lld: include ct header

* ST: fix systime type

* ST: interrupt should be disabled on init

* st: cleanup

* debug it

* Revert "debug it"

This reverts commit 1dd78e8.

* sn32f2xx: make sure clocks match and proper timer init

* add more checks

* always read 32 bits from the counter

* read the first 16 bits directly

* systime_t is 16bits, but MR0 lives in a 32bit register

* testing: use ILRC

* testing: hack

* Revert "testing: hack"

This reverts commit 3821173.

* Revert "testing: use ILRC"
we can't do this because hardware limits
This reverts commit 19d3ffe.

* fix assert

* test: hardcode it

* Revert "test: hardcode it"

This reverts commit a75777c.
* sn32 spi driver

* use spi0

* requested changes

* don't enable on init

* fix SPIx_Disable

* fix typo

* fix spi init
ARM M0 supports interrupt priorities 1-3
* sn32: add watchdog driver

reset mode only.

* fix build
* import helper header

* seperate usb buf init

* move usb init in chibios driver
handle the address set in a more elegant way

* clean up some code
move through sn32_usb
use macros for ep dir

* handle the setup interrupt

* report back the frame no
wake up directly

* further deviate from usbhw.c
call registers directly
use chibios for reset
interrupt party time

* flag update

* switch n/ack to simple macros

* even more native

* bye sonix mess

* bring functions up to the docs

* usb stop, setup error handling

* further cleanup

remove dead code
cleanup headers
add missing connect/dc functionality
bring ep0 init to platform correct

* usb restart is now working

* attempt to fix wakeup

* no more delay on init

* fix the usb wakeup

* improve the wakeup

* make sure the direction is not set before init

* only mess with one ep

* need to enable the bus override too in order to control it

* driver block checks

* allow wakeup time override

* dynamic sram allocation

* remove useless ep naming

* testing: remove packet limits

* guard all i/o ops

* better wakeup/suspend handling

* remove dead code

* code cleanup

* make sure all ep's are handled
@dexter93
Copy link
Contributor Author

dexter93 commented Mar 3, 2022

platform test beds: SN32F240B, SN32F260 ( mostly) and SN32F240. SN32F240 gets it's own LLD since it has significant hardware differences to other F2XX chips. This has been tested to work reliably so far with QMK at SonixQMK repos.

@fpoussin
Copy link
Member

Hi!
Can you add this platform to the CI for testing?
Thanks

@dexter93
Copy link
Contributor Author

Hi! Can you add this platform to the CI for testing? Thanks

Hi there. Probably, but I see that CI uses testhal and demos requiring not yet implemented drivers ( I2C,ADC, UART - most of those are out of scope since no device with them is using them on QMK so far). Could you specify what is needed for CI? Thanks!

@fpoussin
Copy link
Member

You need to have at least one testhal folder and add it to the CI.
You're free to chose which drivers to test.

@fpoussin fpoussin merged commit e775cbb into ChibiOS:chibios-21.11.x Apr 18, 2022
@jindaxia
Copy link

jindaxia commented May 6, 2022

Great Job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SN32F248B Support