libpic170x  0.2
Ease of use library for PIC16(L)1705/1709 chips
io_control.h
Go to the documentation of this file.
1 /*
2  Copyright 2018 Paul Konstantin Gerke
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 
56 #ifndef IO_CONTROL_H
57 #define IO_CONTROL_H
58 
59 #include <stdint.h>
60 #include <stdbool.h>
61 
63 #define PIN_INPUT_MODE_DIGITAL 0
64 #define PIN_INPUT_MODE_ANALOG 1
66 
67 
75 typedef struct {
77  uint8_t pin_pps;
79  volatile unsigned char *out_src_pps_reg;
82 
84  volatile unsigned char *tris_reg;
86  volatile unsigned char *port_reg;
88  volatile unsigned char *ansel_reg;
90  volatile unsigned char *latch_reg;
91 } PinDef;
92 
93 
102 void pin_set_pin_mode(const PinDef* def, bool output);
103 
115 bool pin_get_input(const PinDef* def);
116 
126 void pin_set_output(const PinDef* def, bool on);
127 
141 void pin_set_input_mode(const PinDef* def, uint8_t input_mode);
142 
143 
145 extern const PinDef* PIN_RA0;
147 extern const PinDef* PIN_RA1;
149 extern const PinDef* PIN_RA2;
151 extern const PinDef* PIN_RA3;
153 extern const PinDef* PIN_RA4;
155 extern const PinDef* PIN_RA5;
156 
158 extern const PinDef* PIN_RB4;
160 extern const PinDef* PIN_RB5;
162 extern const PinDef* PIN_RB6;
164 extern const PinDef* PIN_RB7;
165 
167 extern const PinDef* PIN_RC0;
169 extern const PinDef* PIN_RC1;
171 extern const PinDef* PIN_RC2;
173 extern const PinDef* PIN_RC3;
175 extern const PinDef* PIN_RC4;
177 extern const PinDef* PIN_RC5;
179 extern const PinDef* PIN_RC6;
181 extern const PinDef* PIN_RC7;
182 
183 #endif /* IO_CONTROL_H */
184 
volatile unsigned char * tris_reg
Pointer to the pin&#39;s tris register (can be NULL)
Definition: io_control.h:84
const PinDef * PIN_RA0
PIN_RA0 defintion.
const PinDef * PIN_RA5
PIN_RA5 defintion.
const PinDef * PIN_RC0
PIN_RC0 defintion.
const PinDef * PIN_RB5
PIN_RB5 defintion.
volatile unsigned char * port_reg
Pointer to the pin&#39;s port register (never NULL)
Definition: io_control.h:86
void pin_set_output(const PinDef *def, bool on)
Definition: io_control.c:129
const PinDef * PIN_RA2
PIN_RA2 defintion.
uint8_t pin_pps
The input PPS that can be used for modules to set this chip as input.
Definition: io_control.h:77
const PinDef * PIN_RC4
PIN_RC4 defintion.
Record to store a collection of registers and masks related to a pin.
Definition: io_control.h:75
volatile unsigned char * latch_reg
Pointer to the pin&#39;s output register (can be NULL)
Definition: io_control.h:90
const PinDef * PIN_RC1
PIN_RC1 defintion.
const PinDef * PIN_RC2
PIN_RC2 defintion.
const PinDef * PIN_RB6
PIN_RB6 defintion.
volatile unsigned char * out_src_pps_reg
The output PPS that can set such that the pin act as output for a given module.
Definition: io_control.h:79
const PinDef * PIN_RC6
PIN_RC6 defintion.
void pin_set_pin_mode(const PinDef *def, bool output)
Definition: io_control.c:106
bool pin_get_input(const PinDef *def)
Definition: io_control.c:118
const PinDef * PIN_RB7
PIN_RB7 defintion.
const PinDef * PIN_RA4
PIN_RA4 defintion.
const PinDef * PIN_RA1
PIN_RA1 defintion.
const PinDef * PIN_RC5
PIN_RC5 defintion.
const PinDef * PIN_RA3
PIN_RA3 defintion.
void pin_set_input_mode(const PinDef *def, uint8_t input_mode)
Definition: io_control.c:141
const PinDef * PIN_RC7
PIN_RC7 defintion.
volatile unsigned char * ansel_reg
Pointer to the pin&#39;s analog selection register (can be NULL)
Definition: io_control.h:88
uint8_t pin_tris_bitmask
Mask for the pin to use with the referenced tris_reg.
Definition: io_control.h:81
const PinDef * PIN_RB4
PIN_RB4 defintion.
const PinDef * PIN_RC3
PIN_RC3 defintion.