23 static uint8_t num_int_trigs = 0;
24 static uint8_t stop_trigs = 0;
31 static bool ri_gpio_pwm_test_init (
void)
76 float cfg_freq = invalid_max_freq;
77 float cfg_dc = orig_dc;
86 cfg_freq = invalid_min_freq;
102 cfg_freq = orig_freq;
103 cfg_dc = invalid_max_dc;
112 cfg_freq = orig_freq;
113 cfg_dc = invalid_min_dc;
145 float configured_freq = orig_freq;
147 float configured_dc = orig_dc;
150 &configured_freq, &configured_dc);
154 stop_trigs = !stop_trigs;
195 printfp (
"\"gpio_pwm\":{\r\n");
196 printfp (
"\"init\":");
201 failed |= ri_gpio_pwm_test_init ();
205 printfp (
"\"pass\",\r\n");
209 printfp (
"\"fail\",\r\n");
212 printfp (
"\"start\":");
213 failed |= ri_gpio_pwm_test_start (cfg);
217 printfp (
"\"pass\"\r\n");
221 printfp (
"\"fail\"\r\n");
#define RD_ERROR_INVALID_PARAM
Invalid Parameter.
#define RD_ERROR_NULL
Null Pointer.
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
#define RI_GPIO_PWM_TEST_DUTY_INVALID_MAX_HZ
Invalid duty cycle.
rd_status_t ri_gpio_uninit(void)
Uninitializes GPIO module. Call this to reset GPIO to High-Z mode. After uninitialization all GPIO pi...
rd_status_t ri_gpio_interrupt_enable(const ri_gpio_id_t pin, const ri_gpio_slope_t slope, const ri_gpio_mode_t mode, const ri_gpio_interrupt_fp_t handler)
Enable interrupt on a pin.
#define RI_GPIO_INTERRUPT_TEST_TABLE_SIZE
Fixed 64 interrupt table size, adjust this if some device has more than 2 ports with 32 gpios each.
rd_status_t ri_gpio_pwm_stop(const ri_gpio_id_t pin)
Stop PWM on given pin.
#define RI_GPIO_PWM_TEST_FREQ_INVALID_MAX_HZ
Invalid frequency.
rd_status_t ri_gpio_interrupt_init(ri_gpio_interrupt_fp_t *const interrupt_table, const uint16_t max_interrupts)
Initialize interrupt functionality to GPIO. Takes address of interrupt table as a pointer to avoid ty...
#define RI_GPIO_PWM_TEST_DC
Duty cycle in test.
void(* ri_gpio_interrupt_fp_t)(const ri_gpio_evt_t)
#define RI_GPIO_PWM_TEST_DUTY_INVALID_MIN_HZ
Invalid duty cycle.
bool ri_gpio_pwm_is_init(void)
Check if PWM is initialized.
#define RI_GPIO_PWM_TEST_FREQ_INVALID_MIN_HZ
Invalid frequency.
#define RI_GPIO_PWM_TEST_TIME_MS
Milliseconds to test.
rd_status_t ri_gpio_interrupt_uninit(void)
Uninitialize interrupt functionality of GPIO.
rd_status_t ri_gpio_interrupt_disable(const ri_gpio_id_t pin)
Disable interrupt on a pin.
rd_status_t ri_gpio_pwm_init(void)
Run any necessary initialization for PWM.
rd_status_t ri_gpio_init(void)
Initializes GPIO module. Call this before other GPIO functions. After initialization all GPIO pins sh...
#define RI_GPIO_PWM_EXPECT_TRIGS
rd_status_t ri_gpio_pwm_start(const ri_gpio_id_t pin, const ri_gpio_mode_t mode, float *const frequency, float *const duty_cycle)
Start PWM on given pin at given frequency and duty cycle.
rd_status_t ri_gpio_pwm_uninit(void)
Uninitialize PWM.
#define RI_GPIO_PWM_TEST_FREQ_HZ
Frequency of test.
bool ri_gpio_pwm_run_integration_test(const rd_test_print_fp printfp, const ri_gpio_id_t input, const ri_gpio_id_t output)
Run all GPIO interrupt integration tests.
void(* rd_test_print_fp)(const char *const msg)
function pointer to print test information
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Functions for testing drivers.
uint16_t ri_gpio_id_t
port<<8 + pin
@ RI_GPIO_MODE_OUTPUT_HIGHDRIVE
Push-pull output, can be written. Higher current drive than standard.
@ RI_GPIO_MODE_INPUT_NOPULL
Input, can be read. No pull resistors.
@ RI_GPIO_MODE_INPUT_PULLDOWN
Input, can be read. Pulled dpwn by internal resistor, value depends on IC.
rd_status_t ri_delay_ms(uint32_t time)
Delay a given number of milliseconds.
structure to configure GPIO test with input and output. These GPIOs must be physically connected on b...
ri_gpio_id_t input
Input pin used in test. Must be interrupt-capable.
ri_gpio_id_t output
Output pin used in test. Must be PWM-capable.