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 _SAMD11_
46#include "component/samd11_ptc_component.h"
47#define HAS_PTC 1
48#endif
49
50#ifdef HAS_PTC
51
52/* Touch library oversampling (filter) setting */
53typedef enum tag_oversample_level_t {
54 OVERSAMPLE_1,
55 OVERSAMPLE_2,
56 OVERSAMPLE_4,
57 OVERSAMPLE_8,
58 OVERSAMPLE_16,
59 OVERSAMPLE_32,
60 OVERSAMPLE_64
61} ptc_oversample_t;
62
63/* Touch library series resistor setting */
64typedef enum tag_series_resistor_t {
65 RESISTOR_0,
66 RESISTOR_20K,
67 RESISTOR_50K,
68 RESISTOR_100K,
69} ptc_series_resistor_t;
70
71typedef enum tag_freq_mode_t {
72 FREQ_MODE_NONE,
73 FREQ_MODE_HOP,
74 FREQ_MODE_SPREAD,
75 FREQ_MODE_SPREAD_MEDIAN
76} ptc_freq_mode_t;
77
78typedef enum tag_freq_hop_t {
79 FREQ_HOP_1,
80 FREQ_HOP_2,
81 FREQ_HOP_3,
82 FREQ_HOP_4,
83 FREQ_HOP_5,
84 FREQ_HOP_6,
85 FREQ_HOP_7,
86 FREQ_HOP_8,
87 FREQ_HOP_9,
88 FREQ_HOP_10,
89 FREQ_HOP_11,
90 FREQ_HOP_12,
91 FREQ_HOP_13,
92 FREQ_HOP_14,
93 FREQ_HOP_15,
94 FREQ_HOP_16
95} ptc_freq_hop_t;
96
100void ptc_init(void);
101
108void ptc_enable(uint8_t channel);
109
115uint16_t ptc_get_value(uint8_t channel);
116
117#endif
118
void ptc_init(void)
Initialize the peripheral touch controller.
Definition ptc.c:38
uint16_t ptc_get_value(uint8_t channel)
Get a value from the given channel.
Definition ptc.c:91
void ptc_enable(uint8_t channel)
Enable the given PTC channel.
Definition ptc.c:77