gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
ptc.h
1
2/*
3 * FreeTouch, a QTouch-compatible library - tested on ATSAMD21 only!
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2017 Limor 'ladyada' Fried for Adafruit Industries
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27#pragma once
28
29#include <stdbool.h>
30#include <stdint.h>
31#include "sam.h"
32
40#ifdef _SAMD21_
41#include "component/samd21_ptc_component.h"
42#define HAS_PTC 1
43#endif
44
45#ifdef HAS_PTC
46
47/* Touch library oversampling (filter) setting */
48typedef enum tag_oversample_level_t {
49 OVERSAMPLE_1,
50 OVERSAMPLE_2,
51 OVERSAMPLE_4,
52 OVERSAMPLE_8,
53 OVERSAMPLE_16,
54 OVERSAMPLE_32,
55 OVERSAMPLE_64
56} ptc_oversample_t;
57
58/* Touch library series resistor setting */
59typedef enum tag_series_resistor_t {
60 RESISTOR_0,
61 RESISTOR_20K,
62 RESISTOR_50K,
63 RESISTOR_100K,
64} ptc_series_resistor_t;
65
66typedef enum tag_freq_mode_t {
67 FREQ_MODE_NONE,
68 FREQ_MODE_HOP,
69 FREQ_MODE_SPREAD,
70 FREQ_MODE_SPREAD_MEDIAN
71} ptc_freq_mode_t;
72
73typedef enum tag_freq_hop_t {
74 FREQ_HOP_1,
75 FREQ_HOP_2,
76 FREQ_HOP_3,
77 FREQ_HOP_4,
78 FREQ_HOP_5,
79 FREQ_HOP_6,
80 FREQ_HOP_7,
81 FREQ_HOP_8,
82 FREQ_HOP_9,
83 FREQ_HOP_10,
84 FREQ_HOP_11,
85 FREQ_HOP_12,
86 FREQ_HOP_13,
87 FREQ_HOP_14,
88 FREQ_HOP_15,
89 FREQ_HOP_16
90} ptc_freq_hop_t;
91
95void ptc_init(void);
96
103void ptc_enable(uint8_t channel);
104
109bool ptc_is_enabled(void);
110
116uint16_t ptc_get_value(uint8_t channel);
117
118#endif
119
void ptc_init(void)
Initialize the peripheral touch controller.
Definition ptc.c:38
bool ptc_is_enabled(void)
Checks if the PTC is currently enabled.
Definition ptc.c:91
uint16_t ptc_get_value(uint8_t channel)
Get a value from the given channel.
Definition ptc.c:95
void ptc_enable(uint8_t channel)
Enable the given PTC channel.
Definition ptc.c:77