mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
19924: drivers/pcf857x: Move compile time check to compilation unit r=maribu a=maribu ### Contribution description This allows including the header without using the module. Obviously, calls to the functions provided by the header won't like without using the module. But including the header can still be useful for e.g.: if (IS_USED(MODULE_PCF857x)) { /* make use of the module */ } In the above example all calls to pcf857x functions would be optimized out when the module is not used, full compile checks happen in either case. ### Testing procedure - binaries should not change - including the pcf857x header should work without having selected one of the pcf857x variants, if the driver is not actually used - when calling any of the functions provided, linking should fail - when using the `pcf857x` module without any variant, compiling should still fail with a message indicating that (at least) one of the pcf857x needs to be selected ### Issues/PRs references None 19925: cpu/sam3: assert valid freq in timer_init() r=maribu a=maribu ### Contribution description The API of timer_init() expects callers to know what frequencies are supported and only use valid frequencies. So let's add an `assert()` to aid debugging if the app uses an invalid. ### Testing procedure - any valid application should compile and work as before - an application using an unsupported timer frequency should trigger an `assert()`, rather than letting the timer silently run at a (possibly widely) different frequency ### Issues/PRs references None Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
This commit is contained in:
commit
9609a49da7
@ -111,7 +111,12 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
|
||||
* channel 1 toggles this line on each timer tick, the actual frequency
|
||||
* driving channel 0 is f_ch2 / 2 --> f_ch0/1 = (MCK / 2) / 2 / freq.
|
||||
*/
|
||||
dev(tim)->TC_CHANNEL[1].TC_RC = (CLOCK_CORECLOCK / 4) / freq;
|
||||
uint32_t tc_rc = (CLOCK_CORECLOCK / 4) / freq;
|
||||
/* the API expects apps to know in advance which frequencies are possible
|
||||
* and only configure with supported frequencies. So aid debugging with
|
||||
* an assert */
|
||||
assert(tc_rc * freq == CLOCK_CORECLOCK / 4);
|
||||
dev(tim)->TC_CHANNEL[1].TC_RC = tc_rc;
|
||||
|
||||
/* start channel 1 */
|
||||
dev(tim)->TC_CHANNEL[1].TC_CCR = (TC_CCR_CLKEN | TC_CCR_SWTRG);
|
||||
|
@ -260,10 +260,6 @@ extern "C"
|
||||
#include "event.h"
|
||||
#endif /* MODULE_PCF857X_IRQ */
|
||||
|
||||
#if !IS_USED(MODULE_PCF8574) && !IS_USED(MODULE_PCF8574A) && !IS_USED(MODULE_PCF8575)
|
||||
#error "Please provide a list of pcf857x variants used by the application (pcf8574, pcf8574a or pcf8575)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name PCF857X I2C slave addresses
|
||||
*
|
||||
|
@ -42,6 +42,10 @@
|
||||
|
||||
#endif /* ENABLE_DEBUG */
|
||||
|
||||
#if !IS_USED(MODULE_PCF8574) && !IS_USED(MODULE_PCF8574A) && !IS_USED(MODULE_PCF8575)
|
||||
#error "Please provide a list of pcf857x variants used by the application (pcf8574, pcf8574a or pcf8575)"
|
||||
#endif
|
||||
|
||||
#if IS_USED(MODULE_PCF857X_IRQ_LOW)
|
||||
#define PCF857X_EVENT_PRIO EVENT_PRIO_LOWEST
|
||||
#elif IS_USED(MODULE_PCF857X_IRQ_MEDIUM)
|
||||
|
Loading…
Reference in New Issue
Block a user