199 lines
4.9 KiB
C
199 lines
4.9 KiB
C
/**
|
|
Generated Pin Manager File
|
|
|
|
Company:
|
|
Microchip Technology Inc.
|
|
|
|
File Name:
|
|
pin_manager.c
|
|
|
|
Summary:
|
|
This is the Pin Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
|
|
|
Description:
|
|
This header file provides implementations for pin APIs for all pins selected in the GUI.
|
|
Generation Information :
|
|
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.6
|
|
Device : PIC16F1829
|
|
Driver Version : 2.11
|
|
The generated drivers are tested against the following:
|
|
Compiler : XC8 2.30 and above
|
|
MPLAB : MPLAB X 5.40
|
|
|
|
Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved.
|
|
*/
|
|
|
|
/*
|
|
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
|
|
|
Subject to your compliance with these terms, you may use Microchip software and any
|
|
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
|
license terms applicable to your use of third party software (including open source software) that
|
|
may accompany Microchip software.
|
|
|
|
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
|
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
|
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
|
FOR A PARTICULAR PURPOSE.
|
|
|
|
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
|
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
|
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
|
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
|
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
|
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
|
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
|
SOFTWARE.
|
|
*/
|
|
|
|
#include "pin_manager.h"
|
|
|
|
|
|
|
|
|
|
void (*IOCAF4_InterruptHandler)(void);
|
|
void (*IOCAF5_InterruptHandler)(void);
|
|
|
|
|
|
void PIN_MANAGER_Initialize(void)
|
|
{
|
|
/**
|
|
LATx registers
|
|
*/
|
|
LATA = 0x00;
|
|
LATB = 0x00;
|
|
LATC = 0x00;
|
|
|
|
/**
|
|
TRISx registers
|
|
*/
|
|
TRISA = 0x3F;
|
|
TRISB = 0x90;
|
|
TRISC = 0x33;
|
|
|
|
/**
|
|
ANSELx registers
|
|
*/
|
|
ANSELC = 0x03;
|
|
ANSELB = 0x10;
|
|
ANSELA = 0x07;
|
|
|
|
/**
|
|
WPUx registers
|
|
*/
|
|
WPUB = 0x00;
|
|
WPUA = 0x30;
|
|
WPUC = 0x00;
|
|
OPTION_REGbits.nWPUEN = 0;
|
|
|
|
|
|
/**
|
|
APFCONx registers
|
|
*/
|
|
APFCON0 = 0x84;
|
|
APFCON1 = 0x00;
|
|
|
|
/**
|
|
IOCx registers
|
|
*/
|
|
//interrupt on change for group IOCAF - flag
|
|
IOCAFbits.IOCAF4 = 0;
|
|
//interrupt on change for group IOCAF - flag
|
|
IOCAFbits.IOCAF5 = 0;
|
|
//interrupt on change for group IOCAN - negative
|
|
IOCANbits.IOCAN4 = 1;
|
|
//interrupt on change for group IOCAN - negative
|
|
IOCANbits.IOCAN5 = 1;
|
|
//interrupt on change for group IOCAP - positive
|
|
IOCAPbits.IOCAP4 = 1;
|
|
//interrupt on change for group IOCAP - positive
|
|
IOCAPbits.IOCAP5 = 1;
|
|
|
|
|
|
|
|
// register default IOC callback functions at runtime; use these methods to register a custom function
|
|
IOCAF4_SetInterruptHandler(IOCAF4_DefaultInterruptHandler);
|
|
IOCAF5_SetInterruptHandler(IOCAF5_DefaultInterruptHandler);
|
|
|
|
// Enable IOCI interrupt
|
|
INTCONbits.IOCIE = 1;
|
|
|
|
}
|
|
|
|
void PIN_MANAGER_IOC(void)
|
|
{
|
|
// interrupt on change for pin IOCAF4
|
|
if(IOCAFbits.IOCAF4 == 1)
|
|
{
|
|
IOCAF4_ISR();
|
|
}
|
|
// interrupt on change for pin IOCAF5
|
|
if(IOCAFbits.IOCAF5 == 1)
|
|
{
|
|
IOCAF5_ISR();
|
|
}
|
|
}
|
|
|
|
/**
|
|
IOCAF4 Interrupt Service Routine
|
|
*/
|
|
void IOCAF4_ISR(void) {
|
|
|
|
// Add custom IOCAF4 code
|
|
|
|
// Call the interrupt handler for the callback registered at runtime
|
|
if(IOCAF4_InterruptHandler)
|
|
{
|
|
IOCAF4_InterruptHandler();
|
|
}
|
|
IOCAFbits.IOCAF4 = 0;
|
|
}
|
|
|
|
/**
|
|
Allows selecting an interrupt handler for IOCAF4 at application runtime
|
|
*/
|
|
void IOCAF4_SetInterruptHandler(void (* InterruptHandler)(void)){
|
|
IOCAF4_InterruptHandler = InterruptHandler;
|
|
}
|
|
|
|
/**
|
|
Default interrupt handler for IOCAF4
|
|
*/
|
|
void IOCAF4_DefaultInterruptHandler(void){
|
|
// add your IOCAF4 interrupt custom code
|
|
// or set custom function using IOCAF4_SetInterruptHandler()
|
|
}
|
|
|
|
/**
|
|
IOCAF5 Interrupt Service Routine
|
|
*/
|
|
void IOCAF5_ISR(void) {
|
|
|
|
// Add custom IOCAF5 code
|
|
|
|
// Call the interrupt handler for the callback registered at runtime
|
|
if(IOCAF5_InterruptHandler)
|
|
{
|
|
IOCAF5_InterruptHandler();
|
|
}
|
|
IOCAFbits.IOCAF5 = 0;
|
|
}
|
|
|
|
/**
|
|
Allows selecting an interrupt handler for IOCAF5 at application runtime
|
|
*/
|
|
void IOCAF5_SetInterruptHandler(void (* InterruptHandler)(void)){
|
|
IOCAF5_InterruptHandler = InterruptHandler;
|
|
}
|
|
|
|
/**
|
|
Default interrupt handler for IOCAF5
|
|
*/
|
|
void IOCAF5_DefaultInterruptHandler(void){
|
|
// add your IOCAF5 interrupt custom code
|
|
// or set custom function using IOCAF5_SetInterruptHandler()
|
|
}
|
|
|
|
/**
|
|
End of File
|
|
*/ |