CH55x_USB_CompositeDevice
CH55x_USB_CompositeDevice copied to clipboard
Interrupts
Hiya,
There's a comment in main.c that asks:
* According to SDCC specification, interrupt handlers MUST be placed within the file which contains
* the void main(void) function, otherwise SDCC won't be able to recognize it. It's not a bug but a feature.
* If you know how to fix this, please let me know.
https://github.com/rikka0w0/CH55x_USB_CompositeDevice/blob/489bcf73a9872945ca642d420113aea2c8824348/main.c#L27
The SDCC specification actually states that interrupt handlers must be defined in main. The implementation of the function can exist elsewhere. See http://fivedots.coe.psu.ac.th/~cj/masd/resources/sdcc-doc/SDCCUdoc-11.html
I've also independently verified this assertion using some custom USB code on the CH554, compiled using SDCC. e.g.
void main()
{
clock_init();
uart1_init(1);
usbd_init();
LED_PORT_DIR |= LED_MSK;
LED_PORT_PU &= ~(LED_MSK);
while (1)
{
LED_PORT |= LED_MSK;
wait_ms(500);
LED_PORT &= ~LED_MSK;
wait_ms(500);
}
}
void usb_int(void) __interrupt(INT_NO_USB);
and in usbd.c:
void usb_int(void) __interrupt(INT_NO_USB) {
....
Awesome work by the way @rikka0w0, thanks for sharing! It was great to have a functional USB stack to compare my dodgey one to during development.
Thanks for the information!