/**
 * PINS Generated Driver Header File 
 * 
 * @file      pins.h
 *            
 * @defgroup  pinsdriver Pins Driver
 *            
 * @brief     The Pin Driver directs the operation and function of 
 *            the selected device pins using dsPIC MCUs.
 *
 * @skipline @version   PLIB Version 1.0.5
 *
 * @skipline  Device : dsPIC33AK512MPS506
*/

/*
? [2026] 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. 
    You are responsible for complying with 3rd party license terms  
    applicable to your use of 3rd party software (including open source  
    software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? 
    NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS 
    SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,  
    MERCHANTABILITY, OR 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 RELATED TO THE SOFTWARE WILL NOT 
    EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR 
    THIS SOFTWARE.
*/

#ifndef PINS_H
#define PINS_H
// Section: Includes
#include <xc.h>

/**
 * @ingroup  pinsdriver
 * @brief    Locks all the Peripheral Remapping registers and cannot be written.
 * @return   none  
 */
#define PINS_PPSLock()           (RPCONbits.IOLOCK = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Unlocks all the Peripheral Remapping registers and can be written.
 * @return   none  
 */
#define PINS_PPSUnlock()         (RPCONbits.IOLOCK = 0)

// Section: Device Pin Macros
/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA4 GPIO Pin which has a custom name of TFT_DC to High
 * @pre      The RA4 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define TFT_DC_SetHigh()          (_LATA4 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA4 GPIO Pin which has a custom name of TFT_DC to Low
 * @pre      The RA4 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define TFT_DC_SetLow()           (_LATA4 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RA4 GPIO Pin which has a custom name of TFT_DC
 * @pre      The RA4 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define TFT_DC_Toggle()           (_LATA4 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RA4 GPIO Pin which has a custom name of TFT_DC
 * @param    none
 * @return   none  
 */
#define TFT_DC_GetValue()         _RA4

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA4 GPIO Pin which has a custom name of TFT_DC as Input
 * @param    none
 * @return   none  
 */
#define TFT_DC_SetDigitalInput()  (_TRISA4 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA4 GPIO Pin which has a custom name of TFT_DC as Output
 * @param    none
 * @return   none  
 */
#define TFT_DC_SetDigitalOutput() (_TRISA4 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA5 GPIO Pin which has a custom name of TFT_RST to High
 * @pre      The RA5 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define TFT_RST_SetHigh()          (_LATA5 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA5 GPIO Pin which has a custom name of TFT_RST to Low
 * @pre      The RA5 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define TFT_RST_SetLow()           (_LATA5 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RA5 GPIO Pin which has a custom name of TFT_RST
 * @pre      The RA5 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define TFT_RST_Toggle()           (_LATA5 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RA5 GPIO Pin which has a custom name of TFT_RST
 * @param    none
 * @return   none  
 */
#define TFT_RST_GetValue()         _RA5

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA5 GPIO Pin which has a custom name of TFT_RST as Input
 * @param    none
 * @return   none  
 */
#define TFT_RST_SetDigitalInput()  (_TRISA5 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA5 GPIO Pin which has a custom name of TFT_RST as Output
 * @param    none
 * @return   none  
 */
#define TFT_RST_SetDigitalOutput() (_TRISA5 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA6 GPIO Pin which has a custom name of TFT_CS to High
 * @pre      The RA6 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define TFT_CS_SetHigh()          (_LATA6 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA6 GPIO Pin which has a custom name of TFT_CS to Low
 * @pre      The RA6 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define TFT_CS_SetLow()           (_LATA6 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RA6 GPIO Pin which has a custom name of TFT_CS
 * @pre      The RA6 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define TFT_CS_Toggle()           (_LATA6 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RA6 GPIO Pin which has a custom name of TFT_CS
 * @param    none
 * @return   none  
 */
#define TFT_CS_GetValue()         _RA6

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA6 GPIO Pin which has a custom name of TFT_CS as Input
 * @param    none
 * @return   none  
 */
#define TFT_CS_SetDigitalInput()  (_TRISA6 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA6 GPIO Pin which has a custom name of TFT_CS as Output
 * @param    none
 * @return   none  
 */
#define TFT_CS_SetDigitalOutput() (_TRISA6 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA7 GPIO Pin which has a custom name of WS2812 to High
 * @pre      The RA7 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define WS2812_SetHigh()          (_LATA7 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA7 GPIO Pin which has a custom name of WS2812 to Low
 * @pre      The RA7 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define WS2812_SetLow()           (_LATA7 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RA7 GPIO Pin which has a custom name of WS2812
 * @pre      The RA7 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define WS2812_Toggle()           (_LATA7 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RA7 GPIO Pin which has a custom name of WS2812
 * @param    none
 * @return   none  
 */
#define WS2812_GetValue()         _RA7

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA7 GPIO Pin which has a custom name of WS2812 as Input
 * @param    none
 * @return   none  
 */
#define WS2812_SetDigitalInput()  (_TRISA7 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA7 GPIO Pin which has a custom name of WS2812 as Output
 * @param    none
 * @return   none  
 */
#define WS2812_SetDigitalOutput() (_TRISA7 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA8 GPIO Pin which has a custom name of IO_RA8 to High
 * @pre      The RA8 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define IO_RA8_SetHigh()          (_LATA8 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA8 GPIO Pin which has a custom name of IO_RA8 to Low
 * @pre      The RA8 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define IO_RA8_SetLow()           (_LATA8 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RA8 GPIO Pin which has a custom name of IO_RA8
 * @pre      The RA8 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define IO_RA8_Toggle()           (_LATA8 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RA8 GPIO Pin which has a custom name of IO_RA8
 * @param    none
 * @return   none  
 */
#define IO_RA8_GetValue()         _RA8

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA8 GPIO Pin which has a custom name of IO_RA8 as Input
 * @param    none
 * @return   none  
 */
#define IO_RA8_SetDigitalInput()  (_TRISA8 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA8 GPIO Pin which has a custom name of IO_RA8 as Output
 * @param    none
 * @return   none  
 */
#define IO_RA8_SetDigitalOutput() (_TRISA8 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA9 GPIO Pin which has a custom name of IO_RA9 to High
 * @pre      The RA9 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define IO_RA9_SetHigh()          (_LATA9 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RA9 GPIO Pin which has a custom name of IO_RA9 to Low
 * @pre      The RA9 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define IO_RA9_SetLow()           (_LATA9 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RA9 GPIO Pin which has a custom name of IO_RA9
 * @pre      The RA9 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define IO_RA9_Toggle()           (_LATA9 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RA9 GPIO Pin which has a custom name of IO_RA9
 * @param    none
 * @return   none  
 */
#define IO_RA9_GetValue()         _RA9

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA9 GPIO Pin which has a custom name of IO_RA9 as Input
 * @param    none
 * @return   none  
 */
#define IO_RA9_SetDigitalInput()  (_TRISA9 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RA9 GPIO Pin which has a custom name of IO_RA9 as Output
 * @param    none
 * @return   none  
 */
#define IO_RA9_SetDigitalOutput() (_TRISA9 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RC8 GPIO Pin which has a custom name of SW1 to High
 * @pre      The RC8 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define SW1_SetHigh()          (_LATC8 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RC8 GPIO Pin which has a custom name of SW1 to Low
 * @pre      The RC8 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define SW1_SetLow()           (_LATC8 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RC8 GPIO Pin which has a custom name of SW1
 * @pre      The RC8 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define SW1_Toggle()           (_LATC8 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RC8 GPIO Pin which has a custom name of SW1
 * @param    none
 * @return   none  
 */
#define SW1_GetValue()         _RC8

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RC8 GPIO Pin which has a custom name of SW1 as Input
 * @param    none
 * @return   none  
 */
#define SW1_SetDigitalInput()  (_TRISC8 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RC8 GPIO Pin which has a custom name of SW1 as Output
 * @param    none
 * @return   none  
 */
#define SW1_SetDigitalOutput() (_TRISC8 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RC9 GPIO Pin which has a custom name of SW2 to High
 * @pre      The RC9 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define SW2_SetHigh()          (_LATC9 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RC9 GPIO Pin which has a custom name of SW2 to Low
 * @pre      The RC9 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define SW2_SetLow()           (_LATC9 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RC9 GPIO Pin which has a custom name of SW2
 * @pre      The RC9 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define SW2_Toggle()           (_LATC9 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RC9 GPIO Pin which has a custom name of SW2
 * @param    none
 * @return   none  
 */
#define SW2_GetValue()         _RC9

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RC9 GPIO Pin which has a custom name of SW2 as Input
 * @param    none
 * @return   none  
 */
#define SW2_SetDigitalInput()  (_TRISC9 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RC9 GPIO Pin which has a custom name of SW2 as Output
 * @param    none
 * @return   none  
 */
#define SW2_SetDigitalOutput() (_TRISC9 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD0 GPIO Pin which has a custom name of LED_R to High
 * @pre      The RD0 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define LED_R_SetHigh()          (_LATD0 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD0 GPIO Pin which has a custom name of LED_R to Low
 * @pre      The RD0 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED_R_SetLow()           (_LATD0 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RD0 GPIO Pin which has a custom name of LED_R
 * @pre      The RD0 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED_R_Toggle()           (_LATD0 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RD0 GPIO Pin which has a custom name of LED_R
 * @param    none
 * @return   none  
 */
#define LED_R_GetValue()         _RD0

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD0 GPIO Pin which has a custom name of LED_R as Input
 * @param    none
 * @return   none  
 */
#define LED_R_SetDigitalInput()  (_TRISD0 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD0 GPIO Pin which has a custom name of LED_R as Output
 * @param    none
 * @return   none  
 */
#define LED_R_SetDigitalOutput() (_TRISD0 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD1 GPIO Pin which has a custom name of LED_G to High
 * @pre      The RD1 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define LED_G_SetHigh()          (_LATD1 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD1 GPIO Pin which has a custom name of LED_G to Low
 * @pre      The RD1 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED_G_SetLow()           (_LATD1 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RD1 GPIO Pin which has a custom name of LED_G
 * @pre      The RD1 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED_G_Toggle()           (_LATD1 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RD1 GPIO Pin which has a custom name of LED_G
 * @param    none
 * @return   none  
 */
#define LED_G_GetValue()         _RD1

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD1 GPIO Pin which has a custom name of LED_G as Input
 * @param    none
 * @return   none  
 */
#define LED_G_SetDigitalInput()  (_TRISD1 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD1 GPIO Pin which has a custom name of LED_G as Output
 * @param    none
 * @return   none  
 */
#define LED_G_SetDigitalOutput() (_TRISD1 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD2 GPIO Pin which has a custom name of LED_B to High
 * @pre      The RD2 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define LED_B_SetHigh()          (_LATD2 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD2 GPIO Pin which has a custom name of LED_B to Low
 * @pre      The RD2 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED_B_SetLow()           (_LATD2 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RD2 GPIO Pin which has a custom name of LED_B
 * @pre      The RD2 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED_B_Toggle()           (_LATD2 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RD2 GPIO Pin which has a custom name of LED_B
 * @param    none
 * @return   none  
 */
#define LED_B_GetValue()         _RD2

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD2 GPIO Pin which has a custom name of LED_B as Input
 * @param    none
 * @return   none  
 */
#define LED_B_SetDigitalInput()  (_TRISD2 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD2 GPIO Pin which has a custom name of LED_B as Output
 * @param    none
 * @return   none  
 */
#define LED_B_SetDigitalOutput() (_TRISD2 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD7 GPIO Pin which has a custom name of LED1 to High
 * @pre      The RD7 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define LED1_SetHigh()          (_LATD7 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD7 GPIO Pin which has a custom name of LED1 to Low
 * @pre      The RD7 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED1_SetLow()           (_LATD7 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RD7 GPIO Pin which has a custom name of LED1
 * @pre      The RD7 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED1_Toggle()           (_LATD7 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RD7 GPIO Pin which has a custom name of LED1
 * @param    none
 * @return   none  
 */
#define LED1_GetValue()         _RD7

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD7 GPIO Pin which has a custom name of LED1 as Input
 * @param    none
 * @return   none  
 */
#define LED1_SetDigitalInput()  (_TRISD7 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD7 GPIO Pin which has a custom name of LED1 as Output
 * @param    none
 * @return   none  
 */
#define LED1_SetDigitalOutput() (_TRISD7 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD8 GPIO Pin which has a custom name of LED2 to High
 * @pre      The RD8 must be set as Output Pin             
 * @param    none
 * @return   none  
 */
#define LED2_SetHigh()          (_LATD8 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Sets the RD8 GPIO Pin which has a custom name of LED2 to Low
 * @pre      The RD8 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED2_SetLow()           (_LATD8 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Toggles the RD8 GPIO Pin which has a custom name of LED2
 * @pre      The RD8 must be set as Output Pin
 * @param    none
 * @return   none  
 */
#define LED2_Toggle()           (_LATD8 ^= 1)

/**
 * @ingroup  pinsdriver
 * @brief    Reads the value of the RD8 GPIO Pin which has a custom name of LED2
 * @param    none
 * @return   none  
 */
#define LED2_GetValue()         _RD8

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD8 GPIO Pin which has a custom name of LED2 as Input
 * @param    none
 * @return   none  
 */
#define LED2_SetDigitalInput()  (_TRISD8 = 1)

/**
 * @ingroup  pinsdriver
 * @brief    Configures the RD8 GPIO Pin which has a custom name of LED2 as Output
 * @param    none
 * @return   none  
 */
#define LED2_SetDigitalOutput() (_TRISD8 = 0)

/**
 * @ingroup  pinsdriver
 * @brief    Initializes the PINS module
 * @param    none
 * @return   none  
 */
void PINS_Initialize(void);



#endif
