This file contains the SAMD QTouch library sample user application.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
Macros | |
#define | GET_MUTLCAP_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER) |
#define | GET_MUTLCAP_SENSOR_STATE(SENSOR_NUMBER) |
#define | LED_1_PIN PIN_PB01 |
Discrete LED output pin definitions. More... | |
#define | LED_2_PIN PIN_PB02 |
#define | LED_3_PIN PIN_PB03 |
#define | LED_4_PIN PIN_PA05 |
#define | LED_5_PIN PIN_PA06 |
#define | LED_6_PIN PIN_PA04 |
#define | LED_7_PIN PIN_PA07 |
#define | LED_B_PIN PIN_PA17 |
#define | LED_G_PIN PIN_PB15 |
#define | LED_R_PIN PIN_PB14 |
RGB LED output pin definitions. More... | |
#define | TIME_PERIOD_1MSEC 33u |
RTC Interrupt timing definition. More... | |
Functions | |
void | configure_port_pins (void) |
Prototypes. More... | |
void | configure_rtc_callbacks (void) |
Configure the RTC timer callback. More... | |
void | configure_rtc_count (void) |
Configure the RTC timer count after which interrupts comes. More... | |
int | main (void) |
Main function. More... | |
void | rtc_overflow_callback (void) |
RTC timer overflow callback. More... | |
void | timer_init (void) |
Initialize timer. More... | |
Variables | |
volatile uint8_t | PWM_Count |
const uint8_t | PWM_RGB_values [64][3] |
uint8_t | rotor_position |
uint8_t | rotor_state |
Variables. More... | |
struct rtc_module | rtc_instance |
volatile uint16_t | touch_time_counter = 0u |
#define GET_MUTLCAP_ROTOR_SLIDER_POSITION | ( | ROTOR_SLIDER_NUMBER | ) |
Referenced by main(), and rtc_overflow_callback().
#define GET_MUTLCAP_SENSOR_STATE | ( | SENSOR_NUMBER | ) |
Referenced by main().
#define LED_1_PIN PIN_PB01 |
Discrete LED output pin definitions.
Referenced by configure_port_pins(), and main().
#define LED_2_PIN PIN_PB02 |
Referenced by configure_port_pins(), and main().
#define LED_3_PIN PIN_PB03 |
Referenced by configure_port_pins(), and main().
#define LED_4_PIN PIN_PA05 |
Referenced by configure_port_pins(), and main().
#define LED_5_PIN PIN_PA06 |
Referenced by configure_port_pins(), and main().
#define LED_6_PIN PIN_PA04 |
Referenced by configure_port_pins(), and main().
#define LED_7_PIN PIN_PA07 |
Referenced by configure_port_pins(), and main().
#define LED_B_PIN PIN_PA17 |
Referenced by configure_port_pins(), main(), and rtc_overflow_callback().
#define LED_G_PIN PIN_PB15 |
Referenced by configure_port_pins(), main(), and rtc_overflow_callback().
#define LED_R_PIN PIN_PB14 |
RGB LED output pin definitions.
Referenced by configure_port_pins(), main(), and rtc_overflow_callback().
#define TIME_PERIOD_1MSEC 33u |
RTC Interrupt timing definition.
Referenced by timer_init().
void configure_port_pins | ( | void | ) |
Prototypes.
Port pin configuration / assignments.
Configure Port pins
References port_config::direction, LED_0_PIN, LED_1_PIN, LED_2_PIN, LED_3_PIN, LED_4_PIN, LED_5_PIN, LED_6_PIN, LED_7_PIN, LED_B_PIN, LED_G_PIN, LED_R_PIN, port_get_config_defaults(), PORT_PIN_DIR_OUTPUT, and port_pin_set_config().
Referenced by main().
void configure_rtc_callbacks | ( | void | ) |
Configure the RTC timer callback.
References RTC_COUNT_CALLBACK_OVERFLOW, rtc_count_enable_callback(), rtc_count_register_callback(), rtc_instance, and rtc_overflow_callback().
Referenced by timer_init().
void configure_rtc_count | ( | void | ) |
Configure the RTC timer count after which interrupts comes.
References rtc_count_config::continuously_update, rtc_count_config::mode, rtc_count_config::prescaler, rtc_count_enable(), rtc_count_get_config_defaults(), rtc_count_init(), RTC_COUNT_MODE_16BIT, RTC_COUNT_PRESCALER_DIV_1, and rtc_instance.
Referenced by timer_init().
int main | ( | void | ) |
Main function.
Initialize and configure system and generic clocks. Use conf_clocks.h to configure system and generic clocks.
Enable global interrupts.
Initialize delay service.
Initialize timer.
Initialize QTouch library and configure touch sensors.
Configure port pins
Turn off all extension board LEDs
Goto STANDBY sleep mode, unless woken by timer or PTC interrupt.
Start touch sensor measurement, if touch_time.time_to_measure_touch flag is set by timer.
Get touch sensor states
Clear all slider controlled LEDs
If slider is activated
Parse slider position
References configure_port_pins(), delay_init(), GET_MUTLCAP_ROTOR_SLIDER_POSITION, GET_MUTLCAP_SENSOR_STATE, LED_0_PIN, LED_1_PIN, LED_2_PIN, LED_3_PIN, LED_4_PIN, LED_5_PIN, LED_6_PIN, LED_7_PIN, LED_B_PIN, LED_G_PIN, LED_R_PIN, tag_touch_measure_data_t::measurement_done_touch, p_mutlcap_measure_data, port_pin_set_output_level(), PWM_Count, rotor_state, system_init(), system_interrupt_enable_global(), system_set_sleepmode(), system_sleep(), SYSTEM_SLEEPMODE_STANDBY, timer_init(), touch_sensors_init(), and touch_sensors_measure().
void rtc_overflow_callback | ( | void | ) |
RTC timer overflow callback.
Configure the RTC timer overflow callback.
References tag_touch_time_t::current_time_ms, GET_MUTLCAP_ROTOR_SLIDER_POSITION, LED_B_PIN, LED_G_PIN, LED_R_PIN, tag_touch_time_t::measurement_period_ms, port_pin_set_output_level(), PWM_Count, PWM_RGB_values, rotor_position, rotor_state, tag_touch_time_t::time_to_measure_touch, touch_time, and touch_time_counter.
Referenced by configure_rtc_callbacks().
void timer_init | ( | void | ) |
Initialize timer.
References configure_rtc_callbacks(), configure_rtc_count(), rtc_count_set_period(), rtc_instance, and TIME_PERIOD_1MSEC.
Referenced by main().
volatile uint8_t PWM_Count |
Referenced by main(), and rtc_overflow_callback().
const uint8_t PWM_RGB_values[64][3] |
Referenced by rtc_overflow_callback().
uint8_t rotor_position |
Referenced by rtc_overflow_callback().
uint8_t rotor_state |
Variables.
Referenced by main(), and rtc_overflow_callback().
struct rtc_module rtc_instance |
Referenced by configure_rtc_callbacks(), configure_rtc_count(), and timer_init().
volatile uint16_t touch_time_counter = 0u |
Referenced by rtc_overflow_callback().