├── Firmware
├── Binary Rev1.0
│ ├── I2CNavKey.X.production.cmf
│ ├── I2CNavKey.X.production.elf
│ ├── I2CNavKey.X.production.hex
│ ├── I2CNavKey.X.production.hxl
│ ├── I2CNavKey.X.production.lst
│ ├── I2CNavKey.X.production.map
│ ├── I2CNavKey.X.production.mum
│ ├── I2CNavKey.X.production.o
│ ├── I2CNavKey.X.production.rlf
│ ├── I2CNavKey.X.production.sdb
│ ├── I2CNavKey.X.production.sym
│ └── memoryfile.xml
└── I2CNavKey.X
│ ├── DataVariable.c
│ ├── DataVariable.h
│ ├── GPports.c
│ ├── GPports.h
│ ├── I2CNavKey.mc3
│ ├── Makefile
│ ├── NavKey.c
│ ├── NavKey.h
│ ├── PWM.c
│ ├── PWM.h
│ ├── i2c_register.c
│ ├── i2c_register.h
│ ├── main.c
│ ├── main.h
│ ├── mcc_generated_files
│ ├── adc.c
│ ├── adc.h
│ ├── clc1.c
│ ├── clc1.h
│ ├── clc2.c
│ ├── clc2.h
│ ├── device_config.c
│ ├── i2c1.c
│ ├── i2c1.h
│ ├── interrupt_manager.c
│ ├── interrupt_manager.h
│ ├── mcc.c
│ ├── mcc.h
│ ├── pin_manager.c
│ ├── pin_manager.h
│ ├── pwm1.c
│ ├── pwm1.h
│ ├── pwm2.c
│ ├── pwm2.h
│ ├── pwm3.c
│ ├── pwm3.h
│ ├── tmr2.c
│ ├── tmr2.h
│ ├── tmr3.c
│ └── tmr3.h
│ └── nbproject
│ ├── Makefile-default.mk
│ ├── Makefile-genesis.properties
│ ├── Makefile-genesis.properties.mine
│ ├── Makefile-impl.mk
│ ├── Makefile-local-default.mk
│ ├── Makefile-variables.mk
│ ├── Package-default.bash
│ ├── configurations.xml
│ ├── private
│ ├── SuppressibleMessageMemo.properties
│ ├── configurations.xml
│ ├── private.xml
│ ├── private.xml.2.mine
│ ├── private.xml.mine
│ ├── private.xml.r178
│ ├── private.xml.r183
│ ├── private.xml.r28
│ └── private.xml.r30
│ └── project.xml
├── Hardware
├── BOM
│ └── Bill of Materials-I2CNavKey.xls
├── Gerber
│ ├── I2CNavKey.GBL
│ ├── I2CNavKey.GBO
│ ├── I2CNavKey.GBP
│ ├── I2CNavKey.GBS
│ ├── I2CNavKey.GKO
│ ├── I2CNavKey.GTL
│ ├── I2CNavKey.GTO
│ ├── I2CNavKey.GTS
│ └── I2CNavKey.TXT
├── I2CNavKey Schematic.pdf
├── Pick Place
│ └── Pick Place for I2CNavKey.txt
└── STEP
│ └── I2CNavKey.step
├── I2CNavKey_back.jpg
├── I2CNavKey_buttons.jpg
├── I2CNavKey_v1.3.pdf
├── I2CNavKey_v1.4.pdf
├── LICENSE
├── OSHW_mark_IT000005.png
├── Python Raspberry Library
├── Examples
│ └── I2CNavKey_basic.py
├── README.md
└── Source
│ └── i2cNavKeyLib.py
└── README.md
/Firmware/Binary Rev1.0/I2CNavKey.X.production.elf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/Firmware/Binary Rev1.0/I2CNavKey.X.production.elf
--------------------------------------------------------------------------------
/Firmware/Binary Rev1.0/I2CNavKey.X.production.mum:
--------------------------------------------------------------------------------
1 |
2 | Memory Summary:
3 | Program space used 160Eh ( 5646) of 2000h words ( 68.9%)
4 | Data space used 8Bh ( 139) of 400h bytes ( 13.6%)
5 | EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
6 | Data stack space used 0h ( 0) of 365h bytes ( 0.0%)
7 | Configuration bits used 4h ( 4) of 4h words (100.0%)
8 | ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
9 |
10 |
--------------------------------------------------------------------------------
/Firmware/Binary Rev1.0/I2CNavKey.X.production.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/Firmware/Binary Rev1.0/I2CNavKey.X.production.o
--------------------------------------------------------------------------------
/Firmware/Binary Rev1.0/I2CNavKey.X.production.rlf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/Firmware/Binary Rev1.0/I2CNavKey.X.production.rlf
--------------------------------------------------------------------------------
/Firmware/Binary Rev1.0/memoryfile.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | words
6 | 8192
7 | 5646
8 | 2546
9 |
10 |
11 | bytes
12 | 1024
13 | 139
14 | 885
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/DataVariable.c:
--------------------------------------------------------------------------------
1 |
2 | #include "DataVariable.h"
3 | #include "mcc_generated_files/mcc.h"
4 | #include "main.h"
5 | #include "GPports.h"
6 | #include
7 |
8 | volatile uint8_t i2c_address;
9 |
10 |
11 | /** Internal register **/
12 |
13 | /** Configuration **/
14 | volatile uint8_t GCONF = 0; //address 0x00
15 | /** GPIO_CONF **/
16 | volatile uint8_t GP1CONF = 0; //address 0x01
17 | volatile uint8_t GP2CONF = 0; //address 0x02
18 | volatile uint8_t GP3CONF = 0; //address 0x03
19 |
20 | /** INTCONF_CONF **/
21 | volatile union Data_s INTCONF = 0; //address 0x04 - 0x05
22 |
23 | /** Status **/
24 | volatile union Data_s NSTATUS; //address 0x06 - 0x07
25 | volatile uint8_t SSTATUS; //address 0x08
26 | volatile uint8_t FSTATUS; //address 0x09
27 |
28 | /** Data Value **/
29 | volatile union Data_l CVAL; //address 0x0A - 0x0D
30 | volatile union Data_l CMAX; //address 0x0E - 0x11
31 | volatile union Data_l CMIN; //address 0x12 - 0x15
32 | volatile union Data_l ISTEP; //address 0x16 - 0x19
33 |
34 |
35 | /** GPx register **/
36 | volatile uint8_t GP1REG = 0; //address 0x1A
37 | volatile uint8_t GP2REG = 0; //address 0x1B
38 | volatile uint8_t GP3REG = 0; //address 0x1C
39 |
40 | /** Timing register **/
41 | volatile uint8_t DPPERIOD; //address 0x1D
42 | volatile uint8_t FADEGP; //address 0x1E
43 |
44 | /* Gamma register */
45 | volatile uint8_t GAMMAGP1; //address 0x1F
46 | volatile uint8_t GAMMAGP2; //address 0x20
47 | volatile uint8_t GAMMAGP3; //address 0x21
48 |
49 | /** General configuration bit **/
50 | volatile bool C_RESET, C_MBANK, C_CKSRC, C_IPUD, C_DIRE, C_WRAPE, C_DTYPE;
51 |
52 | volatile uint16_t DoublePush;
53 |
54 | void DataInitSet(void) {
55 | GCONF = 0;
56 | GP1CONF = 0;
57 | GP3CONF = 0;
58 | INTCONF.val = 0;
59 | NSTATUS.val = 0;
60 | CVAL.val = 0;
61 | CMAX.val = 0;
62 | CMIN.val = 0;
63 | ISTEP.val = 1;
64 | GP1REG = 0;
65 | GP2REG = 0;
66 | GP3REG = 0;
67 | C_RESET = false;
68 | C_MBANK = false;
69 | C_CKSRC = false;
70 | C_IPUD = false;
71 | C_DIRE = false;
72 | C_WRAPE = false;
73 | C_DTYPE = false;
74 |
75 | DPPERIOD = 0;
76 | FADEGP = 0;
77 | GAMMAGP1=0;
78 | GAMMAGP2=0;
79 | GAMMAGP3=0;
80 | DoublePush = 0;
81 | }
82 |
83 | /**
84 | * @brief Function that split the configuration byte in the single bit
85 | */
86 | void GeneralDataSplit(void) {
87 |
88 | C_DTYPE = GCONF & 0x01U;
89 | C_WRAPE = (bool) (GCONF >> 1) & 0x01U;
90 | C_DIRE = (bool) (GCONF >> 2) & 0x01U;
91 | C_IPUD = (bool) (GCONF >> 3) & 0x01U;
92 | C_CKSRC = (bool) (GCONF >> 4) & 0x01U;
93 | C_MBANK = (bool) (GCONF >> 5) & 0x01U;
94 | C_RESET = (bool) (GCONF >> 7) & 0x01U;
95 |
96 | }
97 |
98 | /**
99 | * @brief Function for update the status variable
100 | * @param stat Status of the encoder from ::ENCODER_STATUS_CASE
101 | */
102 | void NavKeyStatusUpdate(ENCODER_STATUS_CASE stat) {
103 | NSTATUS.val |= (uint16_t) stat;
104 | }
105 |
106 | /**
107 | * @brief Function for update the status variable of the GP pins
108 | * @param stat Status of the encoder from GP_STATUS_CASE
109 | */
110 | void Int2StatusUpdate(INT2_STATUS_CASE stat) {
111 | SSTATUS |= (uint8_t) stat;
112 | NavKeyStatusUpdate(S_INT2);
113 | }
114 |
115 | /**
116 | * @brief Function for clear the status of the encoder
117 | */
118 | void StatusClear(void) {
119 | NSTATUS.val = 0;
120 | }
121 |
122 | /**
123 | * @brief Function for clear the status of the GPz pins
124 | */
125 | void Int2StatusClear(void) {
126 | SSTATUS = 0;
127 | }
128 |
129 | /**
130 | * @brief Function for update the status of the fading process
131 | * @param stat Status of the fade process from FADE_STATUS_CASE
132 | */
133 | void FadeProcessSet(FADE_STATUS_CASE stat) {
134 | FSTATUS |= (uint8_t) stat;
135 | }
136 |
137 | /**
138 | * @brief Function for clear a bit of the fading process
139 | * @param stat Status of the fade process from FADE_STATUS_CASE
140 | */
141 | void FadeProcessClear(FADE_STATUS_CASE stat) {
142 | FSTATUS &= ~(uint8_t) stat;
143 | Int2StatusUpdate(E_GPFADE);
144 |
145 | SetInterrupt();
146 | }
147 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/DataVariable.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: DataVariable.h
3 | * Author: Saimon
4 | *
5 | * Created on 11 settembre 2017, 21.20
6 | */
7 |
8 | #ifndef DATAVARIABLE_H
9 | #define DATAVARIABLE_H
10 |
11 | #include
12 | #include
13 |
14 | #define IDVALUE 0x5B
15 | #define BOARD_VERSION 0x12
16 |
17 |
18 | extern volatile uint8_t i2c_address;
19 |
20 | extern volatile uint8_t I2C1_slaveWriteData;
21 |
22 | extern volatile bool DataType;
23 | #define INT_DATA_TYPE false
24 | #define FLOAT_DATA_TYPE true
25 |
26 | #define RGB_ENCODER true
27 | #define STD_ENCODER false
28 |
29 | union Data_l {
30 | double fval;
31 | int32_t val;
32 | uint8_t bval[4];
33 |
34 | };
35 |
36 | union Data_s {
37 | uint16_t val;
38 | uint8_t bval[2];
39 |
40 | };
41 |
42 | /** Internal register **/
43 | /** Configuration **/
44 | extern volatile uint8_t GCONF; //address 0x00
45 | /** GPIO_CONF **/
46 | extern volatile uint8_t GP1CONF; //address 0x01
47 | extern volatile uint8_t GP2CONF; //address 0x02
48 | extern volatile uint8_t GP3CONF; //address 0x03
49 |
50 | /** INTCONF_CONF **/
51 | extern volatile union Data_s INTCONF; //address 0x04 - 0x05
52 |
53 | /** Status **/
54 | extern volatile union Data_s NSTATUS; //address 0x06 - 0x07
55 | extern volatile uint8_t SSTATUS; //address 0x08
56 | extern volatile uint8_t FSTATUS; //address 0x09
57 |
58 | /** Data Value **/
59 | extern volatile union Data_l CVAL; //address 0x0A - 0x0D
60 | extern volatile union Data_l CMAX; //address 0x0E - 0x11
61 | extern volatile union Data_l CMIN; //address 0x12 - 0x15
62 | extern volatile union Data_l ISTEP; //address 0x16 - 0x19
63 |
64 |
65 | /** GPx register **/
66 | extern volatile uint8_t GP1REG; //address 0x1A
67 | extern volatile uint8_t GP2REG; //address 0x1B
68 | extern volatile uint8_t GP3REG; //address 0x1C
69 |
70 | /** Timing register **/
71 | extern volatile uint8_t DPPERIOD; //address 0x1D
72 | extern volatile uint8_t FADEGP; //address 0x1E
73 |
74 | /* Gamma register */
75 | extern volatile uint8_t GAMMAGP1; //address 0x1F
76 | extern volatile uint8_t GAMMAGP2; //address 0x20
77 | extern volatile uint8_t GAMMAGP3; //address 0x21
78 |
79 | /** General configuration bit **/
80 | extern volatile bool C_RESET, C_MBANK, C_CKSRC, C_IPUD, C_DIRE, C_WRAPE, C_DTYPE;
81 |
82 | extern volatile uint16_t DoublePush;
83 |
84 |
85 |
86 |
87 | /* GP register setting */
88 | #define GPMODE 0x03
89 | #define GPPULLUP 0x04
90 | #define GPINNT 0x18
91 | /* GP MODE configuration */
92 | #define GP_PWM 0x00
93 | #define GP_OUT 0x01
94 | #define GP_ADC 0x02
95 | #define GP_IN 0x03
96 | /* GP pull-up configuration */
97 | #define GP_PULLDI 0x00
98 | #define GP_PULLEN 0x04
99 | /* GP Interrupt configuration */
100 | #define GP_NOINT 0x00
101 | #define GP_POSED 0x08
102 | #define GP_NEGED 0x10
103 | #define GP_BOTHED 0x18
104 |
105 | typedef enum {
106 | S_UPR = 0x0001,
107 | S_UPP = 0x0002,
108 | S_DNR = 0x0004,
109 | S_DNP = 0x0008,
110 | S_RTR = 0x0010,
111 | S_RTP = 0x0020,
112 | S_LTR = 0x0040,
113 | S_LTP = 0x0080,
114 | S_CTRR = 0x0100,
115 | S_CTRP = 0x0200,
116 | S_CTRDP = 0x0400,
117 | S_RINC = 0x0800,
118 | S_RDEC = 0x1000,
119 | S_RMAX = 0x2000,
120 | S_RMIN = 0x4000,
121 | S_INT2 = 0x8000,
122 | } ENCODER_STATUS_CASE;
123 |
124 | typedef enum {
125 | E_GP1POS = 0x01,
126 | E_GP1NEG = 0x02,
127 | E_GP2POS = 0x04,
128 | E_GP2NEG = 0x08,
129 | E_GP3POS = 0x10,
130 | E_GP3NEG = 0x20,
131 | E_GPFADE = 0x40,
132 | } INT2_STATUS_CASE;
133 |
134 | typedef enum {
135 | F_FGP1 = 0x01,
136 | F_FGP2 = 0x02,
137 | F_FGP3 = 0x04,
138 | } FADE_STATUS_CASE;
139 |
140 |
141 |
142 | void DataInitSet(void);
143 | void GeneralDataSplit(void);
144 | void NavKeyStatusUpdate(ENCODER_STATUS_CASE stat);
145 | void Int2StatusUpdate(INT2_STATUS_CASE stat);
146 | void FadeProcessSet(FADE_STATUS_CASE stat);
147 | void StatusClear(void);
148 | void Int2StatusClear(void);
149 | void FadeProcessClear(FADE_STATUS_CASE stat);
150 |
151 | #endif /* DATAVARIABLE_H */
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/GPports.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GPports.h
3 | * Author: Saimon
4 | *
5 | * Created on 8 aprile 2018, 22.13
6 | */
7 |
8 | #ifndef GPPORTS_H
9 | #define GPPORTS_H
10 |
11 | #ifdef __cplusplus
12 | extern "C" {
13 | #endif
14 |
15 |
16 | #define GPIOMASKPOSINT 0x08
17 | #define GPIOMASKNEGINT 0x10
18 |
19 | typedef enum {
20 | GP_CHECKMODE,
21 | GP_ADC_MODE,
22 | GP_WAITRISE,
23 | GP_WAITFALL,
24 | } GP_STATUS;
25 |
26 |
27 |
28 | void RGB_EncoderMode(void);
29 | void STD_EncoderMode(void);
30 |
31 | void Config_GP1(void);
32 | void Config_GP2(void);
33 | void Config_GP3(void);
34 |
35 | void UpdateOut_GP1(void);
36 | void UpdateOut_GP2(void);
37 | void UpdateOut_GP3(void);
38 |
39 |
40 |
41 | void GP1_FSM(void);
42 | void GP2_FSM(void);
43 | void GP3_FSM(void);
44 | void FADE_GPPort1(void);
45 | void FADE_GPPort2(void);
46 | void FADE_GPPort3(void);
47 | void GP_Ports_FSM(void);
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 |
52 | #endif /* GPPORTS_H */
53 |
54 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # There exist several targets which are by default empty and which can be
3 | # used for execution of your targets. These targets are usually executed
4 | # before and after some main targets. They are:
5 | #
6 | # .build-pre: called before 'build' target
7 | # .build-post: called after 'build' target
8 | # .clean-pre: called before 'clean' target
9 | # .clean-post: called after 'clean' target
10 | # .clobber-pre: called before 'clobber' target
11 | # .clobber-post: called after 'clobber' target
12 | # .all-pre: called before 'all' target
13 | # .all-post: called after 'all' target
14 | # .help-pre: called before 'help' target
15 | # .help-post: called after 'help' target
16 | #
17 | # Targets beginning with '.' are not intended to be called on their own.
18 | #
19 | # Main targets can be executed directly, and they are:
20 | #
21 | # build build a specific configuration
22 | # clean remove built files from a configuration
23 | # clobber remove all built files
24 | # all build all configurations
25 | # help print help mesage
26 | #
27 | # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28 | # .help-impl are implemented in nbproject/makefile-impl.mk.
29 | #
30 | # Available make variables:
31 | #
32 | # CND_BASEDIR base directory for relative paths
33 | # CND_DISTDIR default top distribution directory (build artifacts)
34 | # CND_BUILDDIR default top build directory (object files, ...)
35 | # CONF name of current configuration
36 | # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
37 | # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
38 | # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
39 | # CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
40 | # CND_PACKAGE_NAME_${CONF} name of package (current configuration)
41 | # CND_PACKAGE_PATH_${CONF} path to package (current configuration)
42 | #
43 | # NOCDDL
44 |
45 |
46 | # Environment
47 | MKDIR=mkdir
48 | CP=cp
49 | CCADMIN=CCadmin
50 | RANLIB=ranlib
51 |
52 |
53 | # build
54 | build: .build-post
55 |
56 | .build-pre:
57 | # Add your pre 'build' code here...
58 |
59 | .build-post: .build-impl
60 | # Add your post 'build' code here...
61 |
62 |
63 | # clean
64 | clean: .clean-post
65 |
66 | .clean-pre:
67 | # Add your pre 'clean' code here...
68 | # WARNING: the IDE does not call this target since it takes a long time to
69 | # simply run make. Instead, the IDE removes the configuration directories
70 | # under build and dist directly without calling make.
71 | # This target is left here so people can do a clean when running a clean
72 | # outside the IDE.
73 |
74 | .clean-post: .clean-impl
75 | # Add your post 'clean' code here...
76 |
77 |
78 | # clobber
79 | clobber: .clobber-post
80 |
81 | .clobber-pre:
82 | # Add your pre 'clobber' code here...
83 |
84 | .clobber-post: .clobber-impl
85 | # Add your post 'clobber' code here...
86 |
87 |
88 | # all
89 | all: .all-post
90 |
91 | .all-pre:
92 | # Add your pre 'all' code here...
93 |
94 | .all-post: .all-impl
95 | # Add your post 'all' code here...
96 |
97 |
98 | # help
99 | help: .help-post
100 |
101 | .help-pre:
102 | # Add your pre 'help' code here...
103 |
104 | .help-post: .help-impl
105 | # Add your post 'help' code here...
106 |
107 |
108 |
109 | # include project implementation makefile
110 | include nbproject/Makefile-impl.mk
111 |
112 | # include project make variables
113 | include nbproject/Makefile-variables.mk
114 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/NavKey.c:
--------------------------------------------------------------------------------
1 | #include "i2c_register.h"
2 | #include "mcc_generated_files/mcc.h"
3 | #include "mcc_generated_files/adc.h"
4 | #include "main.h"
5 | #include "GPports.h"
6 | #include "DataVariable.h"
7 | #include "NavKey.h"
8 |
9 |
10 | uint8_t pb_fsm = NavKey_WAITPUSH;
11 | int8_t pb_cnt[5] = 0;
12 | uint16_t double_push_cnt = 0;
13 | bool NavKey_PBtemp[5] = {false};
14 | bool NavKey_PBstatus[5] = {false};
15 |
16 | uint16_t en_deb = 0;
17 | uint8_t en_prev = 0;
18 | #define ENC_1 0
19 | #define ENC_2 1
20 |
21 | /**
22 | * @brief function that is called on one direction of the encoder
23 | */
24 | void CLC_1_Interrupt(void) {
25 |
26 | if (en_prev == ENC_2)
27 | if (en_deb < ENC_DEBOUNCE)
28 | return;
29 |
30 |
31 | en_deb = 0;
32 | en_prev = ENC_1;
33 |
34 | if (C_DTYPE == INT_DATA_TYPE) {
35 | CVAL.val = CVAL.val + ISTEP.val;
36 | NavKeyStatusUpdate(S_RINC);
37 | if (CVAL.val > CMAX.val) {
38 | NavKeyStatusUpdate(S_RMAX);
39 | if (C_WRAPE == true) {
40 | CVAL.val = CMIN.val;
41 | } else {
42 | CVAL.val = CMAX.val;
43 | }
44 | }
45 | } else {
46 | CVAL.fval = CVAL.fval + ISTEP.fval;
47 | NavKeyStatusUpdate(S_RINC);
48 | if (CVAL.fval > CMAX.fval) {
49 | NavKeyStatusUpdate(S_RMAX);
50 | if (C_WRAPE == true) {
51 | CVAL.fval = CMIN.fval;
52 | } else {
53 | CVAL.fval = CMAX.fval;
54 | }
55 | }
56 | }
57 |
58 |
59 | SetInterrupt();
60 | }
61 |
62 | /**
63 | * @brief function that is called on the other direction of the encoder
64 | */
65 |
66 | void CLC_2_Interrupt(void) {
67 |
68 | if (en_prev == ENC_1)
69 | if (en_deb < ENC_DEBOUNCE)
70 | return;
71 |
72 | en_deb = 0;
73 | en_prev = ENC_2;
74 |
75 | if (C_DTYPE == INT_DATA_TYPE) {
76 |
77 | CVAL.val = CVAL.val - ISTEP.val;
78 | NavKeyStatusUpdate(S_RDEC);
79 | if (CVAL.val < CMIN.val) {
80 | NavKeyStatusUpdate(S_RMIN);
81 | if (C_WRAPE == true) {
82 | CVAL.val = CMAX.val;
83 | } else {
84 | CVAL.val = CMIN.val;
85 | }
86 | }
87 | } else {
88 | CVAL.fval = CVAL.fval - ISTEP.fval;
89 | NavKeyStatusUpdate(S_RDEC);
90 | if (CVAL.fval < CMIN.fval) {
91 | NavKeyStatusUpdate(S_RMIN);
92 | if (C_WRAPE == true) {
93 | CVAL.fval = CMAX.fval;
94 | } else {
95 | CVAL.fval = CMIN.fval;
96 | }
97 | }
98 | }
99 |
100 | SetInterrupt();
101 | }
102 |
103 | /**
104 | * @brief function that make a anti-bouncing of the switch, must be called every 1ms
105 | * @return true if pressed, false if released
106 | */
107 | void NavKeySwitch_KeyFilter(void) {
108 | uint8_t i;
109 |
110 | NavKey_PBtemp[0] = S1_GetValue();
111 | NavKey_PBtemp[1] = S2_GetValue();
112 | NavKey_PBtemp[2] = S3_GetValue();
113 | NavKey_PBtemp[3] = S4_GetValue();
114 | NavKey_PBtemp[4] = S5_GetValue();
115 |
116 | for (i = 0; i < 5; i++) {
117 | if (NavKey_PBtemp[i] == PB_PRESSED) {
118 | if (pb_cnt[i]++ >= PB_DEBOUNCE) {
119 | pb_cnt[i] = PB_DEBOUNCE;
120 | NavKey_PBstatus[i] = true;
121 | }
122 | } else {
123 | if (pb_cnt[i]-- <= 0) {
124 | pb_cnt[i] = 0;
125 | NavKey_PBstatus[i] = false;
126 | }
127 | }
128 | }
129 | }
130 |
131 | /*
132 | @brief Central button FSM. It's check when the button is pressed, released and double pushed
133 | */
134 |
135 | void NavKey_CentralButton_FSM(void) {
136 |
137 | if (double_push_cnt > DoublePush) {
138 | pb_fsm = NavKey_TIMEOUT;
139 | } else {
140 | double_push_cnt++;
141 | }
142 |
143 | switch (pb_fsm) {
144 | case NavKey_WAITPUSH:
145 | double_push_cnt = 0;
146 | if (NavKey_PBstatus[CTR_KEY] == true) {
147 | pb_fsm = NavKey_WAITRELEASE;
148 | }
149 | break;
150 |
151 |
152 | case NavKey_WAITRELEASE:
153 | if (NavKey_PBstatus[CTR_KEY] == false) {
154 | pb_fsm = NavKey_WAITDOUBLEPUSH;
155 | }
156 | break;
157 |
158 | case NavKey_WAITDOUBLEPUSH:
159 | if (NavKey_PBstatus[CTR_KEY] == true) {
160 | pb_fsm = NavKey_WAITDOUBLERELEASED;
161 | }
162 | break;
163 |
164 | case NavKey_WAITDOUBLERELEASED:
165 | if (NavKey_PBstatus[CTR_KEY] == false) {
166 | double_push_cnt = 0;
167 | pb_fsm = NavKey_WAITPUSH;
168 | NavKeyStatusUpdate(S_CTRDP);
169 | SetInterrupt();
170 | }
171 | break;
172 |
173 | case NavKey_TIMEOUT:
174 | double_push_cnt = 0;
175 | NavKeyStatusUpdate(S_CTRP);
176 | if (NavKey_PBstatus[CTR_KEY] == true) {
177 | pb_fsm = NavKey_PUSHRESET;
178 | } else {
179 | pb_fsm = NavKey_WAITPUSH;
180 | NavKeyStatusUpdate(S_CTRR);
181 | }
182 | SetInterrupt();
183 | break;
184 |
185 | case NavKey_PUSHRESET:
186 | double_push_cnt = 0;
187 | if (NavKey_PBstatus[CTR_KEY] == false) {
188 |
189 | pb_fsm = NavKey_WAITPUSH;
190 | NavKeyStatusUpdate(S_CTRR);
191 | SetInterrupt();
192 | }
193 | break;
194 | }
195 | }
196 |
197 | /*
198 | @brief It's check when the UP button is pressed or released
199 | */
200 |
201 | void NavKey_UPButton_FSM(void) {
202 | static uint8_t up_fsm;
203 |
204 | switch (up_fsm) {
205 |
206 | case NavKey_WAITPUSH:
207 | if (NavKey_PBstatus[UP_KEY] == true) {
208 | up_fsm = NavKey_WAITRELEASE;
209 | NavKeyStatusUpdate(S_UPP);
210 | SetInterrupt();
211 | }
212 | break;
213 |
214 | case NavKey_WAITRELEASE:
215 | if (NavKey_PBstatus[UP_KEY] == false) {
216 | up_fsm = NavKey_WAITPUSH;
217 | NavKeyStatusUpdate(S_UPR);
218 | SetInterrupt();
219 | }
220 | break;
221 |
222 | default:
223 | up_fsm = NavKey_WAITPUSH;
224 | break;
225 | }
226 | }
227 |
228 | /*
229 | @brief It's check when the DOWN button is pressed or released
230 | */
231 |
232 | void NavKey_DWButton_FSM(void) {
233 | static uint8_t dn_fsm;
234 |
235 | switch (dn_fsm) {
236 |
237 | case NavKey_WAITPUSH:
238 | if (NavKey_PBstatus[DN_KEY] == true) {
239 | dn_fsm = NavKey_WAITRELEASE;
240 | NavKeyStatusUpdate(S_DNP);
241 | SetInterrupt();
242 | }
243 | break;
244 |
245 | case NavKey_WAITRELEASE:
246 | if (NavKey_PBstatus[DN_KEY] == false) {
247 | dn_fsm = NavKey_WAITPUSH;
248 | NavKeyStatusUpdate(S_DNR);
249 | SetInterrupt();
250 | }
251 | break;
252 |
253 | default:
254 | dn_fsm = NavKey_WAITPUSH;
255 | break;
256 | }
257 | }
258 |
259 | /*
260 | @brief It's check when the RIGHT button is pressed or released
261 | */
262 |
263 | void NavKey_RTButton_FSM(void) {
264 | static uint8_t rt_fsm;
265 |
266 | switch (rt_fsm) {
267 |
268 | case NavKey_WAITPUSH:
269 | if (NavKey_PBstatus[RT_KEY] == true) {
270 | rt_fsm = NavKey_WAITRELEASE;
271 | NavKeyStatusUpdate(S_RTP);
272 | SetInterrupt();
273 | }
274 | break;
275 |
276 | case NavKey_WAITRELEASE:
277 | if (NavKey_PBstatus[RT_KEY] == false) {
278 | rt_fsm = NavKey_WAITPUSH;
279 | NavKeyStatusUpdate(S_RTR);
280 | SetInterrupt();
281 | }
282 | break;
283 |
284 | default:
285 | rt_fsm = NavKey_WAITPUSH;
286 | break;
287 | }
288 | }
289 |
290 | /*
291 | @brief It's check when the LEFT button is pressed or released
292 | */
293 |
294 | void NavKey_LTButton_FSM(void) {
295 | static uint8_t lt_fsm;
296 |
297 | switch (lt_fsm) {
298 |
299 | case NavKey_WAITPUSH:
300 | if (NavKey_PBstatus[LT_KEY] == true) {
301 | lt_fsm = NavKey_WAITRELEASE;
302 | NavKeyStatusUpdate(S_LTP);
303 | SetInterrupt();
304 | }
305 | break;
306 |
307 | case NavKey_WAITRELEASE:
308 | if (NavKey_PBstatus[LT_KEY] == false) {
309 | lt_fsm = NavKey_WAITPUSH;
310 | NavKeyStatusUpdate(S_LTR);
311 | SetInterrupt();
312 | }
313 | break;
314 |
315 | default:
316 | lt_fsm = NavKey_WAITPUSH;
317 | break;
318 | }
319 | }
320 |
321 | /*
322 | @brief FMS for managing the RGB led fade, the push button and the debounce of the encoder
323 | */
324 | void NavKey_FSM(void) {
325 |
326 |
327 | if (en_deb < ENC_DEBOUNCE) {
328 | en_deb++;
329 | }
330 |
331 | NavKeySwitch_KeyFilter();
332 | NavKey_CentralButton_FSM();
333 | NavKey_UPButton_FSM();
334 | NavKey_DWButton_FSM();
335 | NavKey_RTButton_FSM();
336 | NavKey_LTButton_FSM();
337 | }
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/NavKey.h:
--------------------------------------------------------------------------------
1 | #ifndef NAVKEY_H
2 | #define NAVKEY_H
3 |
4 | #include // include processor files - each processor file is guarded.
5 |
6 |
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif /* __cplusplus */
10 |
11 | #define ENC_DEBOUNCE 10
12 | #define PB_DEBOUNCE 5
13 | #define PB_PRESSED false // logic of the button is negated
14 | #define PB_RELEASED true
15 | #define CTR_KEY 0
16 | #define DN_KEY 1
17 | #define RT_KEY 2
18 | #define UP_KEY 3
19 | #define LT_KEY 4
20 |
21 |
22 |
23 |
24 |
25 | /** FSM for the push button **/
26 | typedef enum {
27 | NavKey_WAITPUSH,
28 | NavKey_WAITRELEASE,
29 | NavKey_WAITDOUBLEPUSH,
30 | NavKey_WAITDOUBLERELEASED,
31 | NavKey_TIMEOUT,
32 | NavKey_PUSHRESET,
33 | } NavKey_SWITCH_STATUS;
34 |
35 | bool NavKeySwitch_GetValue(void);
36 | bool NavKeySwitch_GetValueFiltered(void);
37 | void CLC_1_Interrupt(void);
38 | void CLC_2_Interrupt(void);
39 | void NavKey_PushButton_FSM(void);
40 | void NavKey_FSM(void);
41 |
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif /* __cplusplus */
46 |
47 | #endif /* XC_HEADER_TEMPLATE_H */
48 |
49 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/PWM.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: PWM.c
3 | * Author: Saimon
4 | *
5 | * Created on March 16, 2019, 3:22 PM
6 | */
7 |
8 | //#include
9 | #include "i2c_register.h"
10 | #include "mcc_generated_files/mcc.h"
11 | #include "PWM.h"
12 | #include "main.h"
13 | #include "GPports.h"
14 | #include "DataVariable.h"
15 |
16 |
17 | const uint16_t gamma_table[7][100] = {
18 | { 1013, 1003, 992, 982, 972, 962, 951, 941, 931, 921, 910, 900, 890, 880, 870, 859, 849, 839, 829, 818, 808, 798, 788, 777, 767, 757, 747, 737, 726, 716, 706, 696, 685, 675, 665, 655, 644, 634, 624, 614, 604, 593, 583, 573, 563, 552, 542, 532, 522, 511, 501, 491, 481, 471, 460, 450, 440, 430, 419, 409, 399, 389, 379, 368, 358, 348, 338, 327, 317, 307, 297, 286, 276, 266, 256, 246, 235, 225, 215, 205, 194, 184, 174, 164, 153, 143, 133, 123, 113, 102, 92, 82, 72, 61, 51, 41, 31, 20, 10, 0}, //Linear
19 | { 1023, 1022, 1021, 1020, 1018, 1017, 1014, 1012, 1010, 1007, 1004, 1000, 997, 993, 989, 985, 981, 976, 972, 967, 961, 956, 950, 945, 939, 932, 926, 920, 913, 906, 899, 891, 884, 876, 868, 860, 852, 844, 835, 826, 817, 808, 799, 790, 780, 770, 760, 750, 740, 729, 719, 708, 697, 686, 674, 663, 651, 639, 627, 615, 603, 590, 578, 565, 552, 539, 525, 512, 498, 485, 471, 457, 442, 428, 413, 399, 384, 369, 354, 338, 323, 307, 291, 276, 259, 243, 227, 210, 194, 177, 160, 143, 125, 108, 90, 72, 55, 37, 18, 0}, //GAMMA 1.8
20 | { 1023, 1023, 1022, 1021, 1020, 1019, 1018, 1016, 1015, 1013, 1011, 1008, 1006, 1003, 1000, 997, 993, 990, 986, 982, 978, 973, 969, 964, 959, 954, 948, 943, 937, 931, 925, 918, 912, 905, 898, 890, 883, 875, 867, 859, 851, 843, 834, 825, 816, 807, 797, 787, 777, 767, 757, 746, 736, 725, 714, 702, 691, 679, 667, 655, 642, 630, 617, 604, 591, 577, 564, 550, 536, 522, 507, 493, 478, 463, 448, 432, 416, 401, 385, 368, 352, 335, 318, 301, 284, 266, 249, 231, 213, 194, 176, 157, 138, 119, 100, 80, 60, 41, 20, 0}, //GAMMA 2.0
21 | { 1023, 1023, 1023, 1022, 1022, 1021, 1020, 1019, 1018, 1017, 1015, 1013, 1012, 1009, 1007, 1005, 1002, 999, 997, 993, 990, 986, 983, 979, 975, 970, 966, 961, 956, 951, 945, 940, 934, 928, 921, 915, 908, 901, 894, 887, 879, 871, 863, 855, 846, 838, 829, 819, 810, 800, 790, 780, 770, 759, 748, 737, 726, 714, 703, 690, 678, 666, 653, 640, 626, 613, 599, 585, 571, 556, 541, 526, 511, 496, 480, 464, 447, 431, 414, 397, 380, 362, 344, 326, 308, 289, 270, 251, 231, 212, 192, 171, 151, 130, 109, 88, 66, 44, 22, 0}, //GAMMA 2.2
22 | { 1023, 1023, 1023, 1023, 1022, 1022, 1021, 1021, 1020, 1019, 1018, 1017, 1015, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 999, 996, 993, 990, 986, 983, 979, 975, 971, 966, 961, 957, 951, 946, 941, 935, 929, 923, 916, 910, 903, 895, 888, 880, 872, 864, 856, 847, 838, 829, 820, 810, 800, 790, 779, 769, 758, 746, 735, 723, 711, 698, 685, 672, 659, 646, 632, 618, 603, 588, 573, 558, 542, 526, 510, 494, 477, 459, 442, 424, 406, 388, 369, 350, 330, 311, 291, 270, 250, 229, 207, 186, 164, 141, 118, 95, 72, 48, 24, 0}, //GAMMA 2.4
23 | { 1023, 1023, 1023, 1023, 1023, 1022, 1022, 1022, 1021, 1020, 1020, 1019, 1018, 1017, 1016, 1014, 1013, 1011, 1009, 1007, 1005, 1003, 1001, 998, 995, 992, 989, 986, 982, 978, 974, 970, 966, 961, 956, 951, 946, 940, 935, 929, 922, 916, 909, 902, 895, 887, 879, 871, 863, 854, 845, 836, 827, 817, 807, 796, 786, 775, 764, 752, 740, 728, 715, 702, 689, 676, 662, 648, 633, 618, 603, 588, 572, 555, 539, 522, 504, 487, 469, 450, 432, 412, 393, 373, 353, 332, 311, 289, 267, 245, 222, 199, 176, 152, 128, 103, 78, 52, 26, 0}, //GAMMA 2.6
24 | { 1023, 1023, 1023, 1023, 1023, 1023, 1022, 1022, 1022, 1021, 1021, 1020, 1020, 1019, 1018, 1017, 1016, 1015, 1013, 1012, 1010, 1008, 1006, 1004, 1002, 999, 997, 994, 991, 988, 984, 981, 977, 973, 969, 964, 960, 955, 950, 944, 939, 933, 927, 920, 914, 907, 899, 892, 884, 876, 868, 859, 850, 841, 831, 821, 811, 800, 790, 778, 767, 755, 742, 730, 717, 703, 690, 676, 661, 646, 631, 615, 599, 583, 566, 549, 531, 513, 494, 475, 456, 436, 416, 395, 374, 352, 330, 308, 285, 261, 237, 213, 188, 163, 137, 110, 84, 56, 28, 0}, //GAMMA 2.8
25 | };
26 |
27 | /*
28 | * @brief Update the PWM value of the GP1
29 | */
30 | void PWM_GP1(uint8_t duty) {
31 |
32 | if (duty == 0) {
33 |
34 | GP1_SetHigh();
35 | UNLOCK_PPS;
36 | RC2PPSbits.RC2PPS = 0x00;
37 | LOCK_PPS;
38 | CCP1CON = 0;
39 | return;
40 | }
41 |
42 | if (duty > 100)
43 | duty = 100;
44 |
45 | if (CCP1CON == 0) {
46 | UNLOCK_PPS;
47 | RC2PPSbits.RC2PPS = 0x0C; //RC2->CCP1:PWM1;
48 | LOCK_PPS;
49 | CCP1CON = 0x8F;
50 | }
51 |
52 | CCPR1H = gamma_table[GAMMAGP1][(uint8_t) (duty - 1)] >> 8;
53 | CCPR1L = gamma_table[GAMMAGP1][(uint8_t) (duty - 1)];
54 |
55 |
56 | }
57 |
58 | /*
59 | * @brief Update the PWM value of the GP2
60 | */
61 | void PWM_GP2(uint8_t duty) {
62 |
63 | if (duty == 0) {
64 |
65 | GP2_SetHigh();
66 | UNLOCK_PPS;
67 | RC1PPSbits.RC1PPS = 0x00;
68 | LOCK_PPS;
69 | CCP2CON = 0;
70 | return;
71 | }
72 |
73 | if (duty > 100)
74 | duty = 100;
75 |
76 | if (CCP2CON == 0) {
77 | UNLOCK_PPS;
78 | RC1PPSbits.RC1PPS = 0x0D; //RC1->CCP2:PWM2;
79 | LOCK_PPS;
80 | CCP2CON = 0x8F;
81 | }
82 |
83 | CCPR2H = gamma_table[GAMMAGP2][(uint8_t) (duty - 1)] >> 8;
84 | CCPR2L = gamma_table[GAMMAGP2][(uint8_t) (duty - 1)];
85 | }
86 |
87 | /*
88 | * @brief Update the PWM value of the GP3
89 | */
90 | void PWM_GP3(uint8_t duty) {
91 |
92 | if (duty == 0) {
93 |
94 | GP3_SetHigh();
95 | UNLOCK_PPS;
96 | RC0PPSbits.RC0PPS = 0x00;
97 | LOCK_PPS;
98 | CCP3CON = 0;
99 | return;
100 | }
101 |
102 | if (duty > 100)
103 | duty = 100;
104 |
105 | if (CCP2CON == 0) {
106 | UNLOCK_PPS;
107 | RC0PPSbits.RC0PPS = 0x0E; //RC0->CCP3:PWM3;
108 | LOCK_PPS;
109 | CCP3CON = 0x8F;
110 | }
111 |
112 | CCPR3H = gamma_table[GAMMAGP3][(uint8_t) (duty - 1)] >> 8;
113 | CCPR3L = gamma_table[GAMMAGP3][(uint8_t) (duty - 1)];
114 | }
115 |
116 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/PWM.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File:
3 | * Author:
4 | * Comments:
5 | * Revision history:
6 | */
7 |
8 | // This is a guard condition so that contents of this file are not included
9 | // more than once.
10 | #ifndef PWM_H
11 | #define PWM_H
12 |
13 |
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif /* __cplusplus */
17 |
18 |
19 | void PWM_GP1(uint8_t duty);
20 | void PWM_GP2(uint8_t duty);
21 | void PWM_GP3(uint8_t duty);
22 | void PWM_Start_CreateGammaTable(void);
23 | void PWM_CreateGammaTable(void);
24 |
25 |
26 |
27 |
28 | #ifdef __cplusplus
29 | }
30 | #endif /* __cplusplus */
31 |
32 | #endif /* XC_HEADER_TEMPLATE_H */
33 |
34 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/i2c_register.c:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "i2c_register.h"
4 | #include "mcc_generated_files/mcc.h"
5 | #include "mcc_generated_files/i2c1.h"
6 | #include "main.h"
7 | #include "GPports.h"
8 | #include "DataVariable.h"
9 | #include "NavKey.h"
10 |
11 |
12 | volatile uint8_t EncoderReg = 0;
13 | volatile bool intclear = false;
14 | volatile bool int2clear = false;
15 |
16 | /**
17 | * @brief Function that set the I2C address according to the A0-A3 jumper setting
18 | */
19 |
20 | void I2C1_AddressSet(void) {
21 | #ifdef CUSTOM_ADD
22 | i2c_address = CUSTOM_ADD;
23 |
24 | #else
25 |
26 | i2c_address = I2C1_SLAVE_ADDRESS;
27 |
28 | ADD0_SetDigitalInput();
29 | ADD1_SetDigitalInput();
30 | ADD2_SetDigitalInput();
31 |
32 | ADD0_SetPullup();
33 | ADD1_SetPullup();
34 | ADD2_SetPullup();
35 | ADD3_SetPullup();
36 |
37 | if (!ADD0_GetValue()) {
38 | i2c_address |= 0x01;
39 | ADD0_ResetPullup();
40 | }
41 |
42 | if (!ADD1_GetValue()) {
43 | i2c_address |= 0x02;
44 | ADD1_ResetPullup();
45 | }
46 |
47 | if (!ADD2_GetValue()) {
48 | i2c_address |= 0x04;
49 | ADD2_ResetPullup();
50 | }
51 |
52 | if (!ADD3_GetValue()) {
53 | i2c_address |= 0x08;
54 | ADD3_ResetPullup();
55 | }
56 |
57 | #endif
58 | i2c_address = (uint8_t) (i2c_address << 1);
59 |
60 |
61 | }
62 |
63 | /**
64 | * @brief Callback for managing the I2C request from the master
65 | * @param i2c_bus_state
66 | */
67 | void I2C1_StatusCallback(I2C1_SLAVE_DRIVER_STATUS i2c_bus_state) {
68 | static uint8_t slaveWriteType = SLAVE_NORMAL_DATA;
69 |
70 | switch (i2c_bus_state) {
71 | case I2C1_SLAVE_WRITE_REQUEST:
72 | // the master will be sending the eeprom address next
73 | slaveWriteType = SLAVE_DATA_ADDRESS;
74 | break;
75 |
76 |
77 | case I2C1_SLAVE_WRITE_COMPLETED:
78 |
79 | switch (slaveWriteType) {
80 | case SLAVE_DATA_ADDRESS:
81 | EncoderReg = I2C1_slaveWriteData;
82 | break;
83 |
84 | case SLAVE_NORMAL_DATA:
85 | default:
86 | RegisterWrite(EncoderReg, I2C1_slaveWriteData);
87 | EncoderReg++;
88 | break;
89 |
90 | } // end switch(slaveWriteType)
91 |
92 | slaveWriteType = SLAVE_NORMAL_DATA;
93 | break;
94 |
95 | case I2C1_SLAVE_READ_REQUEST:
96 | SSP1BUF = RegisterRead(EncoderReg);
97 | EncoderReg++;
98 | break;
99 |
100 | case I2C1_SLAVE_READ_COMPLETED:
101 | if (intclear == true) {
102 | StatusClear();
103 | ClearInterrupt();
104 | intclear = false;
105 | }
106 |
107 | if (int2clear == true) {
108 | Int2StatusClear();
109 | int2clear = false;
110 | }
111 |
112 | break;
113 |
114 | default:
115 | break;
116 |
117 | } // end switch(i2c_bus_state)
118 |
119 | }
120 |
121 | /**
122 | * @brief Function that write inside on the Encoder register
123 | * @param add Address of the internal register
124 | * @param data Data to be written inside of the register
125 | */
126 | void RegisterWrite(uint8_t add, uint8_t data) {
127 |
128 | switch (add) {
129 | case REG_GCONF:
130 | GCONF = data;
131 | GeneralDataSplit();
132 | GeneralDataSet();
133 | break;
134 |
135 | case REG_GP1CONF:
136 | GP1CONF = data;
137 | Config_GP1();
138 | break;
139 |
140 | case REG_GP2CONF:
141 | GP2CONF = data;
142 | Config_GP2();
143 | break;
144 |
145 | case REG_GP3CONF:
146 | GP3CONF = data;
147 | Config_GP3();
148 | break;
149 |
150 | case REG_INTCONFB2:
151 | INTCONF.bval[BYTE2] = data;
152 | break;
153 |
154 | case REG_INTCONFB1:
155 | INTCONF.bval[BYTE1] = data;
156 | break;
157 |
158 | /*** Counter value reg ***/
159 | case REG_CVALB4:
160 | CVAL.bval[BYTE4] = data;
161 | break;
162 | case REG_CVALB3:
163 | CVAL.bval[BYTE3] = data;
164 | break;
165 | case REG_CVALB2:
166 | CVAL.bval[BYTE2] = data;
167 | break;
168 | case REG_CVALB1:
169 | CVAL.bval[BYTE1] = data;
170 | break;
171 |
172 | /*** Max Value ***/
173 | case REG_CMAXB4:
174 | CMAX.bval[BYTE4] = data;
175 | break;
176 | case REG_CMAXB3:
177 | CMAX.bval[BYTE3] = data;
178 | break;
179 | case REG_CMAXB2:
180 | CMAX.bval[BYTE2] = data;
181 | break;
182 | case REG_CMAXB1:
183 | CMAX.bval[BYTE1] = data;
184 | break;
185 |
186 | /*** Min Value ***/
187 | case REG_CMINB4:
188 | CMIN.bval[BYTE4] = data;
189 | break;
190 | case REG_CMINB3:
191 | CMIN.bval[BYTE3] = data;
192 | break;
193 | case REG_CMINB2:
194 | CMIN.bval[BYTE2] = data;
195 | break;
196 | case REG_CMINB1:
197 | CMIN.bval[BYTE1] = data;
198 | break;
199 |
200 | /*** Increment step Value ***/
201 | case REG_ISTEPB4:
202 | ISTEP.bval[BYTE4] = data;
203 | break;
204 | case REG_ISTEPB3:
205 | ISTEP.bval[BYTE3] = data;
206 | break;
207 | case REG_ISTEPB2:
208 | ISTEP.bval[BYTE2] = data;
209 | break;
210 | case REG_ISTEPB1:
211 | ISTEP.bval[BYTE1] = data;
212 | break;
213 |
214 | /* GPs */
215 | case REG_GP1REG:
216 | GP1REG = data;
217 | if (GP1REG > 100)
218 | GP1REG = 100;
219 | UpdateOut_GP1();
220 | break;
221 |
222 | case REG_GP2REG:
223 | GP2REG = data;
224 | if (GP2REG > 100)
225 | GP2REG = 100;
226 | UpdateOut_GP2();
227 | break;
228 |
229 | case REG_GP3REG:
230 | GP3REG = data;
231 | if (GP3REG > 100)
232 | GP3REG = 100;
233 | UpdateOut_GP3();
234 | break;
235 |
236 | // timing register
237 |
238 | case REG_DPPERIOD:
239 | DPPERIOD = data;
240 | DoublePush = ((uint16_t) DPPERIOD * 10);
241 | if (DoublePush > 5) {
242 | DoublePush = DoublePush - 5;
243 | }
244 | break;
245 |
246 | case REG_FADEGP:
247 | FADEGP = data;
248 | break;
249 |
250 | case REG_GAMMAGP1:
251 | GAMMAGP1 = data;
252 | if (GAMMAGP1 > 7) {
253 | GAMMAGP1 = 7;
254 | }
255 | break;
256 | case REG_GAMMAGP2:
257 | GAMMAGP2 = data;
258 | if (GAMMAGP2 > 7) {
259 | GAMMAGP2 = 7;
260 | }
261 | break;
262 | case REG_GAMMAGP3:
263 | GAMMAGP3 = data;
264 | if (GAMMAGP3 > 7) {
265 | GAMMAGP3 = 7;
266 | }
267 | break;
268 |
269 | }
270 |
271 | if (add >= REG_EEPROMS) {
272 |
273 | if (C_MBANK == 0) {
274 | eeprom_write((uint8_t) (add - REG_EEPROMS), (uint8_t) data);
275 |
276 | } else {
277 | eeprom_write((uint8_t) add, (uint8_t) data);
278 | }
279 | }
280 | }
281 |
282 | /**
283 | * @brief Function called when there is a Read request from the i2c master
284 | * @param add Address of the internal register
285 | * @return Value of the internal register, 0 in case of invalid register
286 | */
287 |
288 | uint8_t RegisterRead(uint8_t add) {
289 | uint8_t return_value = 0;
290 |
291 | switch (add) {
292 | case REG_GCONF:
293 | return_value = GCONF;
294 | break;
295 |
296 | case REG_GP1CONF:
297 | return_value = GP1CONF;
298 | break;
299 |
300 | case REG_GP2CONF:
301 | return_value = GP2CONF;
302 | break;
303 |
304 | case REG_GP3CONF:
305 | return_value = GP3CONF;
306 | break;
307 |
308 | case REG_INTCONFB2:
309 | return_value = INTCONF.bval[BYTE2];
310 | break;
311 |
312 | case REG_INTCONFB1:
313 | return_value = INTCONF.bval[BYTE1];
314 | break;
315 |
316 | case REG_STATUSB2:
317 | return_value = NSTATUS.bval[BYTE2];
318 | intclear = true;
319 | break;
320 |
321 | case REG_STATUSB1:
322 | return_value = NSTATUS.bval[BYTE1];
323 | intclear = true;
324 | break;
325 |
326 | case REG_SSTATUS:
327 | return_value = SSTATUS;
328 | int2clear = true;
329 | break;
330 |
331 | case REG_FSTATUS:
332 | return_value = FSTATUS;
333 | break;
334 |
335 | /*** Data Value ***/
336 | case REG_CVALB4:
337 | return_value = CVAL.bval[BYTE4];
338 | break;
339 | case REG_CVALB3:
340 | return_value = CVAL.bval[BYTE3];
341 | break;
342 | case REG_CVALB2:
343 | return_value = CVAL.bval[BYTE2];
344 | break;
345 | case REG_CVALB1:
346 | return_value = CVAL.bval[BYTE1];
347 | break;
348 |
349 | /*** Max Value ***/
350 | case REG_CMAXB4:
351 | return_value = CMAX.bval[BYTE4];
352 | break;
353 | case REG_CMAXB3:
354 | return_value = CMAX.bval[BYTE3];
355 | break;
356 | case REG_CMAXB2:
357 | return_value = CMAX.bval[BYTE2];
358 | break;
359 | case REG_CMAXB1:
360 | return_value = CMAX.bval[BYTE1];
361 | break;
362 |
363 | /*** Min Value ***/
364 | case REG_CMINB4:
365 | return_value = CMIN.bval[BYTE4];
366 | break;
367 | case REG_CMINB3:
368 | return_value = CMIN.bval[BYTE3];
369 | break;
370 | case REG_CMINB2:
371 | return_value = CMIN.bval[BYTE2];
372 | break;
373 | case REG_CMINB1:
374 | return_value = CMIN.bval[BYTE1];
375 | break;
376 |
377 | /*** Increment step Value ***/
378 | case REG_ISTEPB4:
379 | return_value = ISTEP.bval[BYTE4];
380 | break;
381 | case REG_ISTEPB3:
382 | return_value = ISTEP.bval[BYTE3];
383 | break;
384 | case REG_ISTEPB2:
385 | return_value = ISTEP.bval[BYTE2];
386 | break;
387 | case REG_ISTEPB1:
388 | return_value = ISTEP.bval[BYTE1];
389 | break;
390 |
391 | case REG_GP1REG:
392 | return_value = GP1REG;
393 | break;
394 |
395 | case REG_GP2REG:
396 | return_value = GP2REG;
397 | break;
398 |
399 | case REG_GP3REG:
400 | return_value = GP3REG;
401 | break;
402 |
403 | case REG_DPPERIOD:
404 | return_value = DPPERIOD;
405 | break;
406 |
407 | case REG_FADEGP:
408 | return_value = FADEGP;
409 | break;
410 |
411 | case REG_GAMMAGP1:
412 | return_value = GAMMAGP1;
413 | break;
414 |
415 | case REG_GAMMAGP2:
416 | return_value = GAMMAGP2;
417 | break;
418 |
419 | case REG_GAMMAGP3:
420 | return_value = GAMMAGP3;
421 | break;
422 |
423 | case REG_IDCODE:
424 | return_value = IDVALUE;
425 | break;
426 |
427 | case REG_FWVER:
428 | return_value = BOARD_VERSION;
429 | break;
430 |
431 | default:
432 | return_value = 0;
433 | break;
434 |
435 | }
436 | if (add >= REG_EEPROMS) {
437 | if (C_MBANK == 0) {
438 | return_value = eeprom_read((uint8_t) (add - REG_EEPROMS));
439 | } else {
440 | return_value = eeprom_read(add);
441 | }
442 | }
443 | return return_value;
444 | }
445 |
446 | /**
447 | * @brief Function that execute the command according on the configuration register
448 | */
449 | void GeneralDataSet(void) {
450 |
451 | if (C_DIRE == false) {
452 | UNLOCK_PPS;
453 | CLCIN1PPSbits.CLCIN1PPS = 0x14; //RC5->CLC2:CLCIN1;
454 | CLCIN0PPSbits.CLCIN0PPS = 0x15; //RC4->CLC2:CLCIN0;
455 | LOCK_PPS;
456 | } else {
457 | UNLOCK_PPS;
458 | CLCIN1PPSbits.CLCIN1PPS = 0x15; //RC5->CLC2:CLCIN1;
459 | CLCIN0PPSbits.CLCIN0PPS = 0x14; //RC4->CLC2:CLCIN0;
460 | LOCK_PPS;
461 | }
462 |
463 | if (C_IPUD == true) {
464 | INT_ResetPullup();
465 | INT_SetHigh();
466 | } else {
467 | INT_SetPullup();
468 | INT_SetHigh();
469 |
470 | }
471 |
472 |
473 | if (C_CKSRC == true) {
474 | I2C1_Initialize_ClockStreach();
475 | } else {
476 | I2C1_Initialize();
477 | }
478 |
479 | if (C_RESET == true) {
480 | RESET();
481 | }
482 | }
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/i2c_register.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: i2c_register.h
3 | * Author: Saimon
4 | *
5 | * Created on September 9, 2017, 6:08 PM
6 | */
7 |
8 |
9 | #ifndef I2C_REGISTER_H
10 | #define I2C_REGISTER_H
11 |
12 | #include
13 |
14 | /** Default I2C address **/
15 | #define I2C1_SLAVE_ADDRESS 0x10
16 | ///#define CUSTOM_ADD 0b0010000
17 |
18 | /** Internal i2C address definition **/
19 | typedef enum {
20 | REG_GCONF = 0x00,
21 | REG_GP1CONF = 0x01,
22 | REG_GP2CONF = 0x02,
23 | REG_GP3CONF = 0x03,
24 | REG_INTCONFB2 = 0x04,
25 | REG_INTCONFB1 = 0x05,
26 | REG_STATUSB2 = 0x06,
27 | REG_STATUSB1 = 0x07,
28 | REG_SSTATUS = 0x08,
29 | REG_FSTATUS = 0x09,
30 | REG_CVALB4 = 0x0A,
31 | REG_CVALB3 = 0x0B,
32 | REG_CVALB2 = 0x0C,
33 | REG_CVALB1 = 0x0D,
34 | REG_CMAXB4 = 0x0E,
35 | REG_CMAXB3 = 0x0F,
36 | REG_CMAXB2 = 0x10,
37 | REG_CMAXB1 = 0x11,
38 | REG_CMINB4 = 0x12,
39 | REG_CMINB3 = 0x13,
40 | REG_CMINB2 = 0x14,
41 | REG_CMINB1 = 0x15,
42 | REG_ISTEPB4 = 0x16,
43 | REG_ISTEPB3 = 0x17,
44 | REG_ISTEPB2 = 0x18,
45 | REG_ISTEPB1 = 0x19,
46 | REG_GP1REG = 0x1A,
47 | REG_GP2REG = 0x1B,
48 | REG_GP3REG = 0x1C,
49 | REG_DPPERIOD = 0x1D,
50 | REG_FADEGP = 0x1E,
51 | REG_GAMMAGP1 = 0x1F,
52 | REG_GAMMAGP2 = 0x20,
53 | REG_GAMMAGP3 = 0x21,
54 | REG_IDCODE = 0x70,
55 | REG_FWVER = 0x71,
56 | REG_EEPROMS = 0x80,
57 | } I2C1_REGISTER;
58 |
59 | /** MSB or LSB order in 16bit variable **/
60 | #define BYTE1 0
61 | #define BYTE2 1
62 | #define BYTE3 2
63 | #define BYTE4 3
64 |
65 | typedef enum {
66 | I2C1_SLAVE_WRITE_REQUEST,
67 | I2C1_SLAVE_READ_REQUEST,
68 | I2C1_SLAVE_WRITE_COMPLETED,
69 | I2C1_SLAVE_READ_COMPLETED,
70 | } I2C1_SLAVE_DRIVER_STATUS;
71 |
72 | typedef enum {
73 | SLAVE_NORMAL_DATA,
74 | SLAVE_DATA_ADDRESS,
75 | } SLAVE_WRITE_DATA_TYPE;
76 |
77 |
78 | void I2C1_AddressSet(void);
79 |
80 | void I2C1_StatusCallback(I2C1_SLAVE_DRIVER_STATUS i2c_bus_state);
81 |
82 | void RegisterWrite(uint8_t add, uint8_t data);
83 | uint8_t RegisterRead(uint8_t add);
84 | void GeneralDataSet(void);
85 |
86 | #endif /* I2C_REGISTER_H */
87 |
88 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | Generated Main Source File
3 |
4 | Company:
5 | Microchip Technology Inc.
6 |
7 | File Name:
8 | main.c
9 |
10 | Summary:
11 | This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | Description:
14 | This header file provides implementations for driver APIs for all modules selected in the GUI.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18344
18 | Driver Version : 2.00
19 | */
20 |
21 | /*
22 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
23 |
24 | Subject to your compliance with these terms, you may use Microchip software and any
25 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
26 | license terms applicable to your use of third party software (including open source software) that
27 | may accompany Microchip software.
28 |
29 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
30 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
31 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
32 | FOR A PARTICULAR PURPOSE.
33 |
34 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
35 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
36 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
37 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
38 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
39 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
40 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
41 | SOFTWARE.
42 | */
43 |
44 | #include "mcc_generated_files/mcc.h"
45 | #include "i2c_register.h"
46 | #include "main.h"
47 | #include "GPports.h"
48 | #include "DataVariable.h"
49 | #include "NavKey.h"
50 |
51 | bool fsm_tmr = false;
52 |
53 | /**
54 | * @brief Function for set the output interrupt pin
55 | */
56 | void SetInterrupt(void) {
57 |
58 | if ((NSTATUS.val & INTCONF.val) != 0) {
59 | INT_SetLow();
60 | }
61 | }
62 |
63 | /**
64 | * @brief Function for clear the output interrupt pin
65 | */
66 | void ClearInterrupt(void) {
67 | INT_SetHigh();
68 | }
69 |
70 | /**
71 | * @brief Timer 3 interrupt, it's called every 1ms
72 | */
73 | void TimerInt(void) {
74 | fsm_tmr = true;
75 | }
76 |
77 | /*
78 | Main application
79 | */
80 | void main(void) {
81 | // initialize the device
82 | SYSTEM_Initialize();
83 |
84 | // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
85 | // Use the following macros to:
86 |
87 | // Enable the Global Interrupts
88 | INTERRUPT_GlobalInterruptEnable();
89 |
90 | // Enable the Peripheral Interrupts
91 | INTERRUPT_PeripheralInterruptEnable();
92 |
93 | // Disable the Global Interrupts
94 | //INTERRUPT_GlobalInterruptDisable();
95 |
96 | // Disable the Peripheral Interrupts
97 | //INTERRUPT_PeripheralInterruptDisable();
98 |
99 | TMR3_SetInterruptHandler(TimerInt);
100 | DataInitSet();
101 | GP1_SetDigitalInput();
102 | GP2_SetDigitalInput();
103 | GP3_SetDigitalInput();
104 |
105 | TMR3_StartTimer();
106 | ClearInterrupt();
107 |
108 | while (1) {
109 | if (fsm_tmr == true) {
110 |
111 | fsm_tmr = false;
112 | NavKey_FSM();
113 | GP_Ports_FSM();
114 |
115 | }
116 | }
117 | }
118 | /**
119 | End of File
120 | */
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/main.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: main.h
3 | * Author: Saimon
4 | *
5 | * Created on 10 settembre 2017, 11.48
6 | */
7 |
8 | #ifndef MAIN_H
9 | #define MAIN_H
10 |
11 | #define DEBOUNCE_CNT 50 //Debounce of 300us
12 | #define ADC_SAMPLE 4000
13 |
14 | #define LOCK_PPS PPSLOCK = 0x55; PPSLOCK = 0xAA; PPSLOCKbits.PPSLOCKED = 0x01 // lock PPS
15 | #define UNLOCK_PPS PPSLOCK = 0x55; PPSLOCK = 0xAA; PPSLOCKbits.PPSLOCKED = 0x00 // unlock PPS
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | void TimerInt(void);
26 | void SetInterrupt(void);
27 | void ClearInterrupt(void);
28 |
29 | #endif /* MAIN_H */
30 |
31 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/adc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ADC Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | adc.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the ADC driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides implementations for driver APIs for ADC.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "adc.h"
53 | #include "mcc.h"
54 |
55 | /**
56 | Section: Macro Declarations
57 | */
58 |
59 | #define ACQ_US_DELAY 5
60 |
61 | /**
62 | Section: ADC Module APIs
63 | */
64 |
65 | void ADC_Initialize(void)
66 | {
67 | // set the ADC to the options selected in the User Interface
68 |
69 | // ADGO stop; ADON enabled; CHS ANA0;
70 | ADCON0 = 0x01;
71 |
72 | // ADFM right; ADNREF VSS; ADPREF VDD; ADCS FOSC/64;
73 | ADCON1 = 0xE0;
74 |
75 | // ADACT no_auto_trigger;
76 | ADACT = 0x00;
77 |
78 | // ADRESL 0;
79 | ADRESL = 0x00;
80 |
81 | // ADRESH 0;
82 | ADRESH = 0x00;
83 |
84 | }
85 |
86 | void ADC_SelectChannel(adc_channel_t channel)
87 | {
88 | // select the A/D channel
89 | ADCON0bits.CHS = channel;
90 | // Turn on the ADC module
91 | ADCON0bits.ADON = 1;
92 | }
93 |
94 | void ADC_StartConversion()
95 | {
96 | // Start the conversion
97 | ADCON0bits.ADGO = 1;
98 | }
99 |
100 |
101 | bool ADC_IsConversionDone()
102 | {
103 | // Start the conversion
104 | return ((bool)(!ADCON0bits.ADGO));
105 | }
106 |
107 | adc_result_t ADC_GetConversionResult(void)
108 | {
109 | // Conversion finished, return the result
110 | return ((adc_result_t)((ADRESH << 8) + ADRESL));
111 | }
112 |
113 | adc_result_t ADC_GetConversion(adc_channel_t channel)
114 | {
115 | // select the A/D channel
116 | ADCON0bits.CHS = channel;
117 |
118 | // Turn on the ADC module
119 | ADCON0bits.ADON = 1;
120 |
121 | // Acquisition time delay
122 | __delay_us(ACQ_US_DELAY);
123 |
124 | // Start the conversion
125 | ADCON0bits.ADGO = 1;
126 |
127 | // Wait for the conversion to finish
128 | while (ADCON0bits.ADGO)
129 | {
130 | }
131 |
132 | // Conversion finished, return the result
133 | return ((adc_result_t)((ADRESH << 8) + ADRESL));
134 | }
135 |
136 | void ADC_TemperatureAcquisitionDelay(void)
137 | {
138 | __delay_us(200);
139 | }
140 | /**
141 | End of File
142 | */
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/adc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ADC Generated Driver API Header File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | adc.h
9 |
10 | @Summary
11 | This is the generated header file for the ADC driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides APIs for driver for ADC.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef ADC_H
48 | #define ADC_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 | #include
57 |
58 | #ifdef __cplusplus // Provide C++ Compatibility
59 |
60 | extern "C" {
61 |
62 | #endif
63 |
64 | /**
65 | Section: Data Types Definitions
66 | */
67 |
68 | /**
69 | * result size of an A/D conversion
70 | */
71 |
72 | typedef uint16_t adc_result_t;
73 |
74 | /**
75 | * result type of a Double ADC conversion
76 | */
77 | typedef struct
78 | {
79 | adc_result_t adcResult1;
80 | adc_result_t adcResult2;
81 | } adc_sync_double_result_t;
82 |
83 | /** ADC Channel Definition
84 |
85 | @Summary
86 | Defines the channels available for conversion.
87 |
88 | @Description
89 | This routine defines the channels that are available for the module to use.
90 |
91 | Remarks:
92 | None
93 | */
94 |
95 | typedef enum
96 | {
97 | A_GP1 = 0x12, //ANC2
98 | A_GP2 = 0x11, //ANC1
99 | A_GP3 = 0x10, //ANC0
100 | channel_AVSS = 0x3C,
101 | channel_Temp = 0x3D,
102 | channel_DAC1 = 0x3E,
103 | channel_FVR = 0x3F
104 | } adc_channel_t;
105 |
106 | /**
107 | Section: ADC Module APIs
108 | */
109 |
110 | /**
111 | @Summary
112 | Initializes the ADC
113 |
114 | @Description
115 | This routine initializes the Initializes the ADC.
116 | This routine must be called before any other ADC routine is called.
117 | This routine should only be called once during system initialization.
118 |
119 | @Preconditions
120 | None
121 |
122 | @Param
123 | None
124 |
125 | @Returns
126 | None
127 |
128 | @Comment
129 |
130 |
131 | @Example
132 |
133 | uint16_t convertedValue;
134 |
135 | ADC_Initialize();
136 | convertedValue = ADC_GetConversionResult();
137 |
138 | */
139 | void ADC_Initialize(void);
140 |
141 | /**
142 | @Summary
143 | Allows selection of a channel for conversion
144 |
145 | @Description
146 | This routine is used to select desired channel for conversion.
147 | available
148 |
149 | @Preconditions
150 | ADC_Initialize() function should have been called before calling this function.
151 |
152 | @Returns
153 | None
154 |
155 | @Param
156 | Pass in required channel number
157 | "For available channel refer to enum under adc.h file"
158 |
159 | @Example
160 |
161 | uint16_t convertedValue;
162 |
163 | ADC_Initialize();
164 | ADC_SelectChannel(AN1_Channel);
165 | ADC_StartConversion();
166 | convertedValue = ADC_GetConversionResult();
167 |
168 | */
169 | void ADC_SelectChannel(adc_channel_t channel);
170 |
171 | /**
172 | @Summary
173 | Starts conversion
174 |
175 | @Description
176 | This routine is used to start conversion of desired channel.
177 |
178 | @Preconditions
179 | ADC_Initialize() function should have been called before calling this function.
180 |
181 | @Returns
182 | None
183 |
184 | @Param
185 | None
186 |
187 | @Example
188 |
189 | uint16_t convertedValue;
190 |
191 | ADC_Initialize();
192 | ADC_StartConversion();
193 | convertedValue = ADC_GetConversionResult();
194 |
195 | */
196 | void ADC_StartConversion();
197 |
198 | /**
199 | @Summary
200 | Returns true when the conversion is completed otherwise false.
201 |
202 | @Description
203 | This routine is used to determine if conversion is completed.
204 | When conversion is complete routine returns true. It returns false otherwise.
205 |
206 | @Preconditions
207 | ADC_Initialize() and ADC_StartConversion(adc_channel_t channel)
208 | function should have been called before calling this function.
209 |
210 | @Returns
211 | true - If conversion is complete
212 | false - If conversion is not completed
213 |
214 | @Param
215 | None
216 |
217 | @Example
218 |
219 | uint16_t convertedValue;
220 |
221 | ADC_Initialize();
222 | ADC_StartConversion(AN1_Channel);
223 |
224 | while(!ADC_IsConversionDone());
225 | convertedValue = ADC_GetConversionResult();
226 |
227 | */
228 | bool ADC_IsConversionDone();
229 |
230 | /**
231 | @Summary
232 | Returns the ADC conversion value.
233 |
234 | @Description
235 | This routine is used to get the analog to digital converted value. This
236 | routine gets converted values from the channel specified.
237 |
238 | @Preconditions
239 | This routine returns the conversion value only after the conversion is complete.
240 | Completion status can be checked using
241 | ADC_IsConversionDone() routine.
242 |
243 | @Returns
244 | Returns the converted value.
245 |
246 | @Param
247 | None
248 |
249 | @Example
250 |
251 | uint16_t convertedValue;
252 |
253 | ADC_Initialize();
254 | ADC_StartConversion(AN1_Channel);
255 |
256 | while(ADC_IsConversionDone());
257 |
258 | convertedValue = ADC_GetConversionResult();
259 |
260 | */
261 | adc_result_t ADC_GetConversionResult(void);
262 |
263 | /**
264 | @Summary
265 | Returns the ADC conversion value
266 | also allows selection of a channel for conversion.
267 |
268 | @Description
269 | This routine is used to select desired channel for conversion
270 | and to get the analog to digital converted value.
271 |
272 | @Preconditions
273 | ADC_Initialize() function should have been called before calling this function.
274 |
275 | @Returns
276 | Returns the converted value.
277 |
278 | @Param
279 | Pass in required channel number.
280 | "For available channel refer to enum under adc.h file"
281 |
282 | @Example
283 |
284 | uint16_t convertedValue;
285 |
286 | ADC_Initialize();
287 |
288 | conversion = ADC_GetConversion(AN1_Channel);
289 |
290 | */
291 | adc_result_t ADC_GetConversion(adc_channel_t channel);
292 |
293 | /**
294 | @Summary
295 | Acquisition Delay for temperature sensor
296 |
297 | @Description
298 | This routine should be called when temperature sensor is used.
299 |
300 | @Preconditions
301 | ADC_Initialize() function should have been called before calling this function.
302 |
303 | @Returns
304 | None
305 |
306 | @Param
307 | None
308 |
309 | @Example
310 |
311 | uint16_t convertedValue;
312 |
313 | ADC_Initialize();
314 | ADC_StartConversion();
315 | ADC_temperatureAcquisitionDelay();
316 | convertedValue = ADC_GetConversionResult();
317 |
318 | */
319 | void ADC_TemperatureAcquisitionDelay(void);
320 |
321 | #ifdef __cplusplus // Provide C++ Compatibility
322 |
323 | }
324 |
325 | #endif
326 |
327 | #endif //ADC_H
328 | /**
329 | End of File
330 | */
331 |
332 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/clc1.c:
--------------------------------------------------------------------------------
1 | /**
2 | CLC1 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | clc1.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the CLC1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides implementations for driver APIs for CLC1.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45 or later
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "clc1.h"
53 | #include "mcc.h"
54 |
55 | /**
56 | Section: CLC1 APIs
57 | */
58 |
59 | void CLC1_Initialize(void) {
60 | // Set the CLC1 to the options selected in the User Interface
61 |
62 | // LC1G1POL not_inverted; LC1G2POL not_inverted; LC1G3POL inverted; LC1G4POL not_inverted; LC1POL not_inverted;
63 | CLC1POL = 0x04;
64 | // LC1D1S CLCIN0 (CLCIN0PPS);
65 | CLC1SEL0 = 0x00;
66 | // LC1D2S CLCIN1 (CLCIN1PPS);
67 | CLC1SEL1 = 0x01;
68 | // LC1D3S CLCIN1 (CLCIN1PPS);
69 | CLC1SEL2 = 0x01;
70 | // LC1D4S CLCIN1 (CLCIN1PPS);
71 | CLC1SEL3 = 0x01;
72 | // LC1G1D3N disabled; LC1G1D2N disabled; LC1G1D4N disabled; LC1G1D1T enabled; LC1G1D3T disabled; LC1G1D2T disabled; LC1G1D4T disabled; LC1G1D1N disabled;
73 | CLC1GLS0 = 0x02;
74 | // LC1G2D2N disabled; LC1G2D1N disabled; LC1G2D4N disabled; LC1G2D3N disabled; LC1G2D2T enabled; LC1G2D1T disabled; LC1G2D4T enabled; LC1G2D3T enabled;
75 | CLC1GLS1 = 0xA8;
76 | // LC1G3D1N disabled; LC1G3D2N disabled; LC1G3D3N disabled; LC1G3D4N disabled; LC1G3D1T disabled; LC1G3D2T enabled; LC1G3D3T enabled; LC1G3D4T enabled;
77 | CLC1GLS2 = 0xA8;
78 | // LC1G4D1N disabled; LC1G4D2N disabled; LC1G4D3N disabled; LC1G4D4N disabled; LC1G4D1T disabled; LC1G4D2T enabled; LC1G4D3T enabled; LC1G4D4T enabled;
79 | CLC1GLS3 = 0xA8;
80 | // LC1EN enabled; INTN enabled; INTP enabled; MODE 2-input D flip-flop with R;
81 | CLC1CON = 0x9D;
82 |
83 | // Clear the CLC interrupt flag
84 | PIR3bits.CLC1IF = 0;
85 | // Enabling CLC1 interrupt.
86 | PIE3bits.CLC1IE = 1;
87 | }
88 |
89 | void CLC1_ISR(void) {
90 | if (PORTCbits.RC4 == 0 && (PORTCbits.RC5 == 0))
91 | CLC_2_Interrupt();
92 | else
93 | CLC_1_Interrupt();
94 | // Clear the CLC interrupt flag
95 | PIR3bits.CLC1IF = 0;
96 | }
97 |
98 | bool CLC1_OutputStatusGet(void) {
99 | return (CLC1CONbits.LC1OUT);
100 | }
101 | /**
102 | End of File
103 | */
104 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/clc1.h:
--------------------------------------------------------------------------------
1 | /**
2 | CLC1 Generated Driver API Header File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | clc1.h
9 |
10 | @Summary
11 | This is the generated header file for the CLC1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides APIs for driver for CLC1.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45 or later
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef CLC1_H
48 | #define CLC1_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 | #include
57 |
58 | #ifdef __cplusplus // Provide C++ Compatibility
59 |
60 | extern "C" {
61 |
62 | #endif
63 |
64 | /**
65 | Section: CLC1 APIs
66 | */
67 |
68 | /**
69 | @Summary
70 | Initializes the CLC1
71 |
72 | @Description
73 | This routine configures the CLC1 specific control registers
74 |
75 | @Preconditions
76 | None
77 |
78 | @Returns
79 | None
80 |
81 | @Param
82 | None
83 |
84 | @Comment
85 |
86 | @Example
87 |
88 | CLC1_Initialize();
89 |
90 | */
91 | void CLC1_Initialize(void);
92 |
93 | /**
94 | @Summary
95 | CLC1 Interrupt Service Routine
96 |
97 | @Description
98 | This is the CLC1 interrupt service routine called by the Interrupt Manager. Place your CLC1 interrupt code here.
99 |
100 | @Preconditions
101 | CLC1_Initialize() function should have been called before calling this function
102 |
103 | @Returns
104 | None
105 |
106 | @Param
107 | None
108 |
109 | */
110 | void CLC1_ISR(void);
111 | /**
112 | @Summary
113 | Returns output pin status of the CLC module.
114 |
115 | @Description
116 | This routine returns output pin status of the CLC module.
117 |
118 | @Param
119 | None.
120 |
121 | @Returns
122 | Output pin status
123 |
124 | @Example
125 |
126 | bool outputStatus;
127 | outputStatus = CLC1_OutputStatusGet();
128 |
129 | */
130 |
131 | bool CLC1_OutputStatusGet(void);
132 |
133 | #ifdef __cplusplus // Provide C++ Compatibility
134 |
135 | }
136 |
137 | #endif
138 |
139 | #endif // CLC1_H
140 | /**
141 | End of File
142 | */
143 |
144 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/clc2.c:
--------------------------------------------------------------------------------
1 | /**
2 | CLC2 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | clc2.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the CLC2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides implementations for driver APIs for CLC2.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45 or later
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "clc2.h"
53 | #include "mcc.h"
54 |
55 | /**
56 | Section: CLC2 APIs
57 | */
58 |
59 | void CLC2_Initialize(void) {
60 | // Set the CLC2 to the options selected in the User Interface
61 |
62 | // LC2G1POL not_inverted; LC2G2POL not_inverted; LC2G3POL inverted; LC2G4POL not_inverted; LC2POL not_inverted;
63 | CLC2POL = 0x04;
64 | // LC2D1S CLCIN1 (CLCIN1PPS);
65 | CLC2SEL0 = 0x01;
66 | // LC2D2S CLCIN0 (CLCIN0PPS);
67 | CLC2SEL1 = 0x00;
68 | // LC2D3S CLCIN0 (CLCIN0PPS);
69 | CLC2SEL2 = 0x00;
70 | // LC2D4S CLCIN0 (CLCIN0PPS);
71 | CLC2SEL3 = 0x00;
72 | // LC2G1D3N disabled; LC2G1D2N disabled; LC2G1D4N disabled; LC2G1D1T enabled; LC2G1D3T disabled; LC2G1D2T disabled; LC2G1D4T disabled; LC2G1D1N disabled;
73 | CLC2GLS0 = 0x02;
74 | // LC2G2D2N disabled; LC2G2D1N disabled; LC2G2D4N disabled; LC2G2D3N disabled; LC2G2D2T enabled; LC2G2D1T disabled; LC2G2D4T enabled; LC2G2D3T enabled;
75 | CLC2GLS1 = 0xA8;
76 | // LC2G3D1N disabled; LC2G3D2N disabled; LC2G3D3N disabled; LC2G3D4N disabled; LC2G3D1T disabled; LC2G3D2T enabled; LC2G3D3T enabled; LC2G3D4T enabled;
77 | CLC2GLS2 = 0xA8;
78 | // LC2G4D1N disabled; LC2G4D2N disabled; LC2G4D3N disabled; LC2G4D4N disabled; LC2G4D1T disabled; LC2G4D2T enabled; LC2G4D3T enabled; LC2G4D4T enabled;
79 | CLC2GLS3 = 0xA8;
80 | // LC2EN enabled; INTN enabled; INTP enabled; MODE 2-input D flip-flop with R;
81 | CLC2CON = 0x9D;
82 |
83 | // Clear the CLC interrupt flag
84 | PIR3bits.CLC2IF = 0;
85 | // Enabling CLC2 interrupt.
86 | PIE3bits.CLC2IE = 1;
87 | }
88 |
89 | void CLC2_ISR(void) {
90 | if (PORTCbits.RC4 == 0 && (PORTCbits.RC5 == 0))
91 | CLC_1_Interrupt();
92 | else
93 | CLC_2_Interrupt();
94 | // Clear the CLC interrupt flag
95 | PIR3bits.CLC2IF = 0;
96 | }
97 |
98 | bool CLC2_OutputStatusGet(void) {
99 | return (CLC2CONbits.LC2OUT);
100 | }
101 | /**
102 | End of File
103 | */
104 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/clc2.h:
--------------------------------------------------------------------------------
1 | /**
2 | CLC2 Generated Driver API Header File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | clc2.h
9 |
10 | @Summary
11 | This is the generated header file for the CLC2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides APIs for driver for CLC2.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45 or later
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef CLC2_H
48 | #define CLC2_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 | #include
57 |
58 | #ifdef __cplusplus // Provide C++ Compatibility
59 |
60 | extern "C" {
61 |
62 | #endif
63 |
64 | /**
65 | Section: CLC2 APIs
66 | */
67 |
68 | /**
69 | @Summary
70 | Initializes the CLC2
71 |
72 | @Description
73 | This routine configures the CLC2 specific control registers
74 |
75 | @Preconditions
76 | None
77 |
78 | @Returns
79 | None
80 |
81 | @Param
82 | None
83 |
84 | @Comment
85 |
86 | @Example
87 |
88 | CLC2_Initialize();
89 |
90 | */
91 | void CLC2_Initialize(void);
92 |
93 | /**
94 | @Summary
95 | CLC2 Interrupt Service Routine
96 |
97 | @Description
98 | This is the CLC2 interrupt service routine called by the Interrupt Manager. Place your CLC2 interrupt code here.
99 |
100 | @Preconditions
101 | CLC2_Initialize() function should have been called before calling this function
102 |
103 | @Returns
104 | None
105 |
106 | @Param
107 | None
108 |
109 | */
110 | void CLC2_ISR(void);
111 | /**
112 | @Summary
113 | Returns output pin status of the CLC module.
114 |
115 | @Description
116 | This routine returns output pin status of the CLC module.
117 |
118 | @Param
119 | None.
120 |
121 | @Returns
122 | Output pin status
123 |
124 | @Example
125 |
126 | bool outputStatus;
127 | outputStatus = CLC2_OutputStatusGet();
128 |
129 | */
130 |
131 | bool CLC2_OutputStatusGet(void);
132 |
133 | #ifdef __cplusplus // Provide C++ Compatibility
134 |
135 | }
136 |
137 | #endif
138 |
139 | #endif // CLC2_H
140 | /**
141 | End of File
142 | */
143 |
144 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/device_config.c:
--------------------------------------------------------------------------------
1 | /**
2 | @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Source File
3 |
4 | @Company:
5 | Microchip Technology Inc.
6 |
7 | @File Name:
8 | mcc.c
9 |
10 | @Summary:
11 | This is the mcc.c file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description:
14 | This header file provides implementations for driver APIs for all modules selected in the GUI.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.00
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45 or later
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | // Configuration bits: selected in the GUI
48 |
49 | // CONFIG1
50 | #pragma config FEXTOSC = OFF // FEXTOSC External Oscillator mode Selection bits->Oscillator not enabled
51 | #pragma config RSTOSC = HFINT32 // Power-up default value for COSC bits->HFINTOSC with 2x PLL (32MHz)
52 | #pragma config CLKOUTEN = OFF // Clock Out Enable bit->CLKOUT function is disabled; I/O or oscillator function on OSC2
53 | #pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
54 | #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor is enabled
55 |
56 | // CONFIG2
57 | #pragma config MCLRE = OFF // Master Clear Enable bit->MCLR/VPP pin function is digital input; MCLR internally disabled; Weak pull-up under control of port pin's WPU control bit.
58 | #pragma config PWRTE = OFF // Power-up Timer Enable bit->PWRT disabled
59 | #pragma config WDTE = OFF // Watchdog Timer Enable bits->WDT disabled; SWDTEN is ignored
60 | #pragma config LPBOREN = OFF // Low-power BOR enable bit->ULPBOR disabled
61 | #pragma config BOREN = ON // Brown-out Reset Enable bits->Brown-out Reset enabled, SBOREN bit ignored
62 | #pragma config BORV = LOW // Brown-out Reset Voltage selection bit->Brown-out voltage (Vbor) set to 2.45V
63 | #pragma config PPS1WAY = OFF // PPSLOCK bit One-Way Set Enable bit->The PPSLOCK bit can be set and cleared repeatedly (subject to the unlock sequence)
64 | #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable bit->Stack Overflow or Underflow will cause a Reset
65 | #pragma config DEBUG = OFF // Debugger enable bit->Background debugger disabled
66 |
67 | // CONFIG3
68 | #pragma config WRT = OFF // User NVM self-write protection bits->Write protection off
69 | #pragma config LVP = OFF // Low Voltage Programming Enable bit->High Voltage on MCLR/VPP must be used for programming.
70 |
71 | // CONFIG4
72 | #pragma config CP = OFF // User NVM Program Memory Code Protection bit->User NVM code protection disabled
73 | #pragma config CPD = OFF // Data NVM Memory Code Protection bit->Data NVM code protection disabled
74 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/i2c1.c:
--------------------------------------------------------------------------------
1 | /**
2 | MSSP1 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | i2c1.c
9 |
10 | @Summary
11 | This is the generated header file for the MSSP1 driver using
12 | PIC10 / PIC12 / PIC16 / PIC18 MCUs
13 |
14 | @Description
15 | This header file provides APIs for driver for I2C1.
16 | Generation Information :
17 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
18 | Device : PIC16F18345
19 | Driver Version : 2.01
20 | The generated drivers are tested against the following:
21 | Compiler : XC8 1.45
22 | MPLAB : MPLAB X 4.15
23 | */
24 |
25 | /*
26 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
27 |
28 | Subject to your compliance with these terms, you may use Microchip software and any
29 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
30 | license terms applicable to your use of third party software (including open source software) that
31 | may accompany Microchip software.
32 |
33 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
34 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
35 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
36 | FOR A PARTICULAR PURPOSE.
37 |
38 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
39 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
40 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
41 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
42 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
43 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
44 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
45 | SOFTWARE.
46 | */
47 |
48 | #include "i2c1.h"
49 | #include "mcc.h"
50 |
51 |
52 | #define I2C1_SLAVE_MASK 0x7F
53 |
54 |
55 | /**
56 | Section: Global Variables
57 | */
58 |
59 | volatile uint8_t I2C1_slaveWriteData = 0x55;
60 |
61 | /**
62 | Section: Local Functions
63 | */
64 |
65 | /**
66 | Prototype: void I2C1_Initialize(void)
67 | Input: none
68 | Output: none
69 | Description: I2C1_Initialize is an
70 | initialization routine that takes inputs from the GUI.
71 | Comment:
72 | Usage: I2C1_Initialize();
73 |
74 | */
75 | void I2C1_Initialize(void) {
76 | // initialize the hardware
77 | //Reset the I2C Peripheral
78 | SSP1CON1 = 0x00;
79 | SSP1CON2 = 0x00;
80 | // R_nW write_noTX; P stopbit_notdetected; S startbit_notdetected; BF RCinprocess_TXcomplete; SMP High Speed; UA dontupdate; CKE disabled; D_nA lastbyte_address;
81 | SSP1STAT = 0x00;
82 | // SSPEN enabled; WCOL no_collision; CKP disabled; SSPM 7 Bit Polling; SSPOV no_overflow;
83 | SSP1CON1 = 0x26;
84 | // ACKEN disabled; GCEN disabled; PEN disabled; ACKDT acknowledge; RSEN disabled; RCEN disabled; ACKSTAT received; SEN disabled;
85 | SSP1CON2 = 0x00;
86 | // ACKTIM ackseq; SBCDE disabled; BOEN disabled; SCIE disabled; PCIE disabled; DHEN disabled; SDAHT 100ns; AHEN disabled;
87 | SSP1CON3 = 0x00;
88 | // SSP1MSK 127;
89 | SSP1MSK = (I2C1_SLAVE_MASK << 1); // adjust UI mask for R/nW bit
90 | // SSP1ADD 48;
91 | SSP1ADD = i2c_address; // adjust UI address for R/nW bit
92 |
93 | // clear the slave interrupt flag
94 | PIR1bits.SSP1IF = 0;
95 | // enable the master interrupt
96 | PIE1bits.SSP1IE = 1;
97 |
98 | }
99 |
100 | void I2C1_Initialize_ClockStreach(void) {
101 | // initialize the hardware
102 | //Reset the I2C Peripheral
103 | SSP1CON1 = 0x00;
104 | SSP1CON2 = 0x00;
105 | // R_nW write_noTX; P stopbit_notdetected; S startbit_notdetected; BF RCinprocess_TXcomplete; SMP High Speed; UA dontupdate; CKE disabled; D_nA lastbyte_address;
106 | SSP1STAT = 0x00;
107 | // SSPEN enabled; WCOL no_collision; CKP disabled; SSPM 7 Bit Polling; SSPOV no_overflow;
108 | SSP1CON1 = 0x26;
109 | // ACKEN disabled; GCEN disabled; PEN disabled; ACKDT acknowledge; RSEN disabled; RCEN disabled; ACKSTAT received; SEN enabled;
110 | SSP1CON2 = 0x01;
111 | // ACKTIM ackseq; SBCDE disabled; BOEN disabled; SCIE disabled; PCIE disabled; DHEN disabled; SDAHT 100ns; AHEN disabled;
112 | SSP1CON3 = 0x00;
113 | // SSP1MSK 127;
114 | SSP1MSK = (I2C1_SLAVE_MASK << 1); // adjust UI mask for R/nW bit
115 | // SSP1ADD 48;
116 | SSP1ADD = i2c_address; // adjust UI address for R/nW bit
117 |
118 | // clear the slave interrupt flag
119 | PIR1bits.SSP1IF = 0;
120 | // enable the master interrupt
121 | PIE1bits.SSP1IE = 1;
122 |
123 | }
124 |
125 | void I2C1_ISR(void) {
126 | uint8_t i2c_data = 0x55;
127 |
128 |
129 | // NOTE: The slave driver will always acknowledge
130 | // any address match.
131 |
132 | PIR1bits.SSP1IF = 0; // clear the slave interrupt flag
133 | i2c_data = SSP1BUF; // read SSPBUF to clear BF
134 | if (1 == SSP1STATbits.R_nW) {
135 | if ((1 == SSP1STATbits.D_nA) && (1 == SSP1CON2bits.ACKSTAT)) {
136 | // callback routine can perform any post-read processing
137 | I2C1_StatusCallback(I2C1_SLAVE_READ_COMPLETED);
138 | } else {
139 | // callback routine should write data into SSPBUF
140 | I2C1_StatusCallback(I2C1_SLAVE_READ_REQUEST);
141 | }
142 | } else if (0 == SSP1STATbits.D_nA) {
143 | // this is an I2C address
144 |
145 | // callback routine should prepare to receive data from the master
146 | I2C1_StatusCallback(I2C1_SLAVE_WRITE_REQUEST);
147 | } else {
148 | I2C1_slaveWriteData = i2c_data;
149 |
150 | // callback routine should process I2C1_slaveWriteData from the master
151 | I2C1_StatusCallback(I2C1_SLAVE_WRITE_COMPLETED);
152 | }
153 |
154 | SSP1CON1bits.CKP = 1; // release SCL
155 |
156 | } // end I2C1_ISR()
157 |
158 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/i2c1.h:
--------------------------------------------------------------------------------
1 | /**
2 | MSSP1 Generated Driver API Header File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | i2c1.h
9 |
10 | @Summary
11 | This is the generated header file for the MSSP1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides APIs for driver for I2C1.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef _I2C1_H
48 | #define _I2C1_H
49 |
50 | #include
51 | #include
52 | #include
53 | #include
54 |
55 | #ifdef __cplusplus // Provide C++ Compatibility
56 |
57 | extern "C" {
58 |
59 | #endif
60 |
61 | /**
62 | I2C Slave Driver Status
63 |
64 | @Summary
65 | Defines the different status that the slave driver has
66 | detected over the i2c bus.
67 |
68 | @Description
69 | This defines the different status that the slave driver has
70 | detected over the i2c bus. The status is passed to the
71 | I2C1_StatusCallback() callback function that is implemented by
72 | the user of the slave driver as a parameter to inform the user
73 | that there was a change in the status of the driver due to
74 | transactions on the i2c bus. User of the slave driver can use these
75 | to manage the read or write buffers.
76 |
77 | */
78 |
79 |
80 | /**
81 | @Summary
82 | Initializes and enables the i2c slave instance : 1
83 |
84 | @Description
85 | This routine initializes the i2c slave driver instance for : 1
86 | index, making it ready for clients to open and use it.
87 |
88 | @Preconditions
89 | None
90 |
91 | @Param
92 | None
93 |
94 | @Returns
95 | None
96 |
97 | @Example
98 |
99 | // initialize the i2c slave driver
100 | I2C1_Initialize();
101 |
102 |
103 | */
104 |
105 | void I2C1_Initialize(void);
106 |
107 | /**
108 | @Summary
109 | This function process the I2C interrupts generated by
110 | bus activity
111 |
112 | @Description
113 | This function calls a callback function with 1 of 4
114 | possible parameters.
115 | I2C1_SLAVE_WRITE_REQUEST
116 | I2C1_SLAVE_READ_REQUEST
117 | I2C1_SLAVE_WRITE_COMPLETED
118 | I2C1_SLAVE_READ_COMPLETED
119 |
120 | The callback function should contain application specific
121 | code to process I2C bus activity from the I2C master.
122 | A basic EEPROM emulator is provided as an example.
123 | */
124 | void I2C1_Initialize_ClockStreach(void);
125 |
126 |
127 | void I2C1_ISR ( void );
128 |
129 | /**
130 | @Summary
131 | This varible contains the last data written to the I2C slave
132 | */
133 |
134 | extern volatile uint8_t I2C1_slaveWriteData;
135 |
136 |
137 | #ifdef __cplusplus // Provide C++ Compatibility
138 |
139 | }
140 |
141 | #endif
142 |
143 | #endif // _I2C1_H
144 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/interrupt_manager.c:
--------------------------------------------------------------------------------
1 | /**
2 | Generated Interrupt Manager Source File
3 |
4 | @Company:
5 | Microchip Technology Inc.
6 |
7 | @File Name:
8 | interrupt_manager.c
9 |
10 | @Summary:
11 | This is the Interrupt Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description:
14 | This header file provides implementations for global interrupt handling.
15 | For individual peripheral handlers please see the peripheral driver for
16 | all modules selected in the GUI.
17 | Generation Information :
18 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
19 | Device : PIC16F18345
20 | Driver Version : 1.03
21 | The generated drivers are tested against the following:
22 | Compiler : XC8 1.45 or later
23 | MPLAB : MPLAB X 4.15
24 | */
25 |
26 | /*
27 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
28 |
29 | Subject to your compliance with these terms, you may use Microchip software and any
30 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
31 | license terms applicable to your use of third party software (including open source software) that
32 | may accompany Microchip software.
33 |
34 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
35 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
36 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
37 | FOR A PARTICULAR PURPOSE.
38 |
39 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
40 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
41 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
42 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
43 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
44 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
45 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
46 | SOFTWARE.
47 | */
48 |
49 | #include "interrupt_manager.h"
50 | #include "mcc.h"
51 |
52 | void interrupt INTERRUPT_InterruptManager (void)
53 | {
54 | // interrupt handler
55 | if(INTCONbits.PEIE == 1)
56 | {
57 | if(PIE3bits.CLC2IE == 1 && PIR3bits.CLC2IF == 1)
58 | {
59 | CLC2_ISR();
60 | }
61 | else if(PIE3bits.CLC1IE == 1 && PIR3bits.CLC1IF == 1)
62 | {
63 | CLC1_ISR();
64 | }
65 | else if(PIE1bits.SSP1IE == 1 && PIR1bits.SSP1IF == 1)
66 | {
67 | I2C1_ISR();
68 | }
69 | else if(PIE3bits.TMR3IE == 1 && PIR3bits.TMR3IF == 1)
70 | {
71 | TMR3_ISR();
72 | }
73 | else
74 | {
75 | //Unhandled Interrupt
76 | }
77 | }
78 | else
79 | {
80 | //Unhandled Interrupt
81 | }
82 | }
83 | /**
84 | End of File
85 | */
86 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/interrupt_manager.h:
--------------------------------------------------------------------------------
1 | /**
2 | Generated Interrupt Manager Header File
3 |
4 | @Company:
5 | Microchip Technology Inc.
6 |
7 | @File Name:
8 | interrupt_manager.h
9 |
10 | @Summary:
11 | This is the Interrupt Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description:
14 | This header file provides implementations for global interrupt handling.
15 | For individual peripheral handlers please see the peripheral driver for
16 | all modules selected in the GUI.
17 | Generation Information :
18 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
19 | Device : PIC16F18345
20 | Driver Version : 1.03
21 | The generated drivers are tested against the following:
22 | Compiler : XC8 1.45 or later
23 | MPLAB : MPLAB X 4.15
24 | */
25 |
26 | /*
27 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
28 |
29 | Subject to your compliance with these terms, you may use Microchip software and any
30 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
31 | license terms applicable to your use of third party software (including open source software) that
32 | may accompany Microchip software.
33 |
34 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
35 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
36 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
37 | FOR A PARTICULAR PURPOSE.
38 |
39 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
40 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
41 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
42 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
43 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
44 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
45 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
46 | SOFTWARE.
47 | */
48 |
49 | #ifndef INTERRUPT_MANAGER_H
50 | #define INTERRUPT_MANAGER_H
51 |
52 |
53 | /**
54 | * @Param
55 | none
56 | * @Returns
57 | none
58 | * @Description
59 | This macro will enable global interrupts.
60 | * @Example
61 | INTERRUPT_GlobalInterruptEnable();
62 | */
63 | #define INTERRUPT_GlobalInterruptEnable() (INTCONbits.GIE = 1)
64 |
65 | /**
66 | * @Param
67 | none
68 | * @Returns
69 | none
70 | * @Description
71 | This macro will disable global interrupts.
72 | * @Example
73 | INTERRUPT_GlobalInterruptDisable();
74 | */
75 | #define INTERRUPT_GlobalInterruptDisable() (INTCONbits.GIE = 0)
76 | /**
77 | * @Param
78 | none
79 | * @Returns
80 | none
81 | * @Description
82 | This macro will enable peripheral interrupts.
83 | * @Example
84 | INTERRUPT_PeripheralInterruptEnable();
85 | */
86 | #define INTERRUPT_PeripheralInterruptEnable() (INTCONbits.PEIE = 1)
87 |
88 | /**
89 | * @Param
90 | none
91 | * @Returns
92 | none
93 | * @Description
94 | This macro will disable peripheral interrupts.
95 | * @Example
96 | INTERRUPT_PeripheralInterruptDisable();
97 | */
98 | #define INTERRUPT_PeripheralInterruptDisable() (INTCONbits.PEIE = 0)
99 | /**
100 | * @Param
101 | none
102 | * @Returns
103 | none
104 | * @Description
105 | Main interrupt service routine. Calls module interrupt handlers.
106 | * @Example
107 | INTERRUPT_InterruptManager();
108 | */
109 | void interrupt INTERRUPT_InterruptManager(void);
110 |
111 |
112 | #endif // INTERRUPT_MANAGER_H
113 | /**
114 | End of File
115 | */
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/mcc.c:
--------------------------------------------------------------------------------
1 | /**
2 | @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Source File
3 |
4 | @Company:
5 | Microchip Technology Inc.
6 |
7 | @File Name:
8 | mcc.c
9 |
10 | @Summary:
11 | This is the mcc.c file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description:
14 | This header file provides implementations for driver APIs for all modules selected in the GUI.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.00
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45 or later
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #include "mcc.h"
48 |
49 |
50 | void SYSTEM_Initialize(void)
51 | {
52 |
53 | PMD_Initialize();
54 | PIN_MANAGER_Initialize();
55 | OSCILLATOR_Initialize();
56 | WDT_Initialize();
57 | I2C1_AddressSet();
58 | I2C1_Initialize();
59 | CLC2_Initialize();
60 | TMR2_Initialize();
61 | CLC1_Initialize();
62 | TMR3_Initialize();
63 |
64 | }
65 |
66 | void OSCILLATOR_Initialize(void)
67 | {
68 | // NOSC HFINTOSC; NDIV 1;
69 | OSCCON1 = 0x60;
70 | // CSWHOLD may proceed; SOSCPWR Low power; SOSCBE crystal oscillator;
71 | OSCCON3 = 0x00;
72 | // LFOEN disabled; ADOEN disabled; SOSCEN disabled; EXTOEN disabled; HFOEN disabled;
73 | OSCEN = 0x00;
74 | // HFFRQ 32_MHz;
75 | OSCFRQ = 0x07;
76 | // HFTUN 0;
77 | OSCTUNE = 0x00;
78 | }
79 |
80 | void WDT_Initialize(void)
81 | {
82 | // WDTPS 1:65536; SWDTEN OFF;
83 | WDTCON = 0x16;
84 | }
85 |
86 | void PMD_Initialize(void)
87 | {
88 | // CLKRMD CLKR enabled; SYSCMD SYSCLK enabled; FVRMD FVR disabled; IOCMD IOC enabled; NVMMD NVM enabled;
89 | PMD0 = 0x40;
90 | // TMR0MD TMR0 enabled; TMR1MD TMR1 disabled; TMR4MD TMR4 disabled; TMR5MD TMR5 disabled; TMR2MD TMR2 enabled; TMR3MD TMR3 enabled; NCOMD DDS(NCO) disabled; TMR6MD TMR6 disabled;
91 | PMD1 = 0xF2;
92 | // DACMD DAC disabled; CMP1MD CMP1 disabled; ADCMD ADC enabled; CMP2MD CMP2 disabled;
93 | PMD2 = 0x46;
94 | // CCP2MD CCP2 enabled; CCP1MD CCP1 enabled; CCP4MD CCP4 disabled; CCP3MD CCP3 enabled; PWM6MD PWM6 disabled; PWM5MD PWM5 disabled; CWG2MD CWG2 disabled; CWG1MD CWG1 disabled;
95 | PMD3 = 0xF8;
96 | // MSSP1MD MSSP1 enabled; UART1MD EUSART disabled; MSSP2MD MSSP2 enabled;
97 | PMD4 = 0x20;
98 | // DSMMD DSM disabled; CLC3MD CLC3 disabled; CLC4MD CLC4 disabled; CLC1MD CLC1 enabled; CLC2MD CLC2 enabled;
99 | PMD5 = 0x19;
100 | }
101 | /**
102 | End of File
103 | */
104 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/mcc.h:
--------------------------------------------------------------------------------
1 | /**
2 | @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Header File
3 |
4 | @Company:
5 | Microchip Technology Inc.
6 |
7 | @File Name:
8 | mcc.h
9 |
10 | @Summary:
11 | This is the mcc.h file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description:
14 | This header file provides implementations for driver APIs for all modules selected in the GUI.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.00
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45 or later
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef MCC_H
48 | #define MCC_H
49 | #include
50 | #include "pin_manager.h"
51 | #include
52 | #include
53 | #include "interrupt_manager.h"
54 | #include "i2c1.h"
55 | #include "tmr3.h"
56 | #include "tmr2.h"
57 | #include "pwm2.h"
58 | #include "pwm1.h"
59 | #include "pwm3.h"
60 | #include "clc2.h"
61 | #include "clc1.h"
62 | #include "adc.h"
63 |
64 | #define _XTAL_FREQ 32000000
65 |
66 | #include "../DataVariable.h"
67 | #include "../i2c_register.h"
68 | #include "../NavKey.h"
69 | #include "../main.h"
70 | #include "../PWM.h"
71 |
72 | /**
73 | * @Param
74 | none
75 | * @Returns
76 | none
77 | * @Description
78 | Initializes the device to the default states configured in the
79 | * MCC GUI
80 | * @Example
81 | SYSTEM_Initialize(void);
82 | */
83 | void SYSTEM_Initialize(void);
84 |
85 | /**
86 | * @Param
87 | none
88 | * @Returns
89 | none
90 | * @Description
91 | Initializes the oscillator to the default states configured in the
92 | * MCC GUI
93 | * @Example
94 | OSCILLATOR_Initialize(void);
95 | */
96 | void OSCILLATOR_Initialize(void);
97 | /**
98 | * @Param
99 | none
100 | * @Returns
101 | none
102 | * @Description
103 | Initializes the WDT module to the default states configured in the
104 | * MCC GUI
105 | * @Example
106 | WDT_Initialize(void);
107 | */
108 | void WDT_Initialize(void);
109 | /**
110 | * @Param
111 | none
112 | * @Returns
113 | none
114 | * @Description
115 | Initializes the PMD module to the default states configured in the
116 | * MCC GUI
117 | * @Example
118 | PMD_Initialize(void);
119 | */
120 | void PMD_Initialize(void);
121 |
122 | #endif /* MCC_H */
123 | /**
124 | End of File
125 | */
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/pin_manager.c:
--------------------------------------------------------------------------------
1 | /**
2 | Generated Pin Manager File
3 |
4 | Company:
5 | Microchip Technology Inc.
6 |
7 | File Name:
8 | pin_manager.c
9 |
10 | Summary:
11 | This is the Pin Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | Description:
14 | This header file provides implementations for pin APIs for all pins selected in the GUI.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 |
23 | Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved.
24 | */
25 |
26 | /*
27 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
28 |
29 | Subject to your compliance with these terms, you may use Microchip software and any
30 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
31 | license terms applicable to your use of third party software (including open source software) that
32 | may accompany Microchip software.
33 |
34 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
35 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
36 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
37 | FOR A PARTICULAR PURPOSE.
38 |
39 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
40 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
41 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
42 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
43 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
44 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
45 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
46 | SOFTWARE.
47 | */
48 |
49 | #include
50 | #include "pin_manager.h"
51 | #include "stdbool.h"
52 |
53 |
54 |
55 |
56 |
57 | void PIN_MANAGER_Initialize(void)
58 | {
59 | /**
60 | LATx registers
61 | */
62 | LATA = 0x00;
63 | LATB = 0x00;
64 | LATC = 0x00;
65 |
66 | /**
67 | TRISx registers
68 | */
69 | TRISA = 0x37;
70 | TRISB = 0xD0;
71 | TRISC = 0xFF;
72 |
73 | /**
74 | ANSELx registers
75 | */
76 | ANSELC = 0x00;
77 | ANSELB = 0x00;
78 | ANSELA = 0x20;
79 |
80 | /**
81 | WPUx registers
82 | */
83 | WPUB = 0x10;
84 | WPUA = 0x3F;
85 | WPUC = 0xCC;
86 |
87 | /**
88 | ODx registers
89 | */
90 | ODCONA = 0x00;
91 | ODCONB = 0x20;
92 | ODCONC = 0x00;
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | SSP1CLKPPSbits.SSP1CLKPPS = 0x0E; //RB6->MSSP1:SCL1;
102 | SSP1DATPPSbits.SSP1DATPPS = 0x0F; //RB7->MSSP1:SDA1;
103 | CLCIN1PPSbits.CLCIN1PPS = 0x15; //RC5->CLC2:CLCIN1;
104 | CLCIN0PPSbits.CLCIN0PPS = 0x14; //RC4->CLC2:CLCIN0;
105 | RB7PPSbits.RB7PPS = 0x19; //RB7->MSSP1:SDA1;
106 | RB6PPSbits.RB6PPS = 0x18; //RB6->MSSP1:SCL1;
107 | }
108 |
109 | void PIN_MANAGER_IOC(void)
110 | {
111 | }
112 |
113 | /**
114 | End of File
115 | */
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/pwm1.c:
--------------------------------------------------------------------------------
1 | /**
2 | PWM1 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | pwm1.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the PWM1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides implementations for driver APIs for PWM1.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "pwm1.h"
53 |
54 | /**
55 | Section: Macro Declarations
56 | */
57 |
58 | #define PWM1_INITIALIZE_DUTY_VALUE 1023
59 |
60 | /**
61 | Section: PWM Module APIs
62 | */
63 |
64 | void PWM1_Initialize(void)
65 | {
66 | // Set the PWM1 to the options selected in the User Interface
67 |
68 | // CCP1MODE PWM; CCP1EN enabled; CCP1FMT right_aligned;
69 | CCP1CON = 0x8F;
70 |
71 | // CCPR1H 3;
72 | CCPR1H = 0x03;
73 |
74 | // CCPR1L 255;
75 | CCPR1L = 0xFF;
76 |
77 | // Selecting Timer 2
78 | CCPTMRSbits.C1TSEL = 0x1;
79 |
80 | }
81 |
82 | void PWM1_LoadDutyValue(uint16_t dutyValue)
83 | {
84 | dutyValue &= 0x03FF;
85 |
86 | // Load duty cycle value
87 | if(CCP1CONbits.CCP1FMT)
88 | {
89 | dutyValue <<= 6;
90 | CCPR1H = dutyValue >> 8;
91 | CCPR1L = dutyValue;
92 | }
93 | else
94 | {
95 | CCPR1H = dutyValue >> 8;
96 | CCPR1L = dutyValue;
97 | }
98 | }
99 |
100 | bool PWM1_OutputStatusGet(void)
101 | {
102 | // Returns the output status
103 | return(CCP1CONbits.CCP1OUT);
104 | }
105 | /**
106 | End of File
107 | */
108 |
109 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/pwm1.h:
--------------------------------------------------------------------------------
1 | /**
2 | PWM1 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | pwm1.h
9 |
10 | @Summary
11 | This is the generated driver implementation file for the PWM1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides implementations for driver APIs for PWM1.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef PWM1_H
48 | #define PWM1_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 | #include
57 |
58 | #ifdef __cplusplus // Provide C++ Compatibility
59 |
60 | extern "C" {
61 |
62 | #endif
63 |
64 | /**
65 | Section: PWM Module APIs
66 | */
67 |
68 | /**
69 | @Summary
70 | Initializes the PWM1
71 |
72 | @Description
73 | This routine initializes the PWM1 module.
74 | This routine must be called before any other PWM1 routine is called.
75 | This routine should only be called once during system initialization.
76 |
77 | @Preconditions
78 | None
79 |
80 | @Param
81 | None
82 |
83 | @Returns
84 | None
85 |
86 | @Comment
87 |
88 |
89 | @Example
90 |
91 | uint16_t dutycycle;
92 |
93 | CCP1_Initialize();
94 | PWM1_LoadDutyValue(dutycycle);
95 |
96 | */
97 | void PWM1_Initialize(void);
98 |
99 | /**
100 | @Summary
101 | Loads 16-bit duty cycle.
102 |
103 | @Description
104 | This routine loads the 16 bit duty cycle value.
105 |
106 | @Preconditions
107 | PWM1_Initialize() function should have been called
108 | before calling this function.
109 |
110 | @Param
111 | Pass 16bit duty cycle value.
112 |
113 | @Returns
114 | None
115 |
116 | @Example
117 |
118 | uint16_t dutycycle;
119 |
120 | PWM1_Initialize();
121 | PWM1_LoadDutyValue(dutycycle);
122 |
123 | */
124 | void PWM1_LoadDutyValue(uint16_t dutyValue);
125 |
126 | /**
127 | @Summary
128 | Read pwm output status.
129 |
130 | @Description
131 | This routine returns the pwm output status.
132 |
133 | @Preconditions
134 | PWM1_Initialize() function should have been
135 | called before calling this function.
136 |
137 | @Param
138 | None
139 |
140 | @Returns
141 | true : output high
142 | false: output low
143 |
144 | @Example
145 |
146 | uint16_t dutyCycle;
147 | bool status;
148 | PWM1_Initialize();
149 | PWM1_LoadDutyValue(dutyCycle);
150 | while(1)
151 | {
152 | status = PWM1_OutputStatusGet();
153 | }
154 |
155 | */
156 | bool PWM1_OutputStatusGet(void);
157 |
158 | #ifdef __cplusplus // Provide C++ Compatibility
159 |
160 | }
161 |
162 | #endif
163 |
164 | #endif //PWM1_H
165 | /**
166 | End of File
167 | */
168 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/pwm2.c:
--------------------------------------------------------------------------------
1 | /**
2 | PWM2 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | pwm2.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the PWM2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides implementations for driver APIs for PWM2.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "pwm2.h"
53 |
54 | /**
55 | Section: Macro Declarations
56 | */
57 |
58 | #define PWM2_INITIALIZE_DUTY_VALUE 1023
59 |
60 | /**
61 | Section: PWM Module APIs
62 | */
63 |
64 | void PWM2_Initialize(void)
65 | {
66 | // Set the PWM2 to the options selected in the User Interface
67 |
68 | // CCP2MODE PWM; CCP2EN enabled; CCP2FMT right_aligned;
69 | CCP2CON = 0x8F;
70 |
71 | // CCPR2H 3;
72 | CCPR2H = 0x03;
73 |
74 | // CCPR2L 255;
75 | CCPR2L = 0xFF;
76 |
77 | // Selecting Timer 2
78 | CCPTMRSbits.C2TSEL = 0x1;
79 |
80 | }
81 |
82 | void PWM2_LoadDutyValue(uint16_t dutyValue)
83 | {
84 | dutyValue &= 0x03FF;
85 |
86 | // Load duty cycle value
87 | if(CCP2CONbits.CCP2FMT)
88 | {
89 | dutyValue <<= 6;
90 | CCPR2H = dutyValue >> 8;
91 | CCPR2L = dutyValue;
92 | }
93 | else
94 | {
95 | CCPR2H = dutyValue >> 8;
96 | CCPR2L = dutyValue;
97 | }
98 | }
99 |
100 | bool PWM2_OutputStatusGet(void)
101 | {
102 | // Returns the output status
103 | return(CCP2CONbits.CCP2OUT);
104 | }
105 | /**
106 | End of File
107 | */
108 |
109 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/pwm2.h:
--------------------------------------------------------------------------------
1 | /**
2 | PWM2 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | pwm2.h
9 |
10 | @Summary
11 | This is the generated driver implementation file for the PWM2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides implementations for driver APIs for PWM2.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef PWM2_H
48 | #define PWM2_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 | #include
57 |
58 | #ifdef __cplusplus // Provide C++ Compatibility
59 |
60 | extern "C" {
61 |
62 | #endif
63 |
64 | /**
65 | Section: PWM Module APIs
66 | */
67 |
68 | /**
69 | @Summary
70 | Initializes the PWM2
71 |
72 | @Description
73 | This routine initializes the PWM2 module.
74 | This routine must be called before any other PWM2 routine is called.
75 | This routine should only be called once during system initialization.
76 |
77 | @Preconditions
78 | None
79 |
80 | @Param
81 | None
82 |
83 | @Returns
84 | None
85 |
86 | @Comment
87 |
88 |
89 | @Example
90 |
91 | uint16_t dutycycle;
92 |
93 | CCP2_Initialize();
94 | PWM2_LoadDutyValue(dutycycle);
95 |
96 | */
97 | void PWM2_Initialize(void);
98 |
99 | /**
100 | @Summary
101 | Loads 16-bit duty cycle.
102 |
103 | @Description
104 | This routine loads the 16 bit duty cycle value.
105 |
106 | @Preconditions
107 | PWM2_Initialize() function should have been called
108 | before calling this function.
109 |
110 | @Param
111 | Pass 16bit duty cycle value.
112 |
113 | @Returns
114 | None
115 |
116 | @Example
117 |
118 | uint16_t dutycycle;
119 |
120 | PWM2_Initialize();
121 | PWM2_LoadDutyValue(dutycycle);
122 |
123 | */
124 | void PWM2_LoadDutyValue(uint16_t dutyValue);
125 |
126 | /**
127 | @Summary
128 | Read pwm output status.
129 |
130 | @Description
131 | This routine returns the pwm output status.
132 |
133 | @Preconditions
134 | PWM2_Initialize() function should have been
135 | called before calling this function.
136 |
137 | @Param
138 | None
139 |
140 | @Returns
141 | true : output high
142 | false: output low
143 |
144 | @Example
145 |
146 | uint16_t dutyCycle;
147 | bool status;
148 | PWM2_Initialize();
149 | PWM2_LoadDutyValue(dutyCycle);
150 | while(1)
151 | {
152 | status = PWM2_OutputStatusGet();
153 | }
154 |
155 | */
156 | bool PWM2_OutputStatusGet(void);
157 |
158 | #ifdef __cplusplus // Provide C++ Compatibility
159 |
160 | }
161 |
162 | #endif
163 |
164 | #endif //PWM2_H
165 | /**
166 | End of File
167 | */
168 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/pwm3.c:
--------------------------------------------------------------------------------
1 | /**
2 | PWM3 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | pwm3.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the PWM3 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides implementations for driver APIs for PWM3.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "pwm3.h"
53 |
54 | /**
55 | Section: Macro Declarations
56 | */
57 |
58 | #define PWM3_INITIALIZE_DUTY_VALUE 1023
59 |
60 | /**
61 | Section: PWM Module APIs
62 | */
63 |
64 | void PWM3_Initialize(void)
65 | {
66 | // Set the PWM3 to the options selected in the User Interface
67 |
68 | // CCP3MODE PWM; CCP3EN enabled; CCP3FMT right_aligned;
69 | CCP3CON = 0x8F;
70 |
71 | // CCPR3H 3;
72 | CCPR3H = 0x03;
73 |
74 | // CCPR3L 255;
75 | CCPR3L = 0xFF;
76 |
77 | // Selecting Timer 2
78 | CCPTMRSbits.C3TSEL = 0x1;
79 |
80 | }
81 |
82 | void PWM3_LoadDutyValue(uint16_t dutyValue)
83 | {
84 | dutyValue &= 0x03FF;
85 |
86 | // Load duty cycle value
87 | if(CCP3CONbits.CCP3FMT)
88 | {
89 | dutyValue <<= 6;
90 | CCPR3H = dutyValue >> 8;
91 | CCPR3L = dutyValue;
92 | }
93 | else
94 | {
95 | CCPR3H = dutyValue >> 8;
96 | CCPR3L = dutyValue;
97 | }
98 | }
99 |
100 | bool PWM3_OutputStatusGet(void)
101 | {
102 | // Returns the output status
103 | return(CCP3CONbits.CCP3OUT);
104 | }
105 | /**
106 | End of File
107 | */
108 |
109 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/pwm3.h:
--------------------------------------------------------------------------------
1 | /**
2 | PWM3 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | pwm3.h
9 |
10 | @Summary
11 | This is the generated driver implementation file for the PWM3 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides implementations for driver APIs for PWM3.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef PWM3_H
48 | #define PWM3_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 | #include
57 |
58 | #ifdef __cplusplus // Provide C++ Compatibility
59 |
60 | extern "C" {
61 |
62 | #endif
63 |
64 | /**
65 | Section: PWM Module APIs
66 | */
67 |
68 | /**
69 | @Summary
70 | Initializes the PWM3
71 |
72 | @Description
73 | This routine initializes the PWM3 module.
74 | This routine must be called before any other PWM3 routine is called.
75 | This routine should only be called once during system initialization.
76 |
77 | @Preconditions
78 | None
79 |
80 | @Param
81 | None
82 |
83 | @Returns
84 | None
85 |
86 | @Comment
87 |
88 |
89 | @Example
90 |
91 | uint16_t dutycycle;
92 |
93 | CCP3_Initialize();
94 | PWM3_LoadDutyValue(dutycycle);
95 |
96 | */
97 | void PWM3_Initialize(void);
98 |
99 | /**
100 | @Summary
101 | Loads 16-bit duty cycle.
102 |
103 | @Description
104 | This routine loads the 16 bit duty cycle value.
105 |
106 | @Preconditions
107 | PWM3_Initialize() function should have been called
108 | before calling this function.
109 |
110 | @Param
111 | Pass 16bit duty cycle value.
112 |
113 | @Returns
114 | None
115 |
116 | @Example
117 |
118 | uint16_t dutycycle;
119 |
120 | PWM3_Initialize();
121 | PWM3_LoadDutyValue(dutycycle);
122 |
123 | */
124 | void PWM3_LoadDutyValue(uint16_t dutyValue);
125 |
126 | /**
127 | @Summary
128 | Read pwm output status.
129 |
130 | @Description
131 | This routine returns the pwm output status.
132 |
133 | @Preconditions
134 | PWM3_Initialize() function should have been
135 | called before calling this function.
136 |
137 | @Param
138 | None
139 |
140 | @Returns
141 | true : output high
142 | false: output low
143 |
144 | @Example
145 |
146 | uint16_t dutyCycle;
147 | bool status;
148 | PWM3_Initialize();
149 | PWM3_LoadDutyValue(dutyCycle);
150 | while(1)
151 | {
152 | status = PWM3_OutputStatusGet();
153 | }
154 |
155 | */
156 | bool PWM3_OutputStatusGet(void);
157 |
158 | #ifdef __cplusplus // Provide C++ Compatibility
159 |
160 | }
161 |
162 | #endif
163 |
164 | #endif //PWM3_H
165 | /**
166 | End of File
167 | */
168 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/tmr2.c:
--------------------------------------------------------------------------------
1 | /**
2 | TMR2 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | tmr2.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the TMR2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides APIs for TMR2.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "tmr2.h"
53 |
54 | /**
55 | Section: Global Variables Definitions
56 | */
57 |
58 | /**
59 | Section: TMR2 APIs
60 | */
61 |
62 | void TMR2_Initialize(void)
63 | {
64 | // Set TMR2 to the options selected in the User Interface
65 |
66 | // PR2 255;
67 | PR2 = 0xFF;
68 |
69 | // TMR2 0;
70 | TMR2 = 0x00;
71 |
72 | // Clearing IF flag.
73 | PIR1bits.TMR2IF = 0;
74 |
75 | // T2CKPS 1:1; T2OUTPS 1:1; TMR2ON on;
76 | T2CON = 0x04;
77 | }
78 |
79 | void TMR2_StartTimer(void)
80 | {
81 | // Start the Timer by writing to TMRxON bit
82 | T2CONbits.TMR2ON = 1;
83 | }
84 |
85 | void TMR2_StopTimer(void)
86 | {
87 | // Stop the Timer by writing to TMRxON bit
88 | T2CONbits.TMR2ON = 0;
89 | }
90 |
91 | uint8_t TMR2_ReadTimer(void)
92 | {
93 | uint8_t readVal;
94 |
95 | readVal = TMR2;
96 |
97 | return readVal;
98 | }
99 |
100 | void TMR2_WriteTimer(uint8_t timerVal)
101 | {
102 | // Write to the Timer2 register
103 | TMR2 = timerVal;
104 | }
105 |
106 | void TMR2_LoadPeriodRegister(uint8_t periodVal)
107 | {
108 | PR2 = periodVal;
109 | }
110 |
111 | bool TMR2_HasOverflowOccured(void)
112 | {
113 | // check if overflow has occurred by checking the TMRIF bit
114 | bool status = PIR1bits.TMR2IF;
115 | if(status)
116 | {
117 | // Clearing IF flag.
118 | PIR1bits.TMR2IF = 0;
119 | }
120 | return status;
121 | }
122 | /**
123 | End of File
124 | */
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/tmr2.h:
--------------------------------------------------------------------------------
1 | /**
2 | TMR2 Generated Driver API Header File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | tmr2.h
9 |
10 | @Summary
11 | This is the generated header file for the TMR2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides APIs for TMR2.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef TMR2_H
48 | #define TMR2_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 |
57 | #ifdef __cplusplus // Provide C++ Compatibility
58 |
59 | extern "C" {
60 |
61 | #endif
62 |
63 |
64 | /**
65 | Section: Macro Declarations
66 | */
67 |
68 | /**
69 | Section: TMR2 APIs
70 | */
71 |
72 | /**
73 | @Summary
74 | Initializes the TMR2 module.
75 |
76 | @Description
77 | This function initializes the TMR2 Registers.
78 | This function must be called before any other TMR2 function is called.
79 |
80 | @Preconditions
81 | None
82 |
83 | @Param
84 | None
85 |
86 | @Returns
87 | None
88 |
89 | @Comment
90 |
91 |
92 | @Example
93 |
94 | main()
95 | {
96 | // Initialize TMR2 module
97 | TMR2_Initialize();
98 |
99 | // Do something else...
100 | }
101 |
102 | */
103 | void TMR2_Initialize(void);
104 |
105 | /**
106 | @Summary
107 | This function starts the TMR2.
108 |
109 | @Description
110 | This function starts the TMR2 operation.
111 | This function must be called after the initialization of TMR2.
112 |
113 | @Preconditions
114 | Initialize the TMR2 before calling this function.
115 |
116 | @Param
117 | None
118 |
119 | @Returns
120 | None
121 |
122 | @Example
123 |
124 | // Initialize TMR2 module
125 |
126 | // Start TMR2
127 | TMR2_StartTimer();
128 |
129 | // Do something else...
130 |
131 | */
132 | void TMR2_StartTimer(void);
133 |
134 | /**
135 | @Summary
136 | This function stops the TMR2.
137 |
138 | @Description
139 | This function stops the TMR2 operation.
140 | This function must be called after the start of TMR2.
141 |
142 | @Preconditions
143 | Initialize the TMR2 before calling this function.
144 |
145 | @Param
146 | None
147 |
148 | @Returns
149 | None
150 |
151 | @Example
152 |
153 | // Initialize TMR2 module
154 |
155 | // Start TMR2
156 | TMR2_StartTimer();
157 |
158 | // Do something else...
159 |
160 | // Stop TMR2;
161 | TMR2_StopTimer();
162 |
163 | */
164 | void TMR2_StopTimer(void);
165 |
166 | /**
167 | @Summary
168 | Reads the TMR2 register.
169 |
170 | @Description
171 | This function reads the TMR2 register value and return it.
172 |
173 | @Preconditions
174 | Initialize the TMR2 before calling this function.
175 |
176 | @Param
177 | None
178 |
179 | @Returns
180 | This function returns the current value of TMR2 register.
181 |
182 | @Example
183 |
184 | // Initialize TMR2 module
185 |
186 | // Start TMR2
187 | TMR2_StartTimer();
188 |
189 | // Read the current value of TMR2
190 | if(0 == TMR2_ReadTimer())
191 | {
192 | // Do something else...
193 |
194 | // Reload the TMR value
195 | TMR2_Reload();
196 | }
197 |
198 | */
199 | uint8_t TMR2_ReadTimer(void);
200 |
201 | /**
202 | @Summary
203 | Writes the TMR2 register.
204 |
205 | @Description
206 | This function writes the TMR2 register.
207 | This function must be called after the initialization of TMR2.
208 |
209 | @Preconditions
210 | Initialize the TMR2 before calling this function.
211 |
212 | @Param
213 | timerVal - Value to write into TMR2 register.
214 |
215 | @Returns
216 | None
217 |
218 | @Example
219 |
220 | #define PERIOD 0x80
221 | #define ZERO 0x00
222 |
223 | while(1)
224 | {
225 | // Read the TMR2 register
226 | if(ZERO == TMR2_ReadTimer())
227 | {
228 | // Do something else...
229 |
230 | // Write the TMR2 register
231 | TMR2_WriteTimer(PERIOD);
232 | }
233 |
234 | // Do something else...
235 | }
236 |
237 | */
238 | void TMR2_WriteTimer(uint8_t timerVal);
239 |
240 | /**
241 | @Summary
242 | Load value to Period Register.
243 |
244 | @Description
245 | This function writes the value to PR2 register.
246 | This function must be called after the initialization of TMR2.
247 |
248 | @Preconditions
249 | Initialize the TMR2 before calling this function.
250 |
251 | @Param
252 | periodVal - Value to load into TMR2 register.
253 |
254 | @Returns
255 | None
256 |
257 | @Example
258 |
259 | #define PERIOD1 0x80
260 | #define PERIOD2 0x40
261 | #define ZERO 0x00
262 |
263 | while(1)
264 | {
265 | // Read the TMR2 register
266 | if(ZERO == TMR2_ReadTimer())
267 | {
268 | // Do something else...
269 |
270 | if(flag)
271 | {
272 | flag = 0;
273 |
274 | // Load Period 1 value
275 | TMR2_LoadPeriodRegister(PERIOD1);
276 | }
277 | else
278 | {
279 | flag = 1;
280 |
281 | // Load Period 2 value
282 | TMR2_LoadPeriodRegister(PERIOD2);
283 | }
284 | }
285 |
286 | // Do something else...
287 | }
288 |
289 | */
290 | void TMR2_LoadPeriodRegister(uint8_t periodVal);
291 |
292 | /**
293 | @Summary
294 | Boolean routine to poll or to check for the match flag on the fly.
295 |
296 | @Description
297 | This function is called to check for the timer match flag.
298 | This function is used in timer polling method.
299 |
300 | @Preconditions
301 | Initialize the TMR2 module before calling this routine.
302 |
303 | @Param
304 | None
305 |
306 | @Returns
307 | true - timer match has occurred.
308 | false - timer match has not occurred.
309 |
310 | @Example
311 |
312 | while(1)
313 | {
314 | // check the match flag
315 | if(TMR2_HasOverflowOccured())
316 | {
317 | // Do something else...
318 |
319 | // Reload the TMR2 value
320 | TMR2_Reload();
321 | }
322 | }
323 |
324 | */
325 | bool TMR2_HasOverflowOccured(void);
326 |
327 | #ifdef __cplusplus // Provide C++ Compatibility
328 |
329 | }
330 |
331 | #endif
332 |
333 | #endif // TMR2_H
334 | /**
335 | End of File
336 | */
337 |
338 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/tmr3.c:
--------------------------------------------------------------------------------
1 | /**
2 | TMR3 Generated Driver File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | tmr3.c
9 |
10 | @Summary
11 | This is the generated driver implementation file for the TMR3 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This source file provides APIs for TMR3.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | /**
48 | Section: Included Files
49 | */
50 |
51 | #include
52 | #include "tmr3.h"
53 |
54 | /**
55 | Section: Global Variables Definitions
56 | */
57 | volatile uint16_t timer3ReloadVal;
58 | void (*TMR3_InterruptHandler)(void);
59 |
60 | /**
61 | Section: TMR3 APIs
62 | */
63 |
64 | void TMR3_Initialize(void)
65 | {
66 | //Set the Timer to the options selected in the GUI
67 |
68 | //T3GSS T3G_pin; TMR3GE disabled; T3GTM disabled; T3GPOL low; T3GGO_nDONE done; T3GSPM disabled;
69 | T3GCON = 0x00;
70 |
71 | //TMR3H 224;
72 | TMR3H = 0xE0;
73 |
74 | //TMR3L 192;
75 | TMR3L = 0xC0;
76 |
77 | // Load the TMR value to reload variable
78 | timer3ReloadVal=(uint16_t)((TMR3H << 8) | TMR3L);
79 |
80 | // Clearing IF flag before enabling the interrupt.
81 | PIR3bits.TMR3IF = 0;
82 |
83 | // Enabling TMR3 interrupt.
84 | PIE3bits.TMR3IE = 1;
85 |
86 | // Set Default Interrupt Handler
87 | TMR3_SetInterruptHandler(TMR3_DefaultInterruptHandler);
88 |
89 | // T3CKPS 1:1; T3SOSC T3CKI_enabled; T3SYNC synchronize; TMR3CS FOSC/4; TMR3ON enabled;
90 | T3CON = 0x01;
91 | }
92 |
93 | void TMR3_StartTimer(void)
94 | {
95 | // Start the Timer by writing to TMRxON bit
96 | T3CONbits.TMR3ON = 1;
97 | }
98 |
99 | void TMR3_StopTimer(void)
100 | {
101 | // Stop the Timer by writing to TMRxON bit
102 | T3CONbits.TMR3ON = 0;
103 | }
104 |
105 | uint16_t TMR3_ReadTimer(void)
106 | {
107 | uint16_t readVal;
108 | uint8_t readValHigh;
109 | uint8_t readValLow;
110 |
111 |
112 | readValLow = TMR3L;
113 | readValHigh = TMR3H;
114 |
115 | readVal = ((uint16_t)readValHigh << 8) | readValLow;
116 |
117 | return readVal;
118 | }
119 |
120 | void TMR3_WriteTimer(uint16_t timerVal)
121 | {
122 | if (T3CONbits.T3SYNC == 1)
123 | {
124 | // Stop the Timer by writing to TMRxON bit
125 | T3CONbits.TMR3ON = 0;
126 |
127 | // Write to the Timer3 register
128 | TMR3H = (timerVal >> 8);
129 | TMR3L = timerVal;
130 |
131 | // Start the Timer after writing to the register
132 | T3CONbits.TMR3ON =1;
133 | }
134 | else
135 | {
136 | // Write to the Timer3 register
137 | TMR3H = (timerVal >> 8);
138 | TMR3L = timerVal;
139 | }
140 | }
141 |
142 | void TMR3_Reload(void)
143 | {
144 | TMR3_WriteTimer(timer3ReloadVal);
145 | }
146 |
147 | void TMR3_StartSinglePulseAcquisition(void)
148 | {
149 | T3GCONbits.T3GGO_nDONE = 1;
150 | }
151 |
152 | uint8_t TMR3_CheckGateValueStatus(void)
153 | {
154 | return (T3GCONbits.T3GVAL);
155 | }
156 |
157 | void TMR3_ISR(void)
158 | {
159 |
160 | // Clear the TMR3 interrupt flag
161 | PIR3bits.TMR3IF = 0;
162 | TMR3_WriteTimer(timer3ReloadVal);
163 |
164 | // ticker function call;
165 | // ticker is 1 -> Callback function gets called everytime this ISR executes
166 | TMR3_CallBack();
167 | }
168 |
169 | void TMR3_CallBack(void)
170 | {
171 | // Add your custom callback code here
172 | if(TMR3_InterruptHandler)
173 | {
174 | TMR3_InterruptHandler();
175 | }
176 | }
177 |
178 | void TMR3_SetInterruptHandler(void (* InterruptHandler)(void)){
179 | TMR3_InterruptHandler = InterruptHandler;
180 | }
181 |
182 | void TMR3_DefaultInterruptHandler(void){
183 | // add your TMR3 interrupt custom code
184 | // or set custom function using TMR3_SetInterruptHandler()
185 | }
186 |
187 | /**
188 | End of File
189 | */
190 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/mcc_generated_files/tmr3.h:
--------------------------------------------------------------------------------
1 | /**
2 | TMR3 Generated Driver API Header File
3 |
4 | @Company
5 | Microchip Technology Inc.
6 |
7 | @File Name
8 | tmr3.h
9 |
10 | @Summary
11 | This is the generated header file for the TMR3 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
12 |
13 | @Description
14 | This header file provides APIs for driver for TMR3.
15 | Generation Information :
16 | Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
17 | Device : PIC16F18345
18 | Driver Version : 2.01
19 | The generated drivers are tested against the following:
20 | Compiler : XC8 1.45
21 | MPLAB : MPLAB X 4.15
22 | */
23 |
24 | /*
25 | (c) 2018 Microchip Technology Inc. and its subsidiaries.
26 |
27 | Subject to your compliance with these terms, you may use Microchip software and any
28 | derivatives exclusively with Microchip products. It is your responsibility to comply with third party
29 | license terms applicable to your use of third party software (including open source software) that
30 | may accompany Microchip software.
31 |
32 | THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
33 | EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
34 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
35 | FOR A PARTICULAR PURPOSE.
36 |
37 | IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
38 | INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
39 | WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
40 | HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
41 | THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
42 | CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
43 | OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
44 | SOFTWARE.
45 | */
46 |
47 | #ifndef TMR3_H
48 | #define TMR3_H
49 |
50 | /**
51 | Section: Included Files
52 | */
53 |
54 | #include
55 | #include
56 |
57 | #ifdef __cplusplus // Provide C++ Compatibility
58 |
59 | extern "C" {
60 |
61 | #endif
62 |
63 | #define TMR3_INTERRUPT_TICKER_FACTOR 1
64 |
65 | /**
66 | Section: TMR3 APIs
67 | */
68 |
69 | /**
70 | @Summary
71 | Initializes the TMR3
72 |
73 | @Description
74 | This routine initializes the TMR3.
75 | This routine must be called before any other TMR3 routine is called.
76 | This routine should only be called once during system initialization.
77 |
78 | @Preconditions
79 | None
80 |
81 | @Param
82 | None
83 |
84 | @Returns
85 | None
86 |
87 | @Comment
88 |
89 |
90 | @Example
91 |
92 | main()
93 | {
94 | // Initialize TMR3 module
95 | TMR3_Initialize();
96 |
97 | // Do something else...
98 | }
99 |
100 | */
101 | void TMR3_Initialize(void);
102 |
103 | /**
104 | @Summary
105 | This function starts the TMR3.
106 |
107 | @Description
108 | This function starts the TMR3 operation.
109 | This function must be called after the initialization of TMR3.
110 |
111 | @Preconditions
112 | Initialize the TMR3 before calling this function.
113 |
114 | @Param
115 | None
116 |
117 | @Returns
118 | None
119 |
120 | @Example
121 |
122 | // Initialize TMR3 module
123 |
124 | // Start TMR3
125 | TMR3_StartTimer();
126 |
127 | // Do something else...
128 |
129 | */
130 | void TMR3_StartTimer(void);
131 |
132 | /**
133 | @Summary
134 | This function stops the TMR3.
135 |
136 | @Description
137 | This function stops the TMR3 operation.
138 | This function must be called after the start of TMR3.
139 |
140 | @Preconditions
141 | Initialize the TMR3 before calling this function.
142 |
143 | @Param
144 | None
145 |
146 | @Returns
147 | None
148 |
149 | @Example
150 |
151 | // Initialize TMR3 module
152 |
153 | // Start TMR3
154 | TMR3_StartTimer();
155 |
156 | // Do something else...
157 |
158 | // Stop TMR3;
159 | TMR3_StopTimer();
160 |
161 | */
162 | void TMR3_StopTimer(void);
163 |
164 | /**
165 | @Summary
166 | Reads the TMR3 register.
167 |
168 | @Description
169 | This function reads the TMR3 register value and return it.
170 |
171 | @Preconditions
172 | Initialize the TMR3 before calling this function.
173 |
174 | @Param
175 | None
176 |
177 | @Returns
178 | This function returns the current value of TMR3 register.
179 |
180 | @Example
181 |
182 | // Initialize TMR3 module
183 |
184 | // Start TMR3
185 | TMR3_StartTimer();
186 |
187 | // Read the current value of TMR3
188 | if(0 == TMR3_ReadTimer())
189 | {
190 | // Do something else...
191 |
192 | // Reload the TMR value
193 | TMR3_Reload();
194 | }
195 |
196 | */
197 | uint16_t TMR3_ReadTimer(void);
198 |
199 | /**
200 | @Summary
201 | Writes the TMR3 register.
202 |
203 | @Description
204 | This function writes the TMR3 register.
205 | This function must be called after the initialization of TMR3.
206 |
207 | @Preconditions
208 | Initialize the TMR3 before calling this function.
209 |
210 | @Param
211 | timerVal - Value to write into TMR3 register.
212 |
213 | @Returns
214 | None
215 |
216 | @Example
217 |
218 | #define PERIOD 0x80
219 | #define ZERO 0x00
220 |
221 | while(1)
222 | {
223 | // Read the TMR3 register
224 | if(ZERO == TMR3_ReadTimer())
225 | {
226 | // Do something else...
227 |
228 | // Write the TMR3 register
229 | TMR3_WriteTimer(PERIOD);
230 | }
231 |
232 | // Do something else...
233 | }
234 |
235 | */
236 | void TMR3_WriteTimer(uint16_t timerVal);
237 |
238 | /**
239 | @Summary
240 | Reload the TMR3 register.
241 |
242 | @Description
243 | This function reloads the TMR3 register.
244 | This function must be called to write initial value into TMR3 register.
245 |
246 | @Preconditions
247 | Initialize the TMR3 before calling this function.
248 |
249 | @Param
250 | None
251 |
252 | @Returns
253 | None
254 |
255 | @Example
256 |
257 | while(1)
258 | {
259 | if(TMR3IF)
260 | {
261 | // Do something else...
262 |
263 | // clear the TMR3 interrupt flag
264 | TMR3IF = 0;
265 |
266 | // Reload the initial value of TMR3
267 | TMR3_Reload();
268 | }
269 | }
270 |
271 | */
272 | void TMR3_Reload(void);
273 |
274 | /**
275 | @Summary
276 | Starts the single pulse acquisition in TMR3 gate operation.
277 |
278 | @Description
279 | This function starts the single pulse acquisition in TMR3 gate operation.
280 | This function must be used when the TMR3 gate is enabled.
281 |
282 | @Preconditions
283 | Initialize the TMR3 with gate enable before calling this function.
284 |
285 | @Param
286 | None
287 |
288 | @Returns
289 | None
290 |
291 | @Example
292 |
293 | uint16_t xVal;
294 | uint16_t yVal;
295 |
296 | // enable TMR3 singlepulse mode
297 | TMR3_StartSinglePulseAcquistion();
298 |
299 | // check TMR3 gate status
300 | if(TMR3_CheckGateValueStatus()== 0)
301 | xVal = TMR3_ReadTimer();
302 |
303 | // wait untill gate interrupt occured
304 | while(TMR3GIF == 0)
305 | {
306 | }
307 |
308 | yVal = TMR3_ReadTimer();
309 |
310 | */
311 | void TMR3_StartSinglePulseAcquisition(void);
312 |
313 | /**
314 | @Summary
315 | Check the current state of Timer1 gate.
316 |
317 | @Description
318 | This function reads the TMR3 gate value and return it.
319 | This function must be used when the TMR3 gate is enabled.
320 |
321 | @Preconditions
322 | Initialize the TMR3 with gate enable before calling this function.
323 |
324 | @Param
325 | None
326 |
327 | @Returns
328 | None
329 |
330 | @Example
331 |
332 | uint16_t xVal;
333 | uint16_t yVal;
334 |
335 | // enable TMR3 singlepulse mode
336 | TMR3_StartSinglePulseAcquistion();
337 |
338 | // check TMR3 gate status
339 | if(TMR3_CheckGateValueStatus()== 0)
340 | xVal = TMR3_ReadTimer();
341 |
342 | // wait untill gate interrupt occured
343 | while(TMR3IF == 0)
344 | {
345 | }
346 |
347 | yVal = TMR3_ReadTimer();
348 |
349 | */
350 | uint8_t TMR3_CheckGateValueStatus(void);
351 |
352 | /**
353 | @Summary
354 | Timer Interrupt Service Routine
355 |
356 | @Description
357 | Timer Interrupt Service Routine is called by the Interrupt Manager.
358 |
359 | @Preconditions
360 | Initialize the TMR3 module with interrupt before calling this ISR.
361 |
362 | @Param
363 | None
364 |
365 | @Returns
366 | None
367 | */
368 | void TMR3_ISR(void);
369 | /**
370 | @Summary
371 | CallBack function.
372 |
373 | @Description
374 | This routine is called by the Interrupt Manager.
375 |
376 | @Preconditions
377 | Initialize the TMR3 module with interrupt before calling this function.
378 |
379 | @Param
380 | None
381 |
382 | @Returns
383 | None
384 | */
385 | void TMR3_CallBack(void);
386 |
387 | /**
388 | @Summary
389 | Set Timer Interrupt Handler
390 |
391 | @Description
392 | This sets the function to be called during the ISR
393 |
394 | @Preconditions
395 | Initialize the TMR3 module with interrupt before calling this.
396 |
397 | @Param
398 | Address of function to be set
399 |
400 | @Returns
401 | None
402 | */
403 | void TMR3_SetInterruptHandler(void (* InterruptHandler)(void));
404 |
405 | /**
406 | @Summary
407 | Timer Interrupt Handler
408 |
409 | @Description
410 | This is a function pointer to the function that will be called during the ISR
411 |
412 | @Preconditions
413 | Initialize the TMR3 module with interrupt before calling this isr.
414 |
415 | @Param
416 | None
417 |
418 | @Returns
419 | None
420 | */
421 | extern void (*TMR3_InterruptHandler)(void);
422 |
423 | /**
424 | @Summary
425 | Default Timer Interrupt Handler
426 |
427 | @Description
428 | This is the default Interrupt Handler function
429 |
430 | @Preconditions
431 | Initialize the TMR3 module with interrupt before calling this isr.
432 |
433 | @Param
434 | None
435 |
436 | @Returns
437 | None
438 | */
439 | void TMR3_DefaultInterruptHandler(void);
440 |
441 | #ifdef __cplusplus // Provide C++ Compatibility
442 |
443 | }
444 |
445 | #endif
446 |
447 | #endif // TMR3_H
448 | /**
449 | End of File
450 | */
451 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/Makefile-genesis.properties:
--------------------------------------------------------------------------------
1 | #
2 | #Fri Apr 05 15:26:28 CEST 2019
3 | default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v2.05\\bin
4 | configurations-xml=31d7699927247e297146d625ca0bc68b
5 | com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=fe6bc8387062251d924fb28d44703093
6 | default.languagetoolchain.version=2.05
7 | host.platform=windows
8 | conf.ids=default
9 | default.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=efa527c24802a2aace7644337aca6c98
10 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/Makefile-genesis.properties.mine:
--------------------------------------------------------------------------------
1 | #
2 | #Mon Sep 24 21:46:59 CEST 2018
3 | default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v2.00\\bin
4 | configurations-xml=6b21c33f49f08c0d9afb19034f0c32bb
5 | com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=9d53b989b6ed2b6446aae58c2779ca87
6 | default.languagetoolchain.version=2.00
7 | host.platform=windows
8 | conf.ids=default
9 | default.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=d0b8fdc2be6cb87257c6731763a65529
10 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/Makefile-impl.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Generated Makefile - do not edit!
3 | #
4 | # Edit the Makefile in the project folder instead (../Makefile). Each target
5 | # has a pre- and a post- target defined where you can add customization code.
6 | #
7 | # This makefile implements macros and targets common to all configurations.
8 | #
9 | # NOCDDL
10 |
11 |
12 | # Building and Cleaning subprojects are done by default, but can be controlled with the SUB
13 | # macro. If SUB=no, subprojects will not be built or cleaned. The following macro
14 | # statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
15 | # and .clean-reqprojects-conf unless SUB has the value 'no'
16 | SUB_no=NO
17 | SUBPROJECTS=${SUB_${SUB}}
18 | BUILD_SUBPROJECTS_=.build-subprojects
19 | BUILD_SUBPROJECTS_NO=
20 | BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
21 | CLEAN_SUBPROJECTS_=.clean-subprojects
22 | CLEAN_SUBPROJECTS_NO=
23 | CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
24 |
25 |
26 | # Project Name
27 | PROJECTNAME=I2CNavKey.X
28 |
29 | # Active Configuration
30 | DEFAULTCONF=default
31 | CONF=${DEFAULTCONF}
32 |
33 | # All Configurations
34 | ALLCONFS=default
35 |
36 |
37 | # build
38 | .build-impl: .build-pre
39 | ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf
40 |
41 |
42 | # clean
43 | .clean-impl: .clean-pre
44 | ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf
45 |
46 | # clobber
47 | .clobber-impl: .clobber-pre .depcheck-impl
48 | ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean
49 |
50 |
51 |
52 | # all
53 | .all-impl: .all-pre .depcheck-impl
54 | ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build
55 |
56 |
57 |
58 | # dependency checking support
59 | .depcheck-impl:
60 | # @echo "# This code depends on make tool being used" >.dep.inc
61 | # @if [ -n "${MAKE_VERSION}" ]; then \
62 | # echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
63 | # echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
64 | # echo "include \$${DEPFILES}" >>.dep.inc; \
65 | # echo "endif" >>.dep.inc; \
66 | # else \
67 | # echo ".KEEP_STATE:" >>.dep.inc; \
68 | # echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
69 | # fi
70 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/Makefile-local-default.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Generated Makefile - do not edit!
3 | #
4 | #
5 | # This file contains information about the location of compilers and other tools.
6 | # If you commmit this file into your revision control server, you will be able to
7 | # to checkout the project and build it from the command line with make. However,
8 | # if more than one person works on the same project, then this file might show
9 | # conflicts since different users are bound to have compilers in different places.
10 | # In that case you might choose to not commit this file and let MPLAB X recreate this file
11 | # for each user. The disadvantage of not commiting this file is that you must run MPLAB X at
12 | # least once so the file gets created and the project can be built. Finally, you can also
13 | # avoid using this file at all if you are only building from the command line with make.
14 | # You can invoke make with the values of the macros:
15 | # $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
16 | #
17 | SHELL=cmd.exe
18 | PATH_TO_IDE_BIN=C:/Program Files (x86)/Microchip/MPLABX/v5.15/mplab_platform/platform/../mplab_ide/modules/../../bin/
19 | # Adding MPLAB X bin directory to path.
20 | PATH:=C:/Program Files (x86)/Microchip/MPLABX/v5.15/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH)
21 | # Path to java used to run MPLAB X when this makefile was created
22 | MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\v5.15\sys\java\jre1.8.0_181/bin/"
23 | OS_CURRENT="$(shell uname -s)"
24 | MP_CC="C:\Program Files (x86)\Microchip\xc8\v2.05\bin\xc8-cc.exe"
25 | # MP_CPPC is not defined
26 | # MP_BC is not defined
27 | MP_AS="C:\Program Files (x86)\Microchip\xc8\v2.05\bin\xc8-cc.exe"
28 | MP_LD="C:\Program Files (x86)\Microchip\xc8\v2.05\bin\xc8-cc.exe"
29 | MP_AR="C:\Program Files (x86)\Microchip\xc8\v2.05\bin\xc8-ar.exe"
30 | DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/v5.15/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
31 | MP_CC_DIR="C:\Program Files (x86)\Microchip\xc8\v2.05\bin"
32 | # MP_CPPC_DIR is not defined
33 | # MP_BC_DIR is not defined
34 | MP_AS_DIR="C:\Program Files (x86)\Microchip\xc8\v2.05\bin"
35 | MP_LD_DIR="C:\Program Files (x86)\Microchip\xc8\v2.05\bin"
36 | MP_AR_DIR="C:\Program Files (x86)\Microchip\xc8\v2.05\bin"
37 | # MP_BC_DIR is not defined
38 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/Makefile-variables.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Generated - do not edit!
3 | #
4 | # NOCDDL
5 | #
6 | CND_BASEDIR=`pwd`
7 | # default configuration
8 | CND_ARTIFACT_DIR_default=dist/default/production
9 | CND_ARTIFACT_NAME_default=I2CNavKey.X.production.hex
10 | CND_ARTIFACT_PATH_default=dist/default/production/I2CNavKey.X.production.hex
11 | CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package
12 | CND_PACKAGE_NAME_default=i2cnavkey.x.tar
13 | CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/i2cnavkey.x.tar
14 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/Package-default.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | #
4 | # Generated - do not edit!
5 | #
6 |
7 | # Macros
8 | TOP=`pwd`
9 | CND_CONF=default
10 | CND_DISTDIR=dist
11 | TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging
12 | TMPDIRNAME=tmp-packaging
13 | OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/I2CNavKey.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
14 | OUTPUT_BASENAME=I2CNavKey.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
15 | PACKAGE_TOP_DIR=i2cnavkey.x/
16 |
17 | # Functions
18 | function checkReturnCode
19 | {
20 | rc=$?
21 | if [ $rc != 0 ]
22 | then
23 | exit $rc
24 | fi
25 | }
26 | function makeDirectory
27 | # $1 directory path
28 | # $2 permission (optional)
29 | {
30 | mkdir -p "$1"
31 | checkReturnCode
32 | if [ "$2" != "" ]
33 | then
34 | chmod $2 "$1"
35 | checkReturnCode
36 | fi
37 | }
38 | function copyFileToTmpDir
39 | # $1 from-file path
40 | # $2 to-file path
41 | # $3 permission
42 | {
43 | cp "$1" "$2"
44 | checkReturnCode
45 | if [ "$3" != "" ]
46 | then
47 | chmod $3 "$2"
48 | checkReturnCode
49 | fi
50 | }
51 |
52 | # Setup
53 | cd "${TOP}"
54 | mkdir -p ${CND_DISTDIR}/${CND_CONF}/package
55 | rm -rf ${TMPDIR}
56 | mkdir -p ${TMPDIR}
57 |
58 | # Copy files and create directories and links
59 | cd "${TOP}"
60 | makeDirectory ${TMPDIR}/i2cnavkey.x/bin
61 | copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
62 |
63 |
64 | # Generate tar file
65 | cd "${TOP}"
66 | rm -f ${CND_DISTDIR}/${CND_CONF}/package/i2cnavkey.x.tar
67 | cd ${TMPDIR}
68 | tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/i2cnavkey.x.tar *
69 | checkReturnCode
70 |
71 | # Cleanup
72 | cd "${TOP}"
73 | rm -rf ${TMPDIR}
74 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/SuppressibleMessageMemo.properties:
--------------------------------------------------------------------------------
1 | #
2 | #Thu Mar 14 12:04:58 CET 2019
3 | PICkit\ 4/CHECK_4_HIGH_VOLTAGE_VPP=true
4 | pk3/CHECK_4_HIGH_VOLTAGE_VPP=true
5 | mdbDebugger/SOFTWARE_BREAK_POINT_PREFERENCE=true
6 | pk3/DEVID_MISMATCH=true
7 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/configurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Makefile
4 | 0
5 |
6 |
7 |
8 | C:\Program Files (x86)\Microchip\xc8\v2.05\bin
9 |
10 | place holder 1
11 | place holder 2
12 |
13 |
14 |
15 |
16 | true
17 | 0
18 | 0
19 | 0
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/private.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/i2c_register.c
7 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/i2c1.c
8 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/NavKey.c
9 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/NavKey.h
10 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/pin_manager.h
11 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/mcc.c
12 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/DataVariable.h
13 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/DataVariable.c
14 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/GPports.c
15 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/pin_manager.c
16 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/main.c
17 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/i2c_register.h
18 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/interrupt_manager.c
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/private.xml.2.mine:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/i2c_register.c
7 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/main.c
8 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/NavKey.c
9 | file:/C:/Users/scaron/SVN/I2CNavKey/FW/I2CNavKey.X/NavKey.h
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/private.xml.mine:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/adc.c
7 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/tmr3.c
8 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/tmr2.c
9 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/clc2.c
10 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/pwm1.c
11 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/pwm2.c
12 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/pwm4.c
13 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/Encoder.h
14 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/i2c_register.h
15 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/GPports.c
16 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/DataVariable.c
17 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/main.h
18 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/interrupt_manager.h
19 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/DataVariable.h
20 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/GPports.h
21 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/Encoder.c
22 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/i2c_register.c
23 | file:/D:/Users/Saimon/Documents/SVNProjects/EncoderI2C/FW/I2CEncoderV2.X/main.c
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/private.xml.r178:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/DataVariable.c
7 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/GPports.c
8 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/i2c_register.h
9 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/main.c
10 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/pin_manager.h
11 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/DataVariable.h
12 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/i2c_register.c
13 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/main.h
14 | file:/C:/Users/admin/Documents/SVNProject/EncoderI2C/FW/I2CEncoderV2.X/Encoder.c
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/private.xml.r183:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/C:/Users/scaron/SVN/EncoderI2C/FW/I2CEncoderV2.X/main.c
7 | file:/C:/Users/scaron/SVN/EncoderI2C/FW/I2CEncoderV2.X/DataVariable.h
8 | file:/C:/Users/scaron/SVN/EncoderI2C/FW/I2CEncoderV2.X/Encoder.c
9 | file:/C:/Users/scaron/SVN/EncoderI2C/FW/I2CEncoderV2.X/mcc_generated_files/mcc.h
10 | file:/C:/Users/scaron/SVN/EncoderI2C/FW/I2CEncoderV2.X/Encoder.h
11 | file:/C:/Users/scaron/SVN/EncoderI2C/FW/I2CEncoderV2.X/main.h
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/private.xml.r28:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/pin_manager.c
7 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/adc.h
8 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/main.c
9 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/clc1.c
10 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/DataVariable.c
11 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/GPports.c
12 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/interrupt_manager.c
13 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/NavKey.c
14 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/pwm1.c
15 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/i2c_register.c
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/private/private.xml.r30:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/DataVariable.h
7 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/pin_manager.c
8 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/i2c1.c
9 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/i2c_register.h
10 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/clc1.c
11 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/pwm1.c
12 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/i2c_register.c
13 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/main.h
14 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/NavKey.h
15 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/mcc.h
16 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/adc.h
17 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/PWM.c
18 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/main.c
19 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/DataVariable.c
20 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/GPports.c
21 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/mcc_generated_files/interrupt_manager.c
22 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/NavKey.c
23 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/GPports.h
24 | file:/D:/Users/Saimon/Documents/SVNProjects/I2CNavKey/FW/I2CNavKey.X/PWM.h
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Firmware/I2CNavKey.X/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.microchip.mplab.nbide.embedded.makeproject
4 |
5 |
6 | I2CNavKey
7 | 273dd53e-8efe-4eb6-9476-4bc1ed0dcc38
8 | 0
9 | c
10 |
11 | h
12 |
13 | ISO-8859-1
14 |
15 |
16 | .
17 |
18 |
19 |
20 | default
21 | 2
22 |
23 |
24 |
25 | false
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Hardware/BOM/Bill of Materials-I2CNavKey.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/Hardware/BOM/Bill of Materials-I2CNavKey.xls
--------------------------------------------------------------------------------
/Hardware/Gerber/I2CNavKey.GBP:
--------------------------------------------------------------------------------
1 | G04*
2 | G04 #@! TF.GenerationSoftware,Altium Limited,Altium Designer,19.0.10 (269)*
3 | G04*
4 | G04 Layer_Color=128*
5 | %FSLAX25Y25*%
6 | %MOIN*%
7 | G70*
8 | G01*
9 | G75*
10 | G04:AMPARAMS|DCode=29|XSize=24.5mil|YSize=26mil|CornerRadius=6.13mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=135.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=RoundedRectangle|*
11 | %AMROUNDEDRECTD29*
12 | 21,1,0.02450,0.01375,0,0,135.0*
13 | 21,1,0.01225,0.02600,0,0,135.0*
14 | 1,1,0.01225,0.00053,0.00919*
15 | 1,1,0.01225,0.00919,0.00053*
16 | 1,1,0.01225,-0.00053,-0.00919*
17 | 1,1,0.01225,-0.00919,-0.00053*
18 | %
19 | %ADD29ROUNDEDRECTD29*%
20 | G04:AMPARAMS|DCode=30|XSize=62.99mil|YSize=118.11mil|CornerRadius=0mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=315.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=Rectangle|*
21 | %AMROTATEDRECTD30*
22 | 4,1,4,-0.06403,-0.01949,0.01949,0.06403,0.06403,0.01949,-0.01949,-0.06403,-0.06403,-0.01949,0.0*
23 | %
24 | %ADD30ROTATEDRECTD30*%
25 |
26 | G04:AMPARAMS|DCode=31|XSize=51.18mil|YSize=157.48mil|CornerRadius=0mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=315.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=Rectangle|*
27 | %AMROTATEDRECTD31*
28 | 4,1,4,-0.07377,-0.03758,0.03758,0.07377,0.07377,0.03758,-0.03758,-0.07377,-0.07377,-0.03758,0.0*
29 | %
30 | %ADD31ROTATEDRECTD31*%
31 |
32 | G04:AMPARAMS|DCode=32|XSize=35mil|YSize=41mil|CornerRadius=8.75mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=0.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=RoundedRectangle|*
33 | %AMROUNDEDRECTD32*
34 | 21,1,0.03500,0.02350,0,0,0.0*
35 | 21,1,0.01750,0.04100,0,0,0.0*
36 | 1,1,0.01750,0.00875,-0.01175*
37 | 1,1,0.01750,-0.00875,-0.01175*
38 | 1,1,0.01750,-0.00875,0.01175*
39 | 1,1,0.01750,0.00875,0.01175*
40 | %
41 | %ADD32ROUNDEDRECTD32*%
42 | G04:AMPARAMS|DCode=34|XSize=24.5mil|YSize=26mil|CornerRadius=6.13mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=90.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=RoundedRectangle|*
43 | %AMROUNDEDRECTD34*
44 | 21,1,0.02450,0.01375,0,0,90.0*
45 | 21,1,0.01225,0.02600,0,0,90.0*
46 | 1,1,0.01225,0.00688,0.00613*
47 | 1,1,0.01225,0.00688,-0.00613*
48 | 1,1,0.01225,-0.00688,-0.00613*
49 | 1,1,0.01225,-0.00688,0.00613*
50 | %
51 | %ADD34ROUNDEDRECTD34*%
52 | G04:AMPARAMS|DCode=35|XSize=24.5mil|YSize=26mil|CornerRadius=6.13mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=180.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=RoundedRectangle|*
53 | %AMROUNDEDRECTD35*
54 | 21,1,0.02450,0.01375,0,0,180.0*
55 | 21,1,0.01225,0.02600,0,0,180.0*
56 | 1,1,0.01225,-0.00613,0.00688*
57 | 1,1,0.01225,0.00613,0.00688*
58 | 1,1,0.01225,0.00613,-0.00688*
59 | 1,1,0.01225,-0.00613,-0.00688*
60 | %
61 | %ADD35ROUNDEDRECTD35*%
62 | G04:AMPARAMS|DCode=37|XSize=9.84mil|YSize=23.62mil|CornerRadius=0mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=135.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=Round|*
63 | %AMOVALD37*
64 | 21,1,0.01378,0.00984,0.00000,0.00000,225.0*
65 | 1,1,0.00984,0.00487,0.00487*
66 | 1,1,0.00984,-0.00487,-0.00487*
67 | %
68 | %ADD37OVALD37*%
69 |
70 | G04:AMPARAMS|DCode=38|XSize=9.84mil|YSize=23.62mil|CornerRadius=0mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=45.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=Round|*
71 | %AMOVALD38*
72 | 21,1,0.01378,0.00984,0.00000,0.00000,135.0*
73 | 1,1,0.00984,0.00487,-0.00487*
74 | 1,1,0.00984,-0.00487,0.00487*
75 | %
76 | %ADD38OVALD38*%
77 |
78 | %ADD57P,0.05568X4X360.0*%
79 | G04:AMPARAMS|DCode=58|XSize=39.37mil|YSize=39.37mil|CornerRadius=0mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=45.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=Rectangle|*
80 | %AMROTATEDRECTD58*
81 | 4,1,4,0.00000,-0.02784,-0.02784,0.00000,0.00000,0.02784,0.02784,0.00000,0.00000,-0.02784,0.0*
82 | %
83 | %ADD58ROTATEDRECTD58*%
84 |
85 | G04:AMPARAMS|DCode=59|XSize=39.37mil|YSize=39.37mil|CornerRadius=0mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=225.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=Rectangle|*
86 | %AMROTATEDRECTD59*
87 | 4,1,4,0.00000,0.02784,0.02784,0.00000,0.00000,-0.02784,-0.02784,0.00000,0.00000,0.02784,0.0*
88 | %
89 | %ADD59ROTATEDRECTD59*%
90 |
91 | G04:AMPARAMS|DCode=60|XSize=39.37mil|YSize=39.37mil|CornerRadius=0mil|HoleSize=0mil|Usage=FLASHONLY|Rotation=135.000|XOffset=0mil|YOffset=0mil|HoleType=Round|Shape=Rectangle|*
92 | %AMROTATEDRECTD60*
93 | 4,1,4,0.02784,0.00000,0.00000,-0.02784,-0.02784,0.00000,0.00000,0.02784,0.02784,0.00000,0.0*
94 | %
95 | %ADD60ROTATEDRECTD60*%
96 |
97 | D29*
98 | X3706Y-17485D02*
99 | D03*
100 | X1019Y-14798D02*
101 | D03*
102 | X7515Y-21294D02*
103 | D03*
104 | X10202Y-23981D02*
105 | D03*
106 | X21422Y17554D02*
107 | D03*
108 | X18735Y20241D02*
109 | D03*
110 | D30*
111 | X8319Y-36780D02*
112 | D03*
113 | X-36780Y8319D02*
114 | D03*
115 | D31*
116 | X-14370Y-42209D02*
117 | D03*
118 | X-21329Y-35249D02*
119 | D03*
120 | X-28289Y-28289D02*
121 | D03*
122 | X-35249Y-21329D02*
123 | D03*
124 | X-42209Y-14370D02*
125 | D03*
126 | D32*
127 | X37795Y17717D02*
128 | D03*
129 | X44094D02*
130 | D03*
131 | D34*
132 | X5512Y40226D02*
133 | D03*
134 | Y44026D02*
135 | D03*
136 | X0Y40226D02*
137 | D03*
138 | Y44026D02*
139 | D03*
140 | X-5512Y40226D02*
141 | D03*
142 | Y44026D02*
143 | D03*
144 | X27559Y34517D02*
145 | D03*
146 | X27559Y38317D02*
147 | D03*
148 | X34646Y-17648D02*
149 | D03*
150 | Y-13848D02*
151 | D03*
152 | X28346D02*
153 | D03*
154 | Y-17648D02*
155 | D03*
156 | X34646Y-22903D02*
157 | D03*
158 | Y-26703D02*
159 | D03*
160 | D35*
161 | X21979Y34517D02*
162 | D03*
163 | X18179Y34517D02*
164 | D03*
165 | Y40551D02*
166 | D03*
167 | X21979Y40551D02*
168 | D03*
169 | X27628Y17717D02*
170 | D03*
171 | X31428D02*
172 | D03*
173 | D37*
174 | X19375Y11445D02*
175 | D03*
176 | X17983Y12837D02*
177 | D03*
178 | X16591Y14229D02*
179 | D03*
180 | X15199Y15621D02*
181 | D03*
182 | X13807Y17013D02*
183 | D03*
184 | X2672Y5878D02*
185 | D03*
186 | X4064Y4486D02*
187 | D03*
188 | X5456Y3094D02*
189 | D03*
190 | X6848Y1702D02*
191 | D03*
192 | X8240Y310D02*
193 | D03*
194 | D38*
195 | Y17013D02*
196 | D03*
197 | X6848Y15621D02*
198 | D03*
199 | X5456Y14229D02*
200 | D03*
201 | X4064Y12837D02*
202 | D03*
203 | X2672Y11445D02*
204 | D03*
205 | X13807Y310D02*
206 | D03*
207 | X15199Y1702D02*
208 | D03*
209 | X16591Y3094D02*
210 | D03*
211 | X17983Y4486D02*
212 | D03*
213 | X19375Y5878D02*
214 | D03*
215 | D57*
216 | X6848Y8661D02*
217 | D03*
218 | D58*
219 | X11024Y4486D02*
220 | D03*
221 | D59*
222 | X11024Y12837D02*
223 | D03*
224 | D60*
225 | X15199Y8661D02*
226 | D03*
227 | M02*
228 |
--------------------------------------------------------------------------------
/Hardware/Gerber/I2CNavKey.GKO:
--------------------------------------------------------------------------------
1 | G04*
2 | G04 #@! TF.GenerationSoftware,Altium Limited,Altium Designer,19.0.10 (269)*
3 | G04*
4 | G04 Layer_Color=16711935*
5 | %FSLAX25Y25*%
6 | %MOIN*%
7 | G70*
8 | G01*
9 | G75*
10 | %ADD18C,0.00800*%
11 | D18*
12 | X-78740Y-55118D02*
13 | G03*
14 | X-78740Y55118I-163224J55118D01*
15 | G01*
16 | X-55118Y78740D02*
17 | G03*
18 | X55118Y78740I55118J163224D01*
19 | G01*
20 | X78740Y55118D02*
21 | G03*
22 | X78740Y-55118I163224J-55118D01*
23 | G01*
24 | X55118Y-78740D02*
25 | G03*
26 | X-55118Y-78740I-55118J-163224D01*
27 | G01*
28 | Y78740D02*
29 | G03*
30 | X-78740Y55118I-11811J-11811D01*
31 | G01*
32 | Y-55118D02*
33 | G03*
34 | X-55118Y-78740I11811J-11811D01*
35 | G01*
36 | X55118D02*
37 | G03*
38 | X78740Y-55118I11811J11811D01*
39 | G01*
40 | Y55118D02*
41 | G03*
42 | X55118Y78740I-11811J11811D01*
43 | G01*
44 | M02*
45 |
--------------------------------------------------------------------------------
/Hardware/Gerber/I2CNavKey.GTO:
--------------------------------------------------------------------------------
1 | G04*
2 | G04 #@! TF.GenerationSoftware,Altium Limited,Altium Designer,19.0.10 (269)*
3 | G04*
4 | G04 Layer_Color=65535*
5 | %FSLAX25Y25*%
6 | %MOIN*%
7 | G70*
8 | G01*
9 | G75*
10 | %ADD10C,0.01000*%
11 | D10*
12 | X67716Y0D02*
13 | G03*
14 | X67716Y0I-67716J0D01*
15 | G01*
16 | M02*
17 |
--------------------------------------------------------------------------------
/Hardware/Gerber/I2CNavKey.GTS:
--------------------------------------------------------------------------------
1 | G04*
2 | G04 #@! TF.GenerationSoftware,Altium Limited,Altium Designer,19.0.10 (269)*
3 | G04*
4 | G04 Layer_Color=8388736*
5 | %FSLAX25Y25*%
6 | %MOIN*%
7 | G70*
8 | G01*
9 | G75*
10 | %ADD11C,0.09855*%
11 | %ADD12C,0.07493*%
12 | %ADD13C,0.16548*%
13 | %ADD14C,0.20485*%
14 | %ADD15C,0.00400*%
15 | D11*
16 | X-25779Y25779D02*
17 | D03*
18 | X25779Y-25779D02*
19 | D03*
20 | X-4371Y-4371D02*
21 | D03*
22 | X-63584Y-14198D02*
23 | D03*
24 | X-12806Y-63305D02*
25 | D03*
26 | X-30511Y59464D02*
27 | D03*
28 | X25779Y25779D02*
29 | D03*
30 | X63584Y14198D02*
31 | D03*
32 | X30511Y-59464D02*
33 | D03*
34 | D12*
35 | X12528Y-12528D02*
36 | D03*
37 | X-12528Y12528D02*
38 | D03*
39 | D13*
40 | X41758Y-41758D02*
41 | D03*
42 | Y41758D02*
43 | D03*
44 | X-41758D02*
45 | D03*
46 | Y-41758D02*
47 | D03*
48 | D14*
49 | X-66929Y66929D02*
50 | D03*
51 | X66929D02*
52 | D03*
53 | Y-66929D02*
54 | D03*
55 | X-66929D02*
56 | D03*
57 | D15*
58 | X60039Y45039D02*
59 | D03*
60 | X67539Y30039D02*
61 | D03*
62 | X60039Y-14961D02*
63 | D03*
64 | X67539Y-29961D02*
65 | D03*
66 | X60039Y-44961D02*
67 | D03*
68 | X52539Y60039D02*
69 | D03*
70 | Y30039D02*
71 | D03*
72 | Y-59961D02*
73 | D03*
74 | X37539Y60039D02*
75 | D03*
76 | X30039Y45039D02*
77 | D03*
78 | Y-44961D02*
79 | D03*
80 | X37539Y-59961D02*
81 | D03*
82 | X15039Y-44961D02*
83 | D03*
84 | X7539Y-29961D02*
85 | D03*
86 | X39Y-44961D02*
87 | D03*
88 | X7539Y-59961D02*
89 | D03*
90 | X-7461Y-29961D02*
91 | D03*
92 | X-29961Y45039D02*
93 | D03*
94 | Y-44961D02*
95 | D03*
96 | X-22461Y-59961D02*
97 | D03*
98 | X-37461Y60039D02*
99 | D03*
100 | Y30039D02*
101 | D03*
102 | Y39D02*
103 | D03*
104 | Y-59961D02*
105 | D03*
106 | X-52461Y60039D02*
107 | D03*
108 | X-59961Y45039D02*
109 | D03*
110 | X-52461Y30039D02*
111 | D03*
112 | Y39D02*
113 | D03*
114 | Y-29961D02*
115 | D03*
116 | X-59961Y-44961D02*
117 | D03*
118 | X-52461Y-59961D02*
119 | D03*
120 | X-67461Y30039D02*
121 | D03*
122 | Y-29961D02*
123 | D03*
124 | X13112Y6573D02*
125 | D03*
126 | X8936D02*
127 | D03*
128 | Y10749D02*
129 | D03*
130 | X13112D02*
131 | D03*
132 | M02*
133 |
--------------------------------------------------------------------------------
/Hardware/Gerber/I2CNavKey.TXT:
--------------------------------------------------------------------------------
1 | M48
2 | ;Layer_Color=9474304
3 | ;FILE_FORMAT=2:5
4 | INCH,LZ
5 | ;TYPE=PLATED
6 | T1F00S00C0.01200
7 | T2F00S00C0.01575
8 | T3F00S00C0.01800
9 | T4F00S00C0.06693
10 | T5F00S00C0.11811
11 | ;TYPE=NON_PLATED
12 | T6F00S00C0.06693
13 | T7F00S00C0.15748
14 | %
15 | T01
16 | X0007539Y-0059961
17 | X0015039Y-0044961
18 | X0030039
19 | X0020472Y-0034252
20 | X0007539Y-0029961
21 | X0011811Y-0022047
22 | X0024409Y-0018504
23 | X0024803Y-0003937
24 | X0011024Y-0002995
25 | X-0001575Y-0014173
26 | X0000039Y-0044961
27 | X0037539Y-0059961
28 | X0052539
29 | X0060039Y-0044961
30 | X005748Y-0029921
31 | X0067539Y-0029961
32 | X0060236Y-0020079
33 | X0060039Y-0014961
34 | X0062205Y-0010236
35 | X0049892Y-0007012
36 | X004768Y-0016788
37 | X0037402Y-0026772
38 | X-0007461Y-0029961
39 | X-0004331Y-0037008
40 | X-0005512Y-0041732
41 | X-0009449Y-0046063
42 | X-0014567Y-0050787
43 | X-0022047Y-005
44 | X-0022461Y-0059961
45 | X-0037461
46 | X-0052461
47 | X-0059961Y-0044961
48 | X-0052461Y-0029961
49 | X-0067461
50 | X-0029961Y-0044961
51 | X-0037461Y0000039
52 | X-0052461
53 | X-0051181Y0013248
54 | Y0024547
55 | X-0052461Y0030039
56 | X-0037461
57 | X-0029961Y0045039
58 | X-0037461Y0060039
59 | X-0052461
60 | X-0059961Y0045039
61 | X-0067461Y0030039
62 | X0002756Y002126
63 | X0006299Y0020866
64 | X0014567Y0022835
65 | X0017323Y0025591
66 | X0013112Y0010749
67 | Y0006573
68 | X0008936
69 | Y0010749
70 | X0030709Y0002756
71 | X0052362
72 | X0064961Y-0000787
73 | X0067539Y0030039
74 | X0052539
75 | X0047638Y0024409
76 | X0035433Y0023228
77 | X0044094Y0012992
78 | X00275Y00415
79 | X0030039Y0045039
80 | X0025984Y0048819
81 | X0011024Y0046063
82 | X0025591Y0066535
83 | X0037539Y0060039
84 | X0052539
85 | X0060039Y0045039
86 | T02
87 | X0063055Y-0073736
88 | X0067842Y-0074622
89 | X0072235Y-0072527
90 | X0074558Y-0068248
91 | X0073922Y-0063422
92 | X0070571Y-0059891
93 | X0065785Y-0059004
94 | X0061391Y-00611
95 | X0059068Y-0065378
96 | X0059704Y-0070205
97 | X-0059891Y-0070571
98 | X-0059004Y-0065785
99 | X-00611Y-0061391
100 | X-0065378Y-0059068
101 | X-0070205Y-0059704
102 | X-0073736Y-0063055
103 | X-0074622Y-0067842
104 | X-0072527Y-0072235
105 | X-0068248Y-0074558
106 | X-0063422Y-0073922
107 | X-0065785Y0059004
108 | X-0070571Y0059891
109 | X-0073922Y0063422
110 | X-0074558Y0068248
111 | X-0072235Y0072527
112 | X-0067842Y0074622
113 | X-0063055Y0073736
114 | X-0059704Y0070205
115 | X-0059068Y0065378
116 | X-0061391Y00611
117 | X00611Y0061391
118 | X0059004Y0065785
119 | X0059891Y0070571
120 | X0063422Y0073922
121 | X0068248Y0074558
122 | X0072527Y0072235
123 | X0074622Y0067842
124 | X0073736Y0063055
125 | X0070205Y0059704
126 | X0065378Y0059068
127 | T03
128 | X-0012806Y-00265
129 | X-0022047Y-0007087
130 | X-0009Y0031
131 | X00025Y005
132 | X00375Y0013
133 | T04
134 | X0030511Y-0059464
135 | X0025779Y-0025779
136 | X-0004371Y-0004371
137 | X-0012806Y-0063305
138 | X-0063584Y-0014198
139 | X-0025779Y0025779
140 | X-0030511Y0059464
141 | X0025779Y0025779
142 | X0063584Y0014198
143 | T05
144 | X0066929Y-0066929
145 | X-0066929
146 | Y0066929
147 | X0066929
148 | T06
149 | X0012528Y-0012528
150 | X-0012528Y0012528
151 | T07
152 | X0041758Y-0041758
153 | X-0041758
154 | Y0041758
155 | X0041758
156 | M30
157 |
--------------------------------------------------------------------------------
/Hardware/I2CNavKey Schematic.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/Hardware/I2CNavKey Schematic.pdf
--------------------------------------------------------------------------------
/Hardware/Pick Place/Pick Place for I2CNavKey.txt:
--------------------------------------------------------------------------------
1 | ========================================================================================================================
2 | File Design Information:
3 |
4 | Date: 30/04/19
5 | Time: 16:17
6 | Revision: 54
7 | Variant: No variations
8 | Units used: mm
9 |
10 | Designator Comment Layer Footprint Center-X(mm) Center-Y(mm) Rotation Description MouserCode PartNumber Value
11 | SJ5 SJ2W BottomLayer SJ_2 -14.1000 4.8000 90 "" "" "" ""
12 | Ho2 "Hole 2mm" BottomLayer Hole_2mm -4.5000 14.5000 180 "Hole 2mm" "" "" ""
13 | Ho1 "Hole 2mm" BottomLayer Hole_2mm 4.5000 14.5000 180 "Hole 2mm" "" "" ""
14 | D1 LED-RGB-CA BottomLayer LED-RGB-CA-5mm-SMD 0.0000 14.8000 180 "" "" "" ""
15 | * DuppaLogo BottomSolder DUPPA_TOP_400x89 -80.0000 -80.0000 135 "" "" "" ""
16 | R9 R-EU_R0402 BottomLayer R0402 0.6000 -4.1000 135 "" 603-RC0402FR-074K7L RC0402FR-074K7L 4k7
17 | R8 R-EU_R0402 BottomLayer R0402 2.2500 -5.7500 315 "" 603-RC0402FR-074K7L RC0402FR-074K7L 4k7
18 | SW1 TSWB-3N TopLayer TSWB-3N 0.0000 -0.4879 0 "7 Function Tact and Scroll Wheel" "" "TSWB-3N-CB222 LFS" ""
19 | U1 PIC16F18345-I/GZZ BottomLayer MCHP-QFN-ML20_L 2.8000 2.2000 135 "8-bit Microcontrollers - MCU 8-BIT MCU 14KB Flash 1KB RAM, 256 EEPROM" 579-PIC16F18345-I/GZ PIC16F18345-I/GZ ""
20 | R7 R-EU_R0402 BottomLayer R0402 5.1000 8.7674 180 Resistor 603-RC0402FR-0710KL RC0402FR-0710KL 10k
21 | R6 R-EU_R0402 BottomLayer R0402 8.8000 -4.0000 90 Resistor 603-RC0402FR-0710KL RC0402FR-0710KL 10k
22 | R5 R-EU_R0402 BottomLayer R0402 8.8000 -6.3000 270 Resistor 603-RC0402FR-0710KL RC0402FR-0710KL 10k
23 | R4 R-EU_R0402 BottomLayer R0402 7.0000 9.2500 90 Resistor 603-RC0402FR-0710KL RC0402FR-0710KL 10k
24 | R3 R-EU_R0402 BottomLayer R0402 0.0000 10.7000 90 Resistor 603-RC0402FR-0747RL RC0402FR-0747RL 47r
25 | R2 R-EU_R0402 BottomLayer R0402 -1.4000 10.7000 90 Resistor 603-RC0402FR-0747RL RC0402FR-0747RL 47r
26 | R1 R-EU_R0402 BottomLayer R0402 1.4000 10.7000 90 Resistor 603-RC0402FR-0747RL RC0402FR-0747RL 47r
27 | L1 600R@100MHz BottomLayer L0402 7.5000 4.5000 180 "Ferrite Bead" 963-BK1005HS601-T BK1005HS601-T 600R@100MHz
28 | CON1 "JST XH-5 SMD" BottomLayer S5B-XH-SM4-TB-V -4.3040 -4.3040 315 "XH 2.5 Horizontal Male Connector SMD Socket 2.54mm Plug XH Pitch" "" S5B-XH-SM4-TB ""
29 | C4 C-EUC0402 BottomLayer C0402 5.1000 10.3000 360 Capacitor 81-GCM155R71E473KA5D GCM155R71E473KA55D 47n
30 | C3 C-EUC0402 BottomLayer C0402 7.2000 -4.0000 270 Capacitor 81-GCM155R71E473KA5D GCM155R71E473KA55D 47n
31 | C2 C-EUC0402 BottomLayer C0402 5.1000 4.8000 135 Capacitor 603-CC402KRX5R8BB104 GRM155R61C104KA88D 100n
32 | C1 C-EUC0603 BottomLayer C0603 10.4000 4.5000 360 Capacitor 963-EMK107ABJ475MA-T CC0603KRX5R7BB475 4u7
33 |
--------------------------------------------------------------------------------
/I2CNavKey_back.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/I2CNavKey_back.jpg
--------------------------------------------------------------------------------
/I2CNavKey_buttons.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/I2CNavKey_buttons.jpg
--------------------------------------------------------------------------------
/I2CNavKey_v1.3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/I2CNavKey_v1.3.pdf
--------------------------------------------------------------------------------
/I2CNavKey_v1.4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/I2CNavKey_v1.4.pdf
--------------------------------------------------------------------------------
/OSHW_mark_IT000005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Fattoresaimon/I2CNavKey/f55388a7e9793f5e19e5df70c1cf0b99db5503a9/OSHW_mark_IT000005.png
--------------------------------------------------------------------------------
/Python Raspberry Library/Examples/I2CNavKey_basic.py:
--------------------------------------------------------------------------------
1 | import smbus2
2 | import RPi.GPIO as GPIO
3 | from time import sleep
4 | import i2cNavKeyLib
5 |
6 |
7 | def Up_Button():
8 | print ('Button Up Pushed!')
9 | navkey.writeGP1(100)
10 | navkey.writeGP1(0)
11 |
12 |
13 | def Down_Button():
14 | print ('Button Down Pushed!')
15 | navkey.writeGP1(100)
16 | navkey.writeGP1(0)
17 |
18 |
19 | def Left_Button():
20 | print ('Button Left Pushed!')
21 | navkey.writeGP1(100)
22 | navkey.writeGP1(0)
23 |
24 |
25 | def Right_Button():
26 | print ('Button Right Pushed!')
27 | navkey.writeGP1(100)
28 | navkey.writeGP1(0)
29 |
30 |
31 | def Push_Button():
32 | print ('Central Pushed!')
33 | navkey.writeGP1(100)
34 | navkey.writeGP1(0)
35 |
36 |
37 | def DoublePush_Button():
38 | print ('Central Double Pushed!')
39 | navkey.writeGP1(100)
40 | navkey.writeGP1(0)
41 |
42 |
43 | def EncoderChange():
44 | print ('Ring Changed: %d' % (navkey.readCounter32()))
45 | navkey.writeGP2(100)
46 | navkey.writeGP2(0)
47 |
48 |
49 | def EncoderMax():
50 | print ('Ring max!')
51 | navkey.writeGP3(100)
52 | navkey.writeGP3(0)
53 |
54 |
55 | def EncoderMin():
56 | print ('Ring min!')
57 | navkey.writeGP3(100)
58 | navkey.writeGP3(0)
59 |
60 |
61 | def NavKey_INT(self):
62 | navkey.updateStatus()
63 |
64 |
65 | GPIO.setmode(GPIO.BCM)
66 | bus = smbus2.SMBus(1)
67 | INT_pin = 4
68 | GPIO.setup(INT_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
69 |
70 | navkey = i2cNavKeyLib.i2cNavKeyLib(bus, 0x10) # Write here the I2C address of the NavKey #
71 |
72 | encconfig = (i2cNavKeyLib.INT_DATA | i2cNavKeyLib.WRAP_ENABLE | i2cNavKeyLib.DIRE_RIGHT | i2cNavKeyLib.IPUP_ENABLE)
73 | navkey.begin(encconfig)
74 |
75 | navkey.writeCounter(0)
76 | navkey.writeMax(35)
77 | navkey.writeMin(-20)
78 | navkey.writeStep(1)
79 | navkey.writeDoublePushPeriod(50)
80 |
81 | navkey.writeGP1conf(i2cNavKeyLib.GP_PWM)
82 | navkey.writeGP2conf(i2cNavKeyLib.GP_PWM)
83 | navkey.writeGP3conf(i2cNavKeyLib.GP_PWM)
84 |
85 | navkey.writeGammaGP1(i2cNavKeyLib.GAMMA_2)
86 | navkey.writeGammaGP2(i2cNavKeyLib.GAMMA_2)
87 | navkey.writeGammaGP3(i2cNavKeyLib.GAMMA_2)
88 |
89 | navkey.onUpPush = Up_Button
90 | navkey.onDownPush = Down_Button
91 | navkey.onLeftPush = Left_Button
92 | navkey.onRightPush = Right_Button
93 | navkey.onCentralPush = Push_Button
94 | navkey.onCentralDoublePush = DoublePush_Button
95 | navkey.onChange = EncoderChange
96 | navkey.onMax = EncoderMax
97 | navkey.onMin = EncoderMin
98 |
99 | navkey.autoconfigInterrupt()
100 | print ('Board ID code: 0x%X' % (navkey.readIDCode()))
101 | print ('Board Version: 0x%X' % (navkey.readVersion()))
102 |
103 | navkey.writeGP1(100)
104 | navkey.writeGP2(0)
105 | navkey.writeGP3(0)
106 | sleep(0.3)
107 | navkey.writeGP1(0)
108 | navkey.writeGP2(100)
109 | navkey.writeGP3(0)
110 | sleep(0.3)
111 | navkey.writeGP1(0)
112 | navkey.writeGP2(0)
113 | navkey.writeGP3(100)
114 | sleep(0.3)
115 | navkey.writeGP1(0)
116 | navkey.writeGP2(0)
117 | navkey.writeGP3(0)
118 |
119 |
120 | GPIO.add_event_detect(INT_pin, GPIO.FALLING, callback=NavKey_INT)
121 |
122 | while True:
123 | # if GPIO.input(INT_pin) == False: #
124 | # NavKey_INT() #
125 | pass
126 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # I2C NavKey
2 | --------------------------------------------------------------------------------
3 | 
4 |
5 | ## Introduction
6 |
7 | The I2CNavKey is a small board that includes a 7 functions joypad.
8 | The joypad has 4 directional keys plus a central button and a rotary ring. It is controllable with the I2C bus, and it's possible to configure 16 different I2C addresses.
9 |
10 | The I2CNavKey has also 3 configurable GPIOs with the same footprint of RGB LED. This 3 GPIOs can be configured independently in 4 different way: input, output, PWM and analog input.
11 |
12 | Since the I2CNavKey is a I2C slave, it has a series of 8 bit registers where it's possible to configure different parameters,it's also possible to detect when the buttons are pressed or when the ring is rotated.
13 | It also has an open-drain output pin used as interrupt output. This pin is used to notify to the master when some event happens in the I2CNavKey, the source of interrupt can be customized.
14 |
15 | 
16 |
17 | 
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | ## Where you can get this board?
26 |
27 | This project is avaiable on our [Tindie store!](https://www.tindie.com/products/16624/)
28 |
29 |
30 |
31 | ## Repository Structure
32 | * [Arduino Library:](https://github.com/Fattoresaimon/ArduinoDuPPaLib) Repository where you can find the Arduino IDE library for the DuPPa boards
33 | * [Raspberry Library:](/Python%20Raspberry%20Library) Ready to use library in Python for the Raspberry board with example.
34 | * [Firmware:](/Firmware) Project folder of Microchip MPLAB X contain the code running inside of the PIC16F18345
35 | * [Hardware:](/Hardware) Folder containing the production file, schematic, STEP file
36 | * [Datasheet I2C NavKey:](I2CNavKey_v1.4.pdf) Datasheet of the board with the description of the registers and some useful information.
37 |
38 |
39 |
40 | ## Licensing
41 |
42 | Hardware and firmware are licensed under GPL-3 license
43 |
44 | Documentation is licensed under a Creative Commons BY-SA 4.0 international license
45 |
46 | **If you want to donate for my work, i would really appreciate it. You can donate here with this link. Thank you!**
47 |
48 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5DX7BCX7JD5SL)
49 |
--------------------------------------------------------------------------------