-
Notifications
You must be signed in to change notification settings - Fork 72
Core api update interrupt #343
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
Conversation
Signed-off-by: zhanglinjing <[email protected]>
Signed-off-by: zhanglinjing <[email protected]>
Signed-off-by: zhanglinjing <[email protected]>
Signed-off-by: zhanglinjing <[email protected]>
Signed-off-by: zhanglinjing <[email protected]>
Signed-off-by: zhanglinjing <[email protected]>
Signed-off-by: zhanglinjing <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which tests have been performed here? Against which board this is evaluated?
None of them seems to be compiling.
For this branch we have to disable in the actions check all the non-relevant boards and examples, and get this green before moving forward. Otherwise the compile-check won´t providing any helpful information.
These cover UART and Interrupts.
I would expect arduino-copre the interrupts and the UART to be all green and passing. As we don´t have this in the HIL, at least locally and place here the output.
cores/xmc/Uart.h
Outdated
|
||
operator bool() { return true; } | ||
|
||
void setInterruptPriority(uint32_t priority); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these functions public ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi juan, for uart we have another one branch please check other PR which is created by linjing , kindly do review also that one.
i will remove the rewrite functions and let me test again for UART implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, i mean, if that is part of another PR it is fine.
All the uart related comments should be taken in that PR.
If this version is sufficient to get the output of the tests, that´s fine :)
cores/xmc/Uart.h
Outdated
void IrqHandler(void); | ||
|
||
private: | ||
RingBuffer *_rx_buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not to have the RingBuffer object instead of a pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same question. Of course we can change it, but we also need to change all the declarations inside pins_arduino.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless a good reason not to be a private member of the class. Yes please.
Each UART instance handles its own buffer. The UART API public does not need to expose any of that or?
cores/xmc/Uart.h
Outdated
|
||
size_t write(const uint8_t); | ||
|
||
// virtual size_t write(const uint8_t *buffer, size_t size) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some or all of these functions are already provided by parent classes. Unless they are different, we don´t need to rewrite them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove the inline functions, here is the reason I keep it:
I did not rewrite any function except implement write(). But the XMC4Arduino doesn't implement size_t write(const uint8_t *buffer, size_t size), just using the default implementation of Print class. But what about types other than uint8? That is why inline functions are added, it just truncates all inputs to 8-bit bytes.
If I had to severely rewrite the entire uart module, I would change this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all the other types you would use the print() function. And these are handled here:
https://github.com/arduino/ArduinoCore-API/blob/master/api/Print.h#L64-L91
The overloaded print() functions will eventually call write().
Why write() would need to handled that duplicating the behavior or write()?
Why do you have to rewrite the entire module?
We need to provide mandatorily:
virtual size_t write(uint8_t) = 0;
And optionally, and many times convenient:
virtual size_t write(const uint8_t *buffer, size_t size);
cores/xmc/Uart.h
Outdated
int read(void); | ||
void flush(void); | ||
|
||
// virtual size_t readBytes(char *buffer, size_t length) ; // read chars from stream into buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup stale code or comment whey it is commented.
cores/xmc/Uart.h
Outdated
class Uart : public HardwareSerial { | ||
public: | ||
XMC_UART_t *_XMC_UART_config; | ||
Uart(XMC_UART_t *xmc_uart_config, RingBuffer *rx_buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could create a XMC_UART object by passing valid UART pins like UART(pin_tx, pin_rx, pin_cts, pin_rts)
.
Not sure how affordable is it to implement based on the xmc_lib API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible. need to modify pins_arduino.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one probably needs more work than we want to take now. So we can create a ticket for this for the future.
interrupt_0_cb = callback; | ||
NVIC_EnableIRQ(ERU0_3_IRQn); | ||
} else if (pin_irq.irq_num == 1) { | ||
#if defined(XMC4200_Platform2GO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be handled by defines in the pins_arduino.h ?
That way we can avoid here all these cascaded if/else that need to be modified for each board.
XMC_CCU4_EnableClock(pin_irq.ccu, pin_irq.slice_num); | ||
|
||
if (pin_irq.irq_num == 0) { | ||
#if defined(XMC1100_Boot_Kit) || defined(XMC1400_Arduino_Kit) || defined(XMC1400_XMC2GO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same topic...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, this will be evaluated in a later stage!
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
9c7dcf8
to
654f138
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements updates to the interrupt module for the XMC platform while also refactoring the UART initialization and serial event handling. Key changes include:
- Updating the digitalPinToInterrupt macro to return –1 instead of NOT_AN_INTERRUPT.
- Un-commenting and enabling the mapping_interrupt array and serial interrupt callback functions.
- Refactoring the UART code, header inclusions, and modifying the GitHub Actions workflow configuration.
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h | Updated the interrupt macro and enabled the mapping_interrupt array. |
tests/test_config.h | Added a new test configuration header for board-specific test pin definitions. |
cores/xmc/main.cpp | Modified the main loop to explicitly invoke ::serialEventRun() for clarity. |
cores/xmc/WInterrupts.c | Introduced interrupt attach/detach functions and their callbacks. |
cores/xmc/Uart.h, cores/xmc/Uart.cpp | Added new UART class implementation and initialization routines. |
cores/xmc/Arduino.h | Revised includes to integrate the UART support. |
.github/workflows/compile-platform-examples.yml | Commented out certain sketch compilation steps in the CI workflow. |
Files not reviewed (1)
- tests/arduino-core-tests: Language not supported
Comments suppressed due to low confidence (1)
variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h:149
- [nitpick] Consider defining a named constant (e.g., INVALID_INTERRUPT) instead of using the literal -1 to improve code clarity and maintainability.
#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : -1))
nice! |
Signed-off-by: MDin <[email protected]>
Signed-off-by: MDin <[email protected]>
By creating this pull request you agree to the terms in CONTRIBUTING.md.
https://github.com/Infineon/.github/blob/master/CONTRIBUTING.md
--- DO NOT DELETE ANYTHING ABOVE THIS LINE ---
CONTRIBUTING.md also tells you what to expect in the PR process.
Description
Interrupt Module Implementation
Related Issue
NOT_AN_INTERRUPT not initialize anywhere so modified from #define digitalPinToInterrupt(p) (((p) == 9) ? 0 : NOT_AN_INTERRUPT) to #define digitalPinToInterrupt(p) (((p) == 9) ? 0 : -1)
Without digitalPinToInterrupt function, pin is not detecting in test case. so must include digitalPinToInterrupt to initialize pin.
Context
Interrupt test that are running in single board with connected jumper wire between two pins which is OUTPUT pin to INPUT pin(interrupt)