commit ea24f650d11a0b721a922ab9eabe64c162fe7673 Author: lefake Date: Thu Jan 30 20:02:06 2025 -0500 Inital working code diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ab7fc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +.ca/** +dist/** +build/** + +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fca8e2c --- /dev/null +++ b/Makefile @@ -0,0 +1,113 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin +RANLIB=ranlib + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... +# WARNING: the IDE does not call this target since it takes a long time to +# simply run make. Instead, the IDE removes the configuration directories +# under build and dist directly without calling make. +# This target is left here so people can do a clean when running a clean +# outside the IDE. + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/commons.h b/commons.h new file mode 100644 index 0000000..bb6bec8 --- /dev/null +++ b/commons.h @@ -0,0 +1,53 @@ +#ifndef COMMONS_H +#define COMMONS_H + +// Pins +#define LED_PIN 19 +#define RS485_RX_TX_SELECT 22 + +// Config +#define MASTER_ID 0xF0 +#define MY_ID 0x00 +// #define DEBUG +#ifndef MASTER_ID +#define IS_MASTER +#endif + +#define DELAY_TO_REPLY 5 + +// Proto +#define START_DEL '[' +#define END_DEL ']' + +// General indexes +#define ID_INDEX 1 +#define CMD_INDEX (ID_INDEX + 1) +#define PAYLOAD_INDEX (CMD_INDEX + CMD_NAME_LEN) + +// GET +#define GET_CMD_ID 0 +// SET +#define SET_CMD_ID 1 +#define LED1_INDEX 3 +#define LED2_INDEX 5 +// DATA +#define DATA_CMD_ID 2 +#define SENSOR_INDEX 3 +// ERROR +#define ERROR_CMD_ID 3 +#define ERR_INDEX 3 + +#define RET_SUCCESS(ret) (ret <= 1) +#define RET_FAILURE(ret) (ret > 1) + +typedef enum errors +{ + SUCCESS = 0, + NO_RX, + UNSUPPORTED_CMD, + TX_DONE_ERR, + TX_READY_ERR, +} errors_t; + +#endif /* COMMONS_H */ + diff --git a/defmplabxtrace.log b/defmplabxtrace.log new file mode 100644 index 0000000..e69de29 diff --git a/defmplabxtrace.log.inx b/defmplabxtrace.log.inx new file mode 100644 index 0000000..29197e3 Binary files /dev/null and b/defmplabxtrace.log.inx differ diff --git a/main.c b/main.c new file mode 100644 index 0000000..d2aef2a --- /dev/null +++ b/main.c @@ -0,0 +1,224 @@ + /* + * MAIN Generated Driver File + * + * @file main.c + * + * @defgroup main MAIN + * + * @brief This is the generated driver implementation file for the MAIN driver. + * + * @version MAIN Driver Version 1.0.2 + * + * @version Package Version: 3.1.2 +*/ + +/* +© [2025] 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. +*/ +#include "mcc_generated_files/system/system.h" +#include +#include "commons.h" +#include "proto.h" + +static uint16_t led1, led2, sensor; +static errors_t peer_err = SUCCESS, retcode = SUCCESS; +static uint8_t in_rx, cmd, peer_id = 0; +static bool rx_over = false, update_sensor = false; +volatile bool tx_timed_out = false; + +//============================================================================== +// Private Declarations +//============================================================================== +static void init(); +static void show_error(); + +static void tmr_tx_cb(); +static void tmr_sensor_cb(); + +//============================================================================== +// Public +//============================================================================== +/*=****************************************************************************/ +int main(void) +{ + init(); + +// uint16_t i = 0; +// int change = 1; +// +// while(1) +// { +//// PWM3_LoadDutyValue(i); +//// PWM4_LoadDutyValue(i); +//// __delay_ms(1); +//// +//// if (i == 1024) +//// change = -1; +//// else if (i == 0) +//// change = 1; +//// +//// i += change; +// +// // Update sensor if it's time +// if (update_sensor) +// { +// update_sensor = false; +// ADC_StartConversion(); +// while(!ADC_IsConversionDone()); +// sensor = ADC_GetConversionResult(); +// } +// +// retcode = uart_rx_byte(&in_rx); +// if (retcode == SUCCESS) +// { +// rx_over = byte_in(in_rx, &cmd, &peer_id, &led1, &led2, &sensor, &peer_err); +// if (rx_over) +// { +// switch (cmd) +// { +// case GET_CMD_ID: +// // Wait for Master to stop writing +// __delay_ms(DELAY_TO_REPLY); +// retcode = send_data(MY_ID, sensor); +// break; +// case SET_CMD_ID: +// PWM3_LoadDutyValue(led1); +// PWM4_LoadDutyValue(led2); +// __delay_ms(DELAY_TO_REPLY); +// retcode = send_error(MY_ID, SUCCESS); +// break; +// default: +// DEBUG_Toggle(); +// retcode = UNSUPPORTED_CMD; +// break; +// } +// } +// } +// } +// + while(1) + { + if (RET_FAILURE(retcode)) + show_error(); + + // Update sensor if it's time + if (update_sensor) + { + update_sensor = false; + ADC_StartConversion(); + while(!ADC_IsConversionDone()); + sensor = ADC_GetConversionResult(); + } + + retcode = uart_rx_byte(&in_rx); + if (retcode == SUCCESS) + { + rx_over = byte_in(in_rx, &cmd, &peer_id, &led1, &led2, &sensor, &peer_err); + if (rx_over) + { + switch (cmd) + { +#ifndef IS_MASTER + case GET_CMD_ID: + // Wait for Master to stop writing + __delay_ms(DELAY_TO_REPLY); + retcode = send_data(MY_ID, sensor); + break; + + case SET_CMD_ID: + PWM3_LoadDutyValue(led1); + PWM4_LoadDutyValue(led2); + __delay_ms(DELAY_TO_REPLY); + retcode = send_error(MY_ID, SUCCESS); + break; +#else + case DATA_CMD_ID: + Serial.print("Sensor: "); + Serial.println(sensor); + break; + + case ERROR_CMD_ID: + Serial.print("Peer error: "); + Serial.println(peer_err); + break; +#endif + default: + retcode = UNSUPPORTED_CMD; + break; + } + } + } + } + + return 0; +} + +//============================================================================== +// Private +//============================================================================== +/*=****************************************************************************/ +static void init() +{ + SYSTEM_Initialize(); + INTERRUPT_GlobalInterruptEnable(); + INTERRUPT_PeripheralInterruptEnable(); + + ADC_Initialize(); + ADC_SelectChannel(channel_ANC0); + + // TMR callback + TMR_TX_OverflowCallbackRegister(tmr_tx_cb); + TMR_SENSOR_OverflowCallbackRegister(tmr_sensor_cb); + + // Initial variables and pins + RS_MODE_SetLow(); + TMR_TX_Stop(); + tx_timed_out = false; + + DEBUG_SetHigh(); + __delay_ms(1000); + DEBUG_SetLow(); +} + +/*=****************************************************************************/ +static void show_error() +{ + uint16_t time = retcode * 100; + + while(1) + { + DEBUG_Toggle(); + + for (uint16_t i = 0; i < time; ++i) + __delay_ms(1); + } +} + +/*=****************************************************************************/ +static void tmr_tx_cb() +{ + tx_timed_out = true; +} + +/*=****************************************************************************/ +static void tmr_sensor_cb() +{ + update_sensor = true; +} \ No newline at end of file diff --git a/mcc-manifest-autosave.yml b/mcc-manifest-autosave.yml new file mode 100644 index 0000000..8e18b02 --- /dev/null +++ b/mcc-manifest-autosave.yml @@ -0,0 +1,34 @@ +# This file has been autogenerated by MPLAB Code Configurator. Please do not edit this file. + +manifest_file_version: 1.0.0 +project: test_pcb +creation_date: 2025-01-27T15:17:19.196-05:00[America/Toronto] +operating_system: Linux +mcc_mode: IDE +mcc_mode_version: v6.20 +device_name: PIC16F15323 +compiler: XC8 2.45 +mcc_version: 5.5.1 +mcc_core_version: 5.7.1 +content_manager_version: 5.0.1 +is_mcc_offline: false +is_using_prerelease_versions: false +mcc_content_registries: https://registry.npmjs.org/ +device_library: {library_class: com.microchip.mcc.melody.Library, name: Melody, version: 2.8.0} +packs: {name: PIC16F1xxxx_DFP, version: 1.26.410} +modules: +- {name: '@mchp-mcc/main-manager', type: MELODY, version: 3.1.2} +- {name: '@mchp-mcc/pic-8bit', type: MELODY, version: 5.28.4} +- {name: '@mchp-mcc/pic16-configuration-bits-v3', type: MELODY, version: 1.0.5} +- {name: '@mchp-mcc/pic16-pin-manager', type: MELODY, version: 3.6.1} +- {name: '@mchp-mcc/pin-content-processor', type: MELODY, version: 3.9.0} +- {name: '@mchp-mcc/scf-pic8-adc-v1', type: MELODY, version: 3.0.10} +- {name: '@mchp-mcc/scf-pic8-eusart-v1', type: MELODY, version: 7.1.6} +- {name: '@mchp-mcc/scf-pic8-interrupt-v2', type: MELODY, version: 5.2.12} +- {name: '@mchp-mcc/scf-pic8-osc-v1', type: MELODY, version: 4.3.7} +- {name: '@mchp-mcc/scf-pic8-pwm-v2', type: MELODY, version: 4.2.12} +- {name: '@mchp-mcc/scf-pic8-tmr0-v1', type: MELODY, version: 5.0.0} +- {name: '@mchp-mcc/scf-pic8-tmr1-v1', type: MELODY, version: 5.0.0} +- {name: '@mchp-mcc/scf-pic8-tmr2-v1', type: MELODY, version: 5.0.0} +- {name: '@mchp-mcc/timer', type: MELODY, version: 1.2.2} +- {name: '@mchp-mcc/uart-driver', type: MELODY, version: 1.10.2} diff --git a/mcc-manifest-generated-success.yml b/mcc-manifest-generated-success.yml new file mode 100644 index 0000000..9435c52 --- /dev/null +++ b/mcc-manifest-generated-success.yml @@ -0,0 +1,34 @@ +# This file has been autogenerated by MPLAB Code Configurator. Please do not edit this file. + +manifest_file_version: 1.0.0 +project: test_pcb +creation_date: 2025-01-25T13:42:55.333-05:00[America/Toronto] +operating_system: Linux +mcc_mode: IDE +mcc_mode_version: v6.20 +device_name: PIC16F15323 +compiler: XC8 2.45 +mcc_version: 5.5.1 +mcc_core_version: 5.7.1 +content_manager_version: 5.0.1 +is_mcc_offline: false +is_using_prerelease_versions: false +mcc_content_registries: https://registry.npmjs.org/ +device_library: {library_class: com.microchip.mcc.melody.Library, name: Melody, version: 2.8.0} +packs: {name: PIC16F1xxxx_DFP, version: 1.26.410} +modules: +- {name: '@mchp-mcc/main-manager', type: MELODY, version: 3.1.2} +- {name: '@mchp-mcc/pic-8bit', type: MELODY, version: 5.28.4} +- {name: '@mchp-mcc/pic16-configuration-bits-v3', type: MELODY, version: 1.0.5} +- {name: '@mchp-mcc/pic16-pin-manager', type: MELODY, version: 3.6.1} +- {name: '@mchp-mcc/pin-content-processor', type: MELODY, version: 3.9.0} +- {name: '@mchp-mcc/scf-pic8-adc-v1', type: MELODY, version: 3.0.10} +- {name: '@mchp-mcc/scf-pic8-eusart-v1', type: MELODY, version: 7.1.6} +- {name: '@mchp-mcc/scf-pic8-interrupt-v2', type: MELODY, version: 5.2.12} +- {name: '@mchp-mcc/scf-pic8-osc-v1', type: MELODY, version: 4.3.7} +- {name: '@mchp-mcc/scf-pic8-pwm-v2', type: MELODY, version: 4.2.12} +- {name: '@mchp-mcc/scf-pic8-tmr0-v1', type: MELODY, version: 5.0.0} +- {name: '@mchp-mcc/scf-pic8-tmr1-v1', type: MELODY, version: 5.0.0} +- {name: '@mchp-mcc/scf-pic8-tmr2-v1', type: MELODY, version: 5.0.0} +- {name: '@mchp-mcc/timer', type: MELODY, version: 1.2.2} +- {name: '@mchp-mcc/uart-driver', type: MELODY, version: 1.10.2} diff --git a/mcc_generated_files/adc/adc.h b/mcc_generated_files/adc/adc.h new file mode 100644 index 0000000..d72bdd4 --- /dev/null +++ b/mcc_generated_files/adc/adc.h @@ -0,0 +1,139 @@ +/** + * ADC Generated Driver API Header File + * + * @file adc.h + * + * @defgroup adc ADC + * + * @brief This file contains the API prototypes and data types for the ADC driver. + * + * @version ADC Driver Version 2.1.3 + */ +/* +© [2025] 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 ADC_H +#define ADC_H + +#include +#include +#include + +/** + @ingroup adc + @typedef adc_result_t + @brief Used for the result of the Analog-to-Digital (A/D) conversion. + */ + +typedef uint16_t adc_result_t; + +/** + * @ingroup adc + * @typedef adc_sync_double_result_t + * @struct Used for the result for a Double ADC conversion value. + */ +typedef struct +{ + adc_result_t adcResult1; + adc_result_t adcResult2; +} adc_sync_double_result_t; + + +/** + * @ingroup adc + * @enum adc_channel_t + * @brief Contains the available ADC channels. + */ +typedef enum +{ + channel_AVSS = 0x3b, + channel_Temp = 0x3c, + channel_DAC1 = 0x3d, + channel_FVR_BUF1 = 0x3e, + channel_FVR_BUF2 = 0x3f, + channel_ANC0 = 0x10 +} adc_channel_t; + +/** + Section: ADC Module APIs + */ + +/** + * @ingroup adc + * @brief Initializes the ADC module. This routine is called before any other ADC routine. + * @param None. + * @return None. + */ +void ADC_Initialize(void); + +/** + * @ingroup adc + * @brief Selects the channel for the A/D conversion. + * @param channel - Analog channel number on which the A/D conversion will be applied. + * Refer to adc_channel_t for the available channels. + * @return None. + */ +void ADC_SelectChannel(adc_channel_t channel); + +/** + * @ingroup adc + * @brief Starts A/D conversion. + * @param None. + * @return None. + */ +void ADC_StartConversion(void); + +/** + * @ingroup adc + * @brief Checks if ongoing A/D conversion is complete. + * @param None. + * @retval True - A/D conversion is complete. + * @retval False - A/D conversion is ongoing. + */ +bool ADC_IsConversionDone(void); + +/** + * @ingroup adc + * @brief Retrieves the result of the latest A/D conversion. + * @param None. + * @return The result of A/D conversion. Refer to the adc_result_t. + */ +adc_result_t ADC_GetConversionResult(void); + +/** + * @ingroup adc + * @brief Retrieves the result of a single A/D conversion on any given channel. + * @param channel - Analog channel number on which the A/D conversion will be applied. + * Refer to adc_channel_t for the available channels. +* @return The result of A/D conversion. Refer to the adc_result_t. + */ +adc_result_t ADC_GetConversion(adc_channel_t channel); + +/** + * @ingroup adc + * @brief Adds the acquisition delay for the temperature sensor. + * @pre This function is called when temperature sensor is used. + * @param None. + * @return None. + */ +void ADC_TemperatureAcquisitionDelay(void); + +#endif //ADC_H diff --git a/mcc_generated_files/adc/src/adc.c b/mcc_generated_files/adc/src/adc.c new file mode 100644 index 0000000..c9df6a5 --- /dev/null +++ b/mcc_generated_files/adc/src/adc.c @@ -0,0 +1,125 @@ +/** + * ADC Generated Driver File + * + * @file adc.c + * + * @ingroup adc + * + * @brief This file contains the API implementations for the ADC module. + * + * @version ADC Driver Version 2.1.3 +*/ + +/* +© [2025] 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. +*/ + +/** + Section: Included Files +*/ + +#include +#include "../adc.h" +#include "../../system/clock.h" + +/** + Section: Macro Declarations +*/ + +#define ACQ_US_DELAY 5 + + +/** + Section: ADC Module APIs +*/ + +void ADC_Initialize(void) +{ + //ADPREF VDD; ADCS FOSC/64; ADFM right; + ADCON1 = 0xE0; + + //ADRESL 0x0; + ADRESL = 0x0; + + //ADRESH 0x0; + ADRESH = 0x0; + + //ADACT disabled; + ADACT = 0x0; + + //ADON enabled; GO_nDONE stop; CHS ANC0; + ADCON0 = 0x41; + + //Clear the ADC interrupt flag + PIR1bits.ADIF = 0; +} + +void ADC_SelectChannel(adc_channel_t channel) +{ + //Selects the A/D channel + ADCON0bits.CHS = channel; +} + +void ADC_StartConversion(void) +{ + //Starts the conversion + ADCON0bits.GOnDONE = 1; +} + +bool ADC_IsConversionDone(void) +{ + //Returns the conversion status + return ((bool)(!ADCON0bits.GOnDONE)); +} + +adc_result_t ADC_GetConversionResult(void) +{ + //Conversion finished, returns the result + return ((adc_result_t)((ADRESH << 8) + ADRESL)); +} + +adc_result_t ADC_GetConversion(adc_channel_t channel) +{ + //Selects the A/D channel + ADCON0bits.CHS = channel; + + //Turns on the ADC module + ADCON0bits.ADON = 1; + + //Acquisition time delay + __delay_us(ACQ_US_DELAY); + + //Starts the conversion + ADCON0bits.GOnDONE = 1; + + //Waits for the conversion to finish + while (ADCON0bits.GOnDONE) + { + } + + //Conversion finished, returns the result + return ((adc_result_t)((ADRESH << 8) + ADRESL)); +} + +void ADC_TemperatureAcquisitionDelay(void) +{ + __delay_us(200); +} + diff --git a/mcc_generated_files/pwm/pwm3.h b/mcc_generated_files/pwm/pwm3.h new file mode 100644 index 0000000..5536076 --- /dev/null +++ b/mcc_generated_files/pwm/pwm3.h @@ -0,0 +1,67 @@ +/** + * PWM3 Generated Driver API Header File + * + * @file pwm3.h + * + * @defgroup pwm3 PWM3 + * + * @brief This file contains the API prototypes for the PWM3 driver. + * + * @version PWM3 Driver Version 2.0.4 +*/ + +/* +© [2025] 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 PWM3_H + #define PWM3_H + + /** + * Section: Included Files + */ + + #include + #include + + /** + * Section: Macro Declarations + */ + + #define PWM3_INITIALIZE_DUTY_VALUE 499 + + +/** + * @ingroup pwm3 + * @brief Initializes the PWM3 interface. + * @param None. + * @return None. + */ + void PWM3_Initialize(void); + + /** + * @ingroup pwm3 + * @brief Loads the 16-bit duty cycle value. + * @param uint16_t dutyValue - PWM3 duty cycle value to be loaded. + * @return None. + */ + void PWM3_LoadDutyValue(uint16_t dutyValue); + + #endif //PWM3_H diff --git a/mcc_generated_files/pwm/pwm4.h b/mcc_generated_files/pwm/pwm4.h new file mode 100644 index 0000000..68cf419 --- /dev/null +++ b/mcc_generated_files/pwm/pwm4.h @@ -0,0 +1,67 @@ +/** + * PWM4 Generated Driver API Header File + * + * @file pwm4.h + * + * @defgroup pwm4 PWM4 + * + * @brief This file contains the API prototypes for the PWM4 driver. + * + * @version PWM4 Driver Version 2.0.4 +*/ + +/* +© [2025] 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 PWM4_H + #define PWM4_H + + /** + * Section: Included Files + */ + + #include + #include + + /** + * Section: Macro Declarations + */ + + #define PWM4_INITIALIZE_DUTY_VALUE 499 + + +/** + * @ingroup pwm4 + * @brief Initializes the PWM4 interface. + * @param None. + * @return None. + */ + void PWM4_Initialize(void); + + /** + * @ingroup pwm4 + * @brief Loads the 16-bit duty cycle value. + * @param uint16_t dutyValue - PWM4 duty cycle value to be loaded. + * @return None. + */ + void PWM4_LoadDutyValue(uint16_t dutyValue); + + #endif //PWM4_H diff --git a/mcc_generated_files/pwm/src/pwm3.c b/mcc_generated_files/pwm/src/pwm3.c new file mode 100644 index 0000000..24e9507 --- /dev/null +++ b/mcc_generated_files/pwm/src/pwm3.c @@ -0,0 +1,69 @@ +/** + * PWM3 Generated Driver File + * + * @file pwm3.c + * + * @ingroup pwm3 + * + * @brief This file contains the API implementations for the PWM3 module. + * + * @version PWM3 Driver Version 2.0.4 +*/ + + /* +© [2025] 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. +*/ + + /** + * Section: Included Files + */ + + #include + #include "../pwm3.h" + + /** + * Section: PWM Module APIs + */ + + void PWM3_Initialize(void) + { + // Set the PWM3 to the options selected in the User Interface + + // PWMPOL active_hi; PWMEN enabled; + PWM3CON = 0x80; + + // PWMDCH 124; + PWM3DCH = 0x7C; + + // PWMDCL 3; + PWM3DCL = 0xC0; + + + + } + + void PWM3_LoadDutyValue(uint16_t dutyValue) + { + // Writing to 8 MSBs of PWM duty cycle in PWMDCH register + PWM3DCH = (uint8_t) ((dutyValue & 0x03FCu) >> 2); + + // Writing to 2 LSBs of PWM duty cycle in PWMDCL register + PWM3DCL = (uint8_t) ((dutyValue & 0x0003u) << 6); + } diff --git a/mcc_generated_files/pwm/src/pwm4.c b/mcc_generated_files/pwm/src/pwm4.c new file mode 100644 index 0000000..d501d70 --- /dev/null +++ b/mcc_generated_files/pwm/src/pwm4.c @@ -0,0 +1,69 @@ +/** + * PWM4 Generated Driver File + * + * @file pwm4.c + * + * @ingroup pwm4 + * + * @brief This file contains the API implementations for the PWM4 module. + * + * @version PWM4 Driver Version 2.0.4 +*/ + + /* +© [2025] 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. +*/ + + /** + * Section: Included Files + */ + + #include + #include "../pwm4.h" + + /** + * Section: PWM Module APIs + */ + + void PWM4_Initialize(void) + { + // Set the PWM4 to the options selected in the User Interface + + // PWMPOL active_hi; PWMEN enabled; + PWM4CON = 0x80; + + // PWMDCH 124; + PWM4DCH = 0x7C; + + // PWMDCL 3; + PWM4DCL = 0xC0; + + + + } + + void PWM4_LoadDutyValue(uint16_t dutyValue) + { + // Writing to 8 MSBs of PWM duty cycle in PWMDCH register + PWM4DCH = (uint8_t) ((dutyValue & 0x03FCu) >> 2); + + // Writing to 2 LSBs of PWM duty cycle in PWMDCL register + PWM4DCL = (uint8_t) ((dutyValue & 0x0003u) << 6); + } diff --git a/mcc_generated_files/system/clock.h b/mcc_generated_files/system/clock.h new file mode 100644 index 0000000..94f772f --- /dev/null +++ b/mcc_generated_files/system/clock.h @@ -0,0 +1,61 @@ +/** + * CLOCK Generated Driver Header File + * + * @file clock.h + * + * @defgroup clockdriver Clock Driver + * + * @brief This file contains the API prototypes and other data types for the Clock driver. + * + * @version Driver Version 2.0.4 + * + * @version Package Version 4.3.7 + * +*/ + +/* +© [2025] 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 CLOCK_H +#define CLOCK_H + +#ifndef _XTAL_FREQ +/** + @ingroup clock control + @def system frequency + @misradeviation{@required, 21.1} Defining the system frequency using the _XTAL_FREQ macro is required by the XC8 compiler for the built-in delay functions. +*/ +/* cppcheck-suppress misra-c2012-21.1 */ +#define _XTAL_FREQ 32000000U +#endif + +/** + * @ingroup clockdriver + * @brief Initializes all the Internal Oscillator sources and the clock switch configurations. + * @param None. + * @return None. + */ +void CLOCK_Initialize(void); + +#endif /* CLOCK_H */ +/** + End of File +*/ diff --git a/mcc_generated_files/system/config_bits.h b/mcc_generated_files/system/config_bits.h new file mode 100644 index 0000000..54f8cd0 --- /dev/null +++ b/mcc_generated_files/system/config_bits.h @@ -0,0 +1,44 @@ +/** + * Configuration Bits Generated Driver Header File + * + * @file config_bits.h + * + * @defgroup config_bitsdriver CONFIGBITS Driver + * + * @brief This file contains the API prototype for the Configuration Bits driver. + * + * @version Driver Version 2.0.2 + * + * @version Package Version 1.0.5 +*/ + +/* +© [2025] 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 CONFIG_BITS_H +#define CONFIG_BITS_H + +#include "../system/clock.h" + +#endif /* CONFIG_BITS_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/system/interrupt.h b/mcc_generated_files/system/interrupt.h new file mode 100644 index 0000000..28023f4 --- /dev/null +++ b/mcc_generated_files/system/interrupt.h @@ -0,0 +1,166 @@ +/** + * Interrupt Manager Generated Driver API Header File + * + * @file interrupt.h + * + * @defgroup interrupt INTERRUPT + * + * @brief This file contains API prototypes and other data types for the Interrupt Manager driver. + * + * @version Interrupt Manager Driver Version 2.0.6 +*/ + +/* +© [2025] 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 INTERRUPT_H +#define INTERRUPT_H + + +/** + * @ingroup interrupt + * @brief Enables global interrupts. + * @param None. + * @return None. + */ +#define INTERRUPT_GlobalInterruptEnable() (INTCONbits.GIE = 1) + +/** + * @ingroup interrupt + * @brief Disables global interrupts. + * @param None. + * @return None. + */ +#define INTERRUPT_GlobalInterruptDisable() (INTCONbits.GIE = 0) + +/** + * @ingroup interrupt + * @brief Returns the Global Interrupt Enable bit status. + * @param None. + * @retval 0 - Global interrupt disabled. + * @retval 1 - Global interrupt enabled. + */ +#define INTERRUPT_GlobalInterruptStatus() (INTCONbits.GIE) + +/** + * @ingroup interrupt + * @brief Enables peripheral interrupts. + * @param None. + * @return None. + */ +#define INTERRUPT_PeripheralInterruptEnable() (INTCONbits.PEIE = 1) + +/** + * @ingroup interrupt + * @brief Disables peripheral interrupts. + * @param None. + * @return None. + */ +#define INTERRUPT_PeripheralInterruptDisable() (INTCONbits.PEIE = 0) + +/** + * @ingroup interrupt + * @brief Initializes peripheral interrupt priorities, enables or disables priority vectors and initializes the external interrupt. + * @param None. + * @return None. + */ +void INTERRUPT_Initialize (void); + + +/** + * @ingroup interrupt + * @brief Clears the Interrupt flag for the external interrupt, INT. + * @param None. + * @return None. + */ +#define EXT_INT_InterruptFlagClear() (PIR0bits.INTF = 0) + +/** + * @ingroup interrupt + * @brief Clears the interrupt enable for the external interrupt, INT. This way, the external interrupts on this pin will not be serviced by the interrupt handler. + * @param None. + * @return None. + */ +#define EXT_INT_InterruptDisable() (PIE0bits.INTE = 0) + +/** + * @ingroup interrupt + * @brief Sets the interrupt enable for the external interrupt, INT. This way, the external interrupts on this pin will be serviced by the interrupt handler. + * @param None. + * @return None. + */ +#define EXT_INT_InterruptEnable() (PIE0bits.INTE = 1) + + + +/** + Section: External Interrupt Handlers + */ + +/** + * @ingroup interrupt + * @brief Executes the ISR whenever the signal on the INT pin transitions to the preconfigured state. + * @pre Interrupt Manager is initialized. + * @param None. + * @return None. + */ +void INT_ISR(void); + +/** + * @ingroup interrupt + * @brief Allows for a specific callback function to be called in the INT ISR and for a nonspecific interrupt handler to be called at run time. + * @pre Interrupt Manager is initialized. + * @param None. + * @return None. + */ +void INT_CallBack(void); + +/** + * @ingroup interrupt + * @brief Allows selecting an interrupt handler for EXT_INT - INT at application run time. + * @pre Interrupt Manager is initialized. + * @param (*InterruptHandler)(void) - InterruptHandler function pointer. + * @return None. + */ +void INT_SetInterruptHandler(void (* InterruptHandler)(void)); + +/** + * @ingroup interrupt + * @brief Dynamic interrupt handler to be called every time the INT ISR is executed. It allows any function to be registered at run time. + * @pre Interrupt Manager is initialized. + * @param None. + * @return None. + */ +extern void (*INT_InterruptHandler)(void); + +/** + * @ingroup interrupt + * @brief Default interrupt handler to be called every time the INT ISR is executed. It allows any function to be registered at run time. + * @pre Interrupt Manager is initialized. + * @param None. + * @return None. + */ +void INT_DefaultInterruptHandler(void); + +#endif // INTERRUPT_H +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/system/pins.h b/mcc_generated_files/system/pins.h new file mode 100644 index 0000000..d9ea95f --- /dev/null +++ b/mcc_generated_files/system/pins.h @@ -0,0 +1,205 @@ +/** + * Generated Pins header File + * + * @file pins.h + * + * @defgroup pinsdriver Pins Driver + * + * @brief This is generated driver header for pins. + * This header file provides APIs for all pins selected in the GUI. + * + * @version Driver Version 3.0.0 +*/ + +/* +© [2025] 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 + +#include + +#define INPUT 1 +#define OUTPUT 0 + +#define HIGH 1 +#define LOW 0 + +#define ANALOG 1 +#define DIGITAL 0 + +#define PULL_UP_ENABLED 1 +#define PULL_UP_DISABLED 0 + +// get/set IO_RA2 aliases +#define DEBUG_TRIS TRISAbits.TRISA2 +#define DEBUG_LAT LATAbits.LATA2 +#define DEBUG_PORT PORTAbits.RA2 +#define DEBUG_WPU WPUAbits.WPUA2 +#define DEBUG_OD ODCONAbits.ODCA2 +#define DEBUG_ANS ANSELAbits.ANSA2 +#define DEBUG_SetHigh() do { LATAbits.LATA2 = 1; } while(0) +#define DEBUG_SetLow() do { LATAbits.LATA2 = 0; } while(0) +#define DEBUG_Toggle() do { LATAbits.LATA2 = ~LATAbits.LATA2; } while(0) +#define DEBUG_GetValue() PORTAbits.RA2 +#define DEBUG_SetDigitalInput() do { TRISAbits.TRISA2 = 1; } while(0) +#define DEBUG_SetDigitalOutput() do { TRISAbits.TRISA2 = 0; } while(0) +#define DEBUG_SetPullup() do { WPUAbits.WPUA2 = 1; } while(0) +#define DEBUG_ResetPullup() do { WPUAbits.WPUA2 = 0; } while(0) +#define DEBUG_SetPushPull() do { ODCONAbits.ODCA2 = 0; } while(0) +#define DEBUG_SetOpenDrain() do { ODCONAbits.ODCA2 = 1; } while(0) +#define DEBUG_SetAnalogMode() do { ANSELAbits.ANSA2 = 1; } while(0) +#define DEBUG_SetDigitalMode() do { ANSELAbits.ANSA2 = 0; } while(0) +// get/set IO_RA4 aliases +#define LED1_TRIS TRISAbits.TRISA4 +#define LED1_LAT LATAbits.LATA4 +#define LED1_PORT PORTAbits.RA4 +#define LED1_WPU WPUAbits.WPUA4 +#define LED1_OD ODCONAbits.ODCA4 +#define LED1_ANS ANSELAbits.ANSA4 +#define LED1_SetHigh() do { LATAbits.LATA4 = 1; } while(0) +#define LED1_SetLow() do { LATAbits.LATA4 = 0; } while(0) +#define LED1_Toggle() do { LATAbits.LATA4 = ~LATAbits.LATA4; } while(0) +#define LED1_GetValue() PORTAbits.RA4 +#define LED1_SetDigitalInput() do { TRISAbits.TRISA4 = 1; } while(0) +#define LED1_SetDigitalOutput() do { TRISAbits.TRISA4 = 0; } while(0) +#define LED1_SetPullup() do { WPUAbits.WPUA4 = 1; } while(0) +#define LED1_ResetPullup() do { WPUAbits.WPUA4 = 0; } while(0) +#define LED1_SetPushPull() do { ODCONAbits.ODCA4 = 0; } while(0) +#define LED1_SetOpenDrain() do { ODCONAbits.ODCA4 = 1; } while(0) +#define LED1_SetAnalogMode() do { ANSELAbits.ANSA4 = 1; } while(0) +#define LED1_SetDigitalMode() do { ANSELAbits.ANSA4 = 0; } while(0) +// get/set IO_RA5 aliases +#define LED2_TRIS TRISAbits.TRISA5 +#define LED2_LAT LATAbits.LATA5 +#define LED2_PORT PORTAbits.RA5 +#define LED2_WPU WPUAbits.WPUA5 +#define LED2_OD ODCONAbits.ODCA5 +#define LED2_ANS ANSELAbits.ANSA5 +#define LED2_SetHigh() do { LATAbits.LATA5 = 1; } while(0) +#define LED2_SetLow() do { LATAbits.LATA5 = 0; } while(0) +#define LED2_Toggle() do { LATAbits.LATA5 = ~LATAbits.LATA5; } while(0) +#define LED2_GetValue() PORTAbits.RA5 +#define LED2_SetDigitalInput() do { TRISAbits.TRISA5 = 1; } while(0) +#define LED2_SetDigitalOutput() do { TRISAbits.TRISA5 = 0; } while(0) +#define LED2_SetPullup() do { WPUAbits.WPUA5 = 1; } while(0) +#define LED2_ResetPullup() do { WPUAbits.WPUA5 = 0; } while(0) +#define LED2_SetPushPull() do { ODCONAbits.ODCA5 = 0; } while(0) +#define LED2_SetOpenDrain() do { ODCONAbits.ODCA5 = 1; } while(0) +#define LED2_SetAnalogMode() do { ANSELAbits.ANSA5 = 1; } while(0) +#define LED2_SetDigitalMode() do { ANSELAbits.ANSA5 = 0; } while(0) +// get/set IO_RC0 aliases +#define IO_RC0_TRIS TRISCbits.TRISC0 +#define IO_RC0_LAT LATCbits.LATC0 +#define IO_RC0_PORT PORTCbits.RC0 +#define IO_RC0_WPU WPUCbits.WPUC0 +#define IO_RC0_OD ODCONCbits.ODCC0 +#define IO_RC0_ANS ANSELCbits.ANSC0 +#define IO_RC0_SetHigh() do { LATCbits.LATC0 = 1; } while(0) +#define IO_RC0_SetLow() do { LATCbits.LATC0 = 0; } while(0) +#define IO_RC0_Toggle() do { LATCbits.LATC0 = ~LATCbits.LATC0; } while(0) +#define IO_RC0_GetValue() PORTCbits.RC0 +#define IO_RC0_SetDigitalInput() do { TRISCbits.TRISC0 = 1; } while(0) +#define IO_RC0_SetDigitalOutput() do { TRISCbits.TRISC0 = 0; } while(0) +#define IO_RC0_SetPullup() do { WPUCbits.WPUC0 = 1; } while(0) +#define IO_RC0_ResetPullup() do { WPUCbits.WPUC0 = 0; } while(0) +#define IO_RC0_SetPushPull() do { ODCONCbits.ODCC0 = 0; } while(0) +#define IO_RC0_SetOpenDrain() do { ODCONCbits.ODCC0 = 1; } while(0) +#define IO_RC0_SetAnalogMode() do { ANSELCbits.ANSC0 = 1; } while(0) +#define IO_RC0_SetDigitalMode() do { ANSELCbits.ANSC0 = 0; } while(0) +// get/set IO_RC3 aliases +#define RS_MODE_TRIS TRISCbits.TRISC3 +#define RS_MODE_LAT LATCbits.LATC3 +#define RS_MODE_PORT PORTCbits.RC3 +#define RS_MODE_WPU WPUCbits.WPUC3 +#define RS_MODE_OD ODCONCbits.ODCC3 +#define RS_MODE_ANS ANSELCbits.ANSC3 +#define RS_MODE_SetHigh() do { LATCbits.LATC3 = 1; } while(0) +#define RS_MODE_SetLow() do { LATCbits.LATC3 = 0; } while(0) +#define RS_MODE_Toggle() do { LATCbits.LATC3 = ~LATCbits.LATC3; } while(0) +#define RS_MODE_GetValue() PORTCbits.RC3 +#define RS_MODE_SetDigitalInput() do { TRISCbits.TRISC3 = 1; } while(0) +#define RS_MODE_SetDigitalOutput() do { TRISCbits.TRISC3 = 0; } while(0) +#define RS_MODE_SetPullup() do { WPUCbits.WPUC3 = 1; } while(0) +#define RS_MODE_ResetPullup() do { WPUCbits.WPUC3 = 0; } while(0) +#define RS_MODE_SetPushPull() do { ODCONCbits.ODCC3 = 0; } while(0) +#define RS_MODE_SetOpenDrain() do { ODCONCbits.ODCC3 = 1; } while(0) +#define RS_MODE_SetAnalogMode() do { ANSELCbits.ANSC3 = 1; } while(0) +#define RS_MODE_SetDigitalMode() do { ANSELCbits.ANSC3 = 0; } while(0) +// get/set IO_RC4 aliases +#define IO_RC4_TRIS TRISCbits.TRISC4 +#define IO_RC4_LAT LATCbits.LATC4 +#define IO_RC4_PORT PORTCbits.RC4 +#define IO_RC4_WPU WPUCbits.WPUC4 +#define IO_RC4_OD ODCONCbits.ODCC4 +#define IO_RC4_ANS ANSELCbits.ANSC4 +#define IO_RC4_SetHigh() do { LATCbits.LATC4 = 1; } while(0) +#define IO_RC4_SetLow() do { LATCbits.LATC4 = 0; } while(0) +#define IO_RC4_Toggle() do { LATCbits.LATC4 = ~LATCbits.LATC4; } while(0) +#define IO_RC4_GetValue() PORTCbits.RC4 +#define IO_RC4_SetDigitalInput() do { TRISCbits.TRISC4 = 1; } while(0) +#define IO_RC4_SetDigitalOutput() do { TRISCbits.TRISC4 = 0; } while(0) +#define IO_RC4_SetPullup() do { WPUCbits.WPUC4 = 1; } while(0) +#define IO_RC4_ResetPullup() do { WPUCbits.WPUC4 = 0; } while(0) +#define IO_RC4_SetPushPull() do { ODCONCbits.ODCC4 = 0; } while(0) +#define IO_RC4_SetOpenDrain() do { ODCONCbits.ODCC4 = 1; } while(0) +#define IO_RC4_SetAnalogMode() do { ANSELCbits.ANSC4 = 1; } while(0) +#define IO_RC4_SetDigitalMode() do { ANSELCbits.ANSC4 = 0; } while(0) +// get/set IO_RC5 aliases +#define IO_RC5_TRIS TRISCbits.TRISC5 +#define IO_RC5_LAT LATCbits.LATC5 +#define IO_RC5_PORT PORTCbits.RC5 +#define IO_RC5_WPU WPUCbits.WPUC5 +#define IO_RC5_OD ODCONCbits.ODCC5 +#define IO_RC5_ANS ANSELCbits.ANSC5 +#define IO_RC5_SetHigh() do { LATCbits.LATC5 = 1; } while(0) +#define IO_RC5_SetLow() do { LATCbits.LATC5 = 0; } while(0) +#define IO_RC5_Toggle() do { LATCbits.LATC5 = ~LATCbits.LATC5; } while(0) +#define IO_RC5_GetValue() PORTCbits.RC5 +#define IO_RC5_SetDigitalInput() do { TRISCbits.TRISC5 = 1; } while(0) +#define IO_RC5_SetDigitalOutput() do { TRISCbits.TRISC5 = 0; } while(0) +#define IO_RC5_SetPullup() do { WPUCbits.WPUC5 = 1; } while(0) +#define IO_RC5_ResetPullup() do { WPUCbits.WPUC5 = 0; } while(0) +#define IO_RC5_SetPushPull() do { ODCONCbits.ODCC5 = 0; } while(0) +#define IO_RC5_SetOpenDrain() do { ODCONCbits.ODCC5 = 1; } while(0) +#define IO_RC5_SetAnalogMode() do { ANSELCbits.ANSC5 = 1; } while(0) +#define IO_RC5_SetDigitalMode() do { ANSELCbits.ANSC5 = 0; } while(0) +/** + * @ingroup pinsdriver + * @brief GPIO and peripheral I/O initialization + * @param none + * @return none + */ +void PIN_MANAGER_Initialize (void); + +/** + * @ingroup pinsdriver + * @brief Interrupt on Change Handling routine + * @param none + * @return none + */ +void PIN_MANAGER_IOC(void); + + +#endif // PINS_H +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/system/src/clock.c b/mcc_generated_files/system/src/clock.c new file mode 100644 index 0000000..1fdcd62 --- /dev/null +++ b/mcc_generated_files/system/src/clock.c @@ -0,0 +1,56 @@ +/** + * CLOCK Generated Driver Source File + * + * @file clock.c + * + * @ingroup clockdriver + * + * @brief This file contains the API prototypes for the Clock driver. + * + * @version Driver Version 2.0.4 + * + * @version Package Version 4.3.7 +*/ + +/* +© [2025] 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. +*/ + +#include +#include "../clock.h" + +void CLOCK_Initialize(void) +{ + // Set the CLOCK CONTROL module to the options selected in the user interface. + OSCCON1 = (0 << _OSCCON1_NDIV_POSN) // NDIV 1 + | (6 << _OSCCON1_NOSC_POSN); // NOSC HFINTOSC + OSCCON3 = (0 << _OSCCON3_CSWHOLD_POSN); // CSWHOLD may proceed + OSCEN = (0 << _OSCEN_EXTOEN_POSN) // EXTOEN disabled + | (0 << _OSCEN_HFOEN_POSN) // HFOEN disabled + | (0 << _OSCEN_MFOEN_POSN) // MFOEN disabled + | (0 << _OSCEN_LFOEN_POSN) // LFOEN disabled + | (0 << _OSCEN_ADOEN_POSN); // ADOEN disabled + OSCFRQ = (6 << _OSCFRQ_HFFRQ_POSN); // HFFRQ 32_MHz + OSCTUNE = (0 << _OSCTUNE_HFTUN_POSN); // HFTUN 0x20 + +} +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/system/src/config_bits.c b/mcc_generated_files/system/src/config_bits.c new file mode 100644 index 0000000..536f289 --- /dev/null +++ b/mcc_generated_files/system/src/config_bits.c @@ -0,0 +1,75 @@ +/** + * Configuration Bits Generated Driver Source File + * + * @file config_bits.c + * + * @ingroup config_bitsdriver + * + * @brief This file contains the API Implementation for the Device Configuration Bits driver. + * + * @version Driver Version 2.0.2 + * + * @version Package Version 1.0.5 +*/ + +/* +© [2025] 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. +*/ + +// Configuration bits: selected in the GUI + +//CONFIG1 +#pragma config FEXTOSC = OFF // External Oscillator Selection bits->Oscillator not enabled +#pragma config RSTOSC = LFINT // Reset Oscillator Selection bits->LFINTOSC +#pragma config CLKOUTEN = OFF // Clock Out Enable bit->CLKOUT function is disabled; i/o or oscillator function on OSC2 +#pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed +#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit->FSCM timer enabled + +//CONFIG2 +#pragma config MCLRE = ON // Master Clear Enable bit->MCLR pin is Master Clear function +#pragma config LPBOREN = OFF // Low-Power BOR Enable bit->ULPBOR disabled +#pragma config BOREN = ON // Brown-out Reset Enable bits->Brown-out Reset Enabled, SBOREN bit is ignored +#pragma config BORV = LO // Brown-out Reset Voltage Selection bit->Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices +#pragma config ZCD = OFF // ZCD Disable bit->Zero-cross detect circuit is disabled at POR. +#pragma config PPS1WAY = ON // PPSLOCKED One-Way Set Enable bit->The PPSLOCK bit can be cleared and set only once in software +#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable bit->Stack Overflow or Underflow will cause a reset + +//CONFIG3 +#pragma config WDTCPS = WDTCPS_31 // WDT Period Select bits->Divider ratio 1:65536; software control of WDTPS +#pragma config WDTE = OFF // WDT Operating Mode bits->WDT Disabled, SWDTEN is ignored +#pragma config WDTCWS = WDTCWS_7 // WDT Window Select bits->window always open (100%); software control; keyed access not required +#pragma config WDTCCS = SC // WDT Input Clock Select bits->Software Control + +//CONFIG4 +#pragma config BBSIZE = BB512 // Boot Block Size Selection bits->512 words boot block size +#pragma config BBEN = OFF // Boot Block Enable bit->Boot Block disabled +#pragma config SAFEN = OFF // Storage Area Flash (SAF) Enable bit->SAF disabled +#pragma config WRTAPP = OFF // Application Block Write Protection bit->Application Block not write protected +#pragma config WRTB = OFF // Boot Block Write Protection bit->Boot Block not write protected +#pragma config WRTC = OFF // Configuration Register Write Protection bit->Configuration Register not write protected +#pragma config WRTSAF = OFF // Storage Area Flash (SAF) Write Protection bit->SAF not write protected +#pragma config LVP = ON // Low Voltage Programming Enable bit->Low Voltage programming enabled. MCLR/Vpp pin function is MCLR. + +//CONFIG5 +#pragma config CP = OFF // Program Flash Memory Code Protection bit->UserNVM code protection disabled + +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/system/src/interrupt.c b/mcc_generated_files/system/src/interrupt.c new file mode 100644 index 0000000..00b1a0d --- /dev/null +++ b/mcc_generated_files/system/src/interrupt.c @@ -0,0 +1,113 @@ +/** + * Interrupt Manager Generated Driver File + * + * @file interrupt.c + * + * @ingroup interrupt + * + * @brief This file contains the API implementation for the Interrupt Manager driver. + * + * @version Interrupt Manager Driver Version 2.0.6 +*/ + +/* +© [2025] 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. +*/ + +#include "../../system/interrupt.h" +#include "../../system/system.h" +#include "../pins.h" + +void (*INT_InterruptHandler)(void); + +void INTERRUPT_Initialize (void) +{ + // Clear the interrupt flag + EXT_INT_InterruptFlagClear(); + // Set Default Interrupt Handler + INT_SetInterruptHandler(INT_DefaultInterruptHandler); + // EXT_INT_InterruptEnable(); + +} + +/** + * @ingroup interrupt + * @brief Services the Interrupt Service Routines (ISR) of enabled interrupts and is called every time an interrupt is triggered. + * @pre Interrupt Manager is initialized. + * @param None. + * @return None. + */ +void __interrupt() INTERRUPT_InterruptManager (void) +{ + // interrupt handler + if(INTCONbits.PEIE == 1) + { + if(PIE0bits.TMR0IE == 1 && PIR0bits.TMR0IF == 1) + { + TMR0_ISR(); + } + else if(PIE4bits.TMR2IE == 1 && PIR4bits.TMR2IF == 1) + { + TMR2_ISR(); + } + else if(PIE4bits.TMR1IE == 1 && PIR4bits.TMR1IF == 1) + { + TMR1_OverflowISR(); + } + else + { + //Unhandled Interrupt + } + } + else + { + //Unhandled Interrupt + } +} + +void INT_ISR(void) +{ + EXT_INT_InterruptFlagClear(); + + // Callback function gets called everytime this ISR executes + INT_CallBack(); +} + + +void INT_CallBack(void) +{ + // Add your custom callback code here + if(INT_InterruptHandler) + { + INT_InterruptHandler(); + } +} + +void INT_SetInterruptHandler(void (* InterruptHandler)(void)){ + INT_InterruptHandler = InterruptHandler; +} + +void INT_DefaultInterruptHandler(void){ + // add your INT interrupt custom code + // or set custom function using INT_SetInterruptHandler() +} +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/system/src/pins.c b/mcc_generated_files/system/src/pins.c new file mode 100644 index 0000000..9c5feaa --- /dev/null +++ b/mcc_generated_files/system/src/pins.c @@ -0,0 +1,111 @@ +/** + * Generated Driver File + * + * @file pins.c + * + * @ingroup pinsdriver + * + * @brief This is generated driver implementation for pins. + * This file provides implementations for pin APIs for all pins selected in the GUI. + * + * @version Driver Version 3.0.0 +*/ + +/* +© [2025] 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. +*/ + +#include "../pins.h" + + +void PIN_MANAGER_Initialize(void) +{ + /** + LATx registers + */ + LATA = 0x0; + LATC = 0x0; + + /** + TRISx registers + */ + TRISA = 0x3; + TRISC = 0x17; + + /** + ANSELx registers + */ + ANSELA = 0x33; + ANSELC = 0x7; + + /** + WPUx registers + */ + WPUA = 0x0; + WPUC = 0x0; + + /** + ODx registers + */ + + ODCONA = 0x0; + ODCONC = 0x0; + /** + SLRCONx registers + */ + SLRCONA = 0x37; + SLRCONC = 0x3F; + /** + INLVLx registers + */ + INLVLA = 0x3F; + INLVLC = 0x3F; + + /** + PPS registers + */ + RX1DTPPS = 0x14; //RC4->EUSART1:RX1; + RA5PPS = 0x0C; //RA5->PWM4:PWM4OUT; + RC5PPS = 0x0F; //RC5->EUSART1:TX1; + RA4PPS = 0x0B; //RA4->PWM3:PWM3OUT; + + /** + APFCON registers + */ + + /** + IOCx registers + */ + IOCAP = 0x0; + IOCAN = 0x0; + IOCAF = 0x0; + IOCCP = 0x0; + IOCCN = 0x0; + IOCCF = 0x0; + + +} + +void PIN_MANAGER_IOC(void) +{ +} +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/system/src/system.c b/mcc_generated_files/system/src/system.c new file mode 100644 index 0000000..54a943c --- /dev/null +++ b/mcc_generated_files/system/src/system.c @@ -0,0 +1,52 @@ +/** + * System Driver Source File + * + * @file system.c + * + * @ingroup systemdriver + * + * @brief This file contains the API implementation for the System driver. + * + * @version Driver Version 2.0.3 + * + * @version Package Version 1.0.5 +*/ + +/* +© [2025] 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. +*/ + +#include "../system.h" + + +void SYSTEM_Initialize(void) +{ + CLOCK_Initialize(); + PIN_MANAGER_Initialize(); + TMR0_Initialize(); + TMR1_Initialize(); + TMR2_Initialize(); + ADC_Initialize(); + EUSART1_Initialize(); + PWM3_Initialize(); + PWM4_Initialize(); + INTERRUPT_Initialize(); +} + diff --git a/mcc_generated_files/system/system.h b/mcc_generated_files/system/system.h new file mode 100644 index 0000000..85eefbe --- /dev/null +++ b/mcc_generated_files/system/system.h @@ -0,0 +1,66 @@ +/** + * System Driver Header File + * + * @file system.h + * + * @defgroup systemdriver System Driver + * + * @brief This file contains the API prototype for the System Driver. + * + * @version Driver Version 2.0.3 + * + * @version Package Version 1.0.5 +*/ + +/* +© [2025] 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 SYSTEM_H +#define SYSTEM_H + +#include +#include +#include +#include "config_bits.h" +#include "../system/pins.h" +#include "../adc/adc.h" +#include "../uart/eusart1.h" +#include "../pwm/pwm3.h" +#include "../pwm/pwm4.h" +#include "../system/interrupt.h" +#include "../system/clock.h" +#include "../timer/tmr0.h" +#include "../timer/tmr1.h" +#include "../timer/tmr2.h" + +/** + * @ingroup systemdriver + * @brief Initializes the system module. + * This routine is called only once during system initialization, before calling other APIs. + * @param None. + * @return None. +*/ +void SYSTEM_Initialize(void); + +#endif /* SYSTEM_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/timer/src/tmr0.c b/mcc_generated_files/timer/src/tmr0.c new file mode 100644 index 0000000..86033b7 --- /dev/null +++ b/mcc_generated_files/timer/src/tmr0.c @@ -0,0 +1,143 @@ +/** + * TMR0 Generated Driver File + * + * @file tmr0.c + * + * @ingroup tmr08bit + * + * @brief Driver implementation for the TMR0 driver + * + * @version TMR0 Driver Version 3.0.0 + * + * @version Package Version 5.0.0 +*/ +/* +© [2025] 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. +*/ + +#include +#include "../tmr0.h" + +static void (*TMR0_PeriodMatchCallback)(void); +static void TMR0_DefaultCallback(void); + +/** + Section: TMR0 APIs +*/ + +void TMR0_Initialize(void) +{ + TMR0H = 0x63; // Period 10ms; Frequency 10000 Hz; Count 99 + TMR0L = 0x0; + + T0CON1 = (0 << _T0CON1_T0CS_POSN) // T0CS T0CKI_PIN + | (0 << _T0CON1_T0CKPS_POSN) // T0CKPS 1:1 + | (1 << _T0CON1_T0ASYNC_POSN); // T0ASYNC not_synchronised + + TMR0_PeriodMatchCallback = TMR0_DefaultCallback; + + PIR0bits.TMR0IF = 0; + PIE0bits.TMR0IE = 1; + + T0CON0 = (0 << _T0CON0_T0OUTPS_POSN) // T0OUTPS 1:1 + | (1 << _T0CON0_T0EN_POSN) // T0EN enabled + | (0 << _T0CON0_T016BIT_POSN); // T016BIT 8-bit +} + +void TMR0_Deinitialize(void) +{ + T0CON0bits.T0EN = 0; + + PIR0bits.TMR0IF = 0; + PIE0bits.TMR0IE = 0; + + T0CON0 = 0x0; + T0CON1 = 0x0; + TMR0H = 0xFF; + TMR0L =0x0; +} + +void TMR0_Start(void) +{ + T0CON0bits.T0EN = 1; +} + +void TMR0_Stop(void) +{ + T0CON0bits.T0EN = 0; +} + +uint8_t TMR0_CounterGet(void) +{ + uint8_t counterValue; + + counterValue = TMR0L; + + return counterValue; +} + +void TMR0_CounterSet(uint8_t counterValue) +{ + TMR0L = counterValue; + } + +void TMR0_PeriodSet(uint8_t periodValue) +{ + TMR0H = periodValue; +} + +uint8_t TMR0_PeriodGet(void) +{ + return TMR0H; +} + +uint8_t TMR0_MaxCountGet(void) +{ + return TMR0_MAX_COUNT; +} + +void TMR0_TMRInterruptEnable(void) +{ + PIE0bits.TMR0IE = 1; +} + +void TMR0_TMRInterruptDisable(void) +{ + PIE0bits.TMR0IE = 0; +} + +void TMR0_ISR(void) +{ + if(NULL != TMR0_PeriodMatchCallback) + { + TMR0_PeriodMatchCallback(); + } + PIR0bits.TMR0IF = 0; +} + +void TMR0_PeriodMatchCallbackRegister(void (* callbackHandler)(void)) +{ + TMR0_PeriodMatchCallback = callbackHandler; +} + +static void TMR0_DefaultCallback(void) +{ + // Default callback +} \ No newline at end of file diff --git a/mcc_generated_files/timer/src/tmr1.c b/mcc_generated_files/timer/src/tmr1.c new file mode 100644 index 0000000..9a3389b --- /dev/null +++ b/mcc_generated_files/timer/src/tmr1.c @@ -0,0 +1,218 @@ +/** + * TMR1 Generated Driver File + * + * @file tmr1.c + * + * @ingroup tmr1 + * + * @brief Driver implementation for the TMR1 driver + * + * @version TMR1 Driver Version 4.0.0 + * + * @version Package Version 5.0.0 + */ +/* +© [2025] 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. +*/ + +/** + * Section: Included Files +*/ + +#include +#include "../tmr1.h" + + +static volatile uint16_t timer1ReloadVal; +static void (*TMR1_OverflowCallback)(void); +static void (*TMR1_GateCallback)(void); +static void TMR1_DefaultOverflowCallback(void); +static void TMR1_DefaultGateCallback(void); + +void TMR1_Initialize(void) +{ + T1CONbits.TMR1ON = 0; // TMRON disabled + + T1GCON = (0 << _T1GCON_T1GGO_POSN) // T1GGO done + | (0 << _T1GCON_T1GSPM_POSN) // T1GSPM disabled + | (0 << _T1GCON_T1GTM_POSN) // T1GTM disabled + | (0 << _T1GCON_T1GPOL_POSN) // T1GPOL low + | (0 << _T1GCON_T1GE_POSN); // T1GE disabled + + T1GATE = (0 << _T1GATE_GSS_POSN); // GSS T1G_pin + + T1CLK = (4 << _T1CLK_CS_POSN); // CS LFINTOSC + + TMR1H = 0xF3; // Period 100.03226ms; Timer clock 31000 Hz; + TMR1L = 0xE3; + + timer1ReloadVal=((uint16_t)TMR1H << 8) | TMR1L; + TMR1_OverflowCallback = TMR1_DefaultOverflowCallback; + TMR1_GateCallback = TMR1_DefaultGateCallback; + + PIR4bits.TMR1IF = 0; + PIE4bits.TMR1IE = 1; + + T1CON = (1 << _T1CON_TMR1ON_POSN) // TMR1ON enabled + | (0 << _T1CON_T1RD16_POSN) // T1RD16 disabled + | (1 << _T1CON_nT1SYNC_POSN) // nT1SYNC do_not_synchronize + | (0 << _T1CON_CKPS_POSN); // CKPS 1:1 +} + +void TMR1_Deinitialize(void) +{ + T1CONbits.TMR1ON = 0; // TMRON disabled + + T1CON = 0x0; + T1GCON = 0x0; + T1GATE = 0x0; + T1CLK = 0x0; + TMR1H = 0x0; + TMR1L = 0x0; + + PIR4bits.TMR1IF = 0; + PIE4bits.TMR1IE = 0; + PIR5bits.TMR1GIF = 0; + PIE5bits.TMR1GIE = 0; +} + +void TMR1_Start(void) +{ + T1CONbits.TMR1ON = 1; +} + +void TMR1_Stop(void) +{ + T1CONbits.TMR1ON = 0; +} + +uint16_t TMR1_CounterGet(void) +{ + uint16_t readVal; + uint8_t readValHigh; + uint8_t readValLow; + + readValLow = TMR1L; + readValHigh = TMR1H; + + readVal = ((uint16_t)readValHigh << 8) | readValLow; + + return readVal; +} + +void TMR1_CounterSet(uint16_t timerVal) +{ + if (1U == T1CONbits.nT1SYNC) + { + bool onState = T1CONbits.TMR1ON; + + TMR1H = (uint8_t)(timerVal >> 8); + TMR1L = (uint8_t)timerVal; + + T1CONbits.TMR1ON = onState; + } + else + { + TMR1H = (uint8_t)(timerVal >> 8); + TMR1L = (uint8_t)timerVal; + } +} + +void TMR1_PeriodSet(uint16_t periodVal) +{ + timer1ReloadVal = periodVal; +} + +uint16_t TMR1_PeriodGet(void) +{ + return timer1ReloadVal; +} + +void TMR1_Reload(void) +{ + /* cppcheck-suppress misra-c2012-8.7 */ + TMR1_CounterSet(timer1ReloadVal); +} + +uint16_t TMR1_MaxCountGet(void) +{ + return TMR1_MAX_COUNT; +} + +void TMR1_SinglePulseAcquisitionStart(void) +{ + T1GCONbits.T1GGO = 1; +} + +uint8_t TMR1_GateStateGet(void) +{ + return (T1GCONbits.T1GVAL); +} + +void TMR1_TMRInterruptEnable(void) +{ + PIE4bits.TMR1IE = 1; +} + +void TMR1_TMRInterruptDisable(void) +{ + PIE4bits.TMR1IE = 0; +} + +void TMR1_OverflowISR(void) +{ + static volatile uint16_t CountCallBack = 0; + /* cppcheck-suppress misra-c2012-8.7 */ + TMR1_CounterSet(timer1ReloadVal); + + // Callback function: This is called on every 5 pass. + if(++CountCallBack >= TMR1_INTERRUPT_TICKER_FACTOR) + { + if(NULL != TMR1_OverflowCallback) + { + TMR1_OverflowCallback(); + } + CountCallBack = 0; + } + PIR4bits.TMR1IF = 0; +} + +void TMR1_OverflowCallbackRegister(void (*CallbackHandler)(void)) +{ + TMR1_OverflowCallback = CallbackHandler; +} + +void TMR1_GateCallbackRegister(void (*CallbackHandler)(void)) +{ + TMR1_GateCallback = CallbackHandler; +} + +static void TMR1_DefaultOverflowCallback(void) +{ + // Default overflow callback +} + +static void TMR1_DefaultGateCallback(void) +{ + // Default Gate callback +} +/** + End of File +*/ diff --git a/mcc_generated_files/timer/src/tmr2.c b/mcc_generated_files/timer/src/tmr2.c new file mode 100644 index 0000000..ebd9181 --- /dev/null +++ b/mcc_generated_files/timer/src/tmr2.c @@ -0,0 +1,157 @@ +/** + * TMR2 Generated Timer Driver File + * + * @file tmr2.c + * + * @ingroup timerdriver + * + * @brief Driver implementation for the TMR2 Timer driver. + * + * @version Driver Version 4.0.0 + * + * @version Package Version 5.0.0 + */ + +/* +© [2025] 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. +*/ + +/** + Section: Included Files +*/ + +#include +#include "../tmr2.h" + +const struct TIMER_INTERFACE Timer2 = { + .Initialize = TMR2_Initialize, + .Deinitialize = TMR2_Deinitialize, + .Start = TMR2_Start, + .Stop = TMR2_Stop, + .PeriodSet = TMR2_PeriodSet, + .PeriodGet = TMR2_PeriodGet, + .CounterGet = TMR2_CounterGet, + .CounterSet = TMR2_CounterSet, + .MaxCountGet = TMR2_MaxCountGet, + .TimeoutCallbackRegister = TMR2_PeriodMatchCallbackRegister, + .Tasks = NULL +}; + +static void (*TMR2_PeriodMatchCallback)(void); +static void TMR2_DefaultPeriodMatchCallback(void); + +/** + Section: TMR2 APIs +*/ + +void TMR2_Initialize(void) +{ + T2CLKCON = (1 << _T2CLKCON_T2CS_POSN); // T2CS FOSC/4 + + T2HLT = (0 << _T2HLT_T2MODE_POSN) // T2MODE Software control + | (0 << _T2HLT_T2CKSYNC_POSN) // T2CKSYNC Not Synchronized + | (0 << _T2HLT_T2CKPOL_POSN) // T2CKPOL Rising Edge + | (0 << _T2HLT_T2PSYNC_POSN); // T2PSYNC Not Synchronized + + T2RST = (0 << _T2RST_T2RSEL_POSN); // T2RSEL T2INPPS pin + + T2PR = 0xF9; // Period 0.001s; Frequency 250000Hz; Count 249 + + T2TMR = 0x0; + + TMR2_PeriodMatchCallback = TMR2_DefaultPeriodMatchCallback; + + PIR4bits.TMR2IF = 0; + PIE4bits.TMR2IE = 1; + + T2CON = (5 << _T2CON_T2CKPS_POSN) // T2CKPS 1:32 + | (1 << _T2CON_TMR2ON_POSN) // TMR2ON on + | (0 << _T2CON_T2OUTPS_POSN); // T2OUTPS 1:1 +} + +void TMR2_Deinitialize(void) +{ + T2CONbits.TMR2ON = 0; + + PIR4bits.TMR2IF = 0; + PIE4bits.TMR2IE = 0; + + T2CON = 0x0; + T2CLKCON = 0x0; + T2HLT = 0x0; + T2RST = 0x0; + T2PR = 0xFF; + T2TMR =0x0; +} + +void TMR2_Start(void) +{ + T2CONbits.TMR2ON = 1; +} + +void TMR2_Stop(void) +{ + T2CONbits.TMR2ON = 0; +} + +uint32_t TMR2_CounterGet(void) +{ + return (uint32_t)T2TMR; +} + +void TMR2_CounterSet(uint32_t count) +{ + T2TMR = (uint8_t)count; +} + +void TMR2_PeriodSet(uint32_t periodVal) +{ + T2PR = (uint8_t)periodVal; +} + +uint32_t TMR2_PeriodGet(void) +{ + return (uint32_t)T2PR; +} + +uint32_t TMR2_MaxCountGet(void) +{ + return (uint32_t)TMR2_MAX_COUNT; +} + +void TMR2_ISR(void) +{ + // The ticker is set to 1 -> The callback function gets called every time this ISR executes. + if(NULL != TMR2_PeriodMatchCallback) + { + TMR2_PeriodMatchCallback(); + } + PIR4bits.TMR2IF = 0; +} + +void TMR2_PeriodMatchCallbackRegister(void (* callbackHandler)(void)) +{ + TMR2_PeriodMatchCallback = callbackHandler; +} + +static void TMR2_DefaultPeriodMatchCallback(void) +{ + // Default callback function +} diff --git a/mcc_generated_files/timer/timer_interface.h b/mcc_generated_files/timer/timer_interface.h new file mode 100644 index 0000000..b0f666d --- /dev/null +++ b/mcc_generated_files/timer/timer_interface.h @@ -0,0 +1,110 @@ +/** + * TIMER Generated Driver Interface Header File + * + * @file timer_interface.h + * + * @defgroup timerdriver Timer Driver + * + * @brief The Timer driver is an 8-bit, 16-bit or 32-bit timer that can operate as a + * free-running interval timer using PIC®, dsPIC® and AVR® microcontrollers (MCUs). + * + * @skipline @version Firmware Driver Version 1.7.0 +*/ + +/* +© [2025] 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 TIMER_INTERFACE_H +#define TIMER_INTERFACE_H + +// Section: Included Files +#include +#include +#include + +// Section: Data Type Definitions + +/** + * @ingroup timerdriver + * @brief Defines the deprecated SCCPx_Timer_PeriodCountSet or TMRx_PeriodCountSet API. + * Set it to 1 for backward compatibility for 16-bit MCUs only. +*/ +#define TIMER_PERIODCOUNTSET_API_SUPPORT 0 + +/** + * @ingroup timerdriver + * @brief The InterruptPrioritySet API is not supported. +*/ +#define TIMER_INTERRUPT_PRIORITY_SUPPORT 0 + +/** + @ingroup timerdriver + @struct TIMER_INTERFACE + @brief Structure containing the function pointers of the Timer driver +*/ +struct TIMER_INTERFACE +{ + void (*Initialize)(void); + ///< Pointer to MCCPx_Timer_Initialize, SCCPx_Timer_Initialize or TMRx_Initialize (e.g., \ref SCCP1_Timer_Initialize or \ref TMR1_Initialize). + + void (*Deinitialize)(void); + ///< Pointer to MCCPx_Timer_Deinitialize, SCCPx_Timer_Deinitialize or TMRx_Deinitialize (e.g., \ref SCCP1_Timer_Deinitialize or \ref TMR1_Deinitialize). + + void (*Start)(void); + ///< Pointer to MCCPx_Timer_Start, SCCPx_Timer_Start or TMRx_Start (e.g., \ref SCCP1_Timer_Start or \ref TMR1_Start). + + void (*Stop)(void); + ///< Pointer to MCCPx_Timer_Stop, SCCPx_Timer_Stop or TMRx_Stop (e.g., \ref SCCP1_Timer_Stop or \ref TMR1_Stop). + + #if TIMER_PERIODCOUNTSET_API_SUPPORT + void (*PeriodCountSet)(size_t count); + ///< Pointer to MCCPx_Timer_PeriodCountSet, SCCPx_Timer_PeriodCountSet or TMRx_PeriodCountSet (e.g., \ref SCCP1_Timer_PeriodCountSet or \ref TMR1_PeriodCountSet). + #endif + + void (*PeriodSet)(uint32_t count); + ///< Pointer to MCCPx_Timer_PeriodSet, SCCPx_Timer_PeriodSet or TMRx_PeriodSet (e.g., \ref SCCP1_Timer_PeriodSet or \ref TMR1_PeriodSet). + + uint32_t (*PeriodGet)(void); + ///< Pointer to MCCPx_Timer_PeriodGet, SCCPx_Timer_PeriodGet or TMRx_PeriodGet (e.g., \ref SCCP1_Timer_PeriodGet or \ref TMR1_PeriodGet). + + uint32_t (*CounterGet)(void); + ///< Pointer to MCCPx_Timer_CounterGet, SCCPx_Timer_CounterGet or TMRx_CounterGet (e.g., \ref SCCP1_Timer_CounterGet or \ref TMR1_CounterGet). + + void (*CounterSet)(uint32_t count); + ///< Pointer to MCCPx_Timer_CounterSet, SCCPx_Timer_CounterSet or TMRx_CounterSet (e.g., \ref SCCP1_Timer_CounterSet or \ref TMR1_CounterSet). + + uint32_t (*MaxCountGet)(void); + ///< Pointer to MCCPx_Timer_MaxCountGet, SCCPx_Timer_MaxCountGet or TMRx_MaxCountGet (e.g., \ref SCCP1_Timer_MaxCountGet or \ref TMR1_MaxCountGet). + + #if TIMER_INTERRUPT_PRIORITY_SUPPORT + void (*InterruptPrioritySet)(enum INTERRUPT_PRIORITY priority); + ///< Pointer to MCCPx_Timer_InterruptPrioritySet, SCCPx_Timer_InterruptPrioritySet or TMRx_InterruptPrioritySet (e.g., \ref SCCP1_Timer_InterruptPrioritySet or \ref TMR1_InterruptPrioritySet). + #endif + + void (*TimeoutCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to MCCPx_TimeoutCallbackRegister, SCCPx_TimeoutCallbackRegister or TMRx_TimeoutCallbackRegister (e.g., \ref SCCP1_TimeoutCallbackRegister or \ref TMR1_TimeoutCallbackRegister). + + void (*Tasks)(void); + ///< Pointer to MCCPx_Timer_Tasks, SCCPx_Timer_Tasks or TMRx_Tasks (e.g., \ref SCCP1_Timer_Tasks or \ref TMR1_Tasks, supported only in Polling mode). +}; + +#endif // TIMER_INTERFACE_H + diff --git a/mcc_generated_files/timer/tmr0.h b/mcc_generated_files/timer/tmr0.h new file mode 100644 index 0000000..06c57e7 --- /dev/null +++ b/mcc_generated_files/timer/tmr0.h @@ -0,0 +1,266 @@ +/** + * TMR0 Generated Driver API Header File + * + * @file tmr0.h + * + * @defgroup tmr08bit TMR0 in 8-Bit Mode + * + * @brief This file contains API prototypes and other data types for the TMR0 driver. + * + * @version TMR0 Driver Version 3.0.0 + * + * @version Package Version 5.0.0 +*/ +/* +© [2025] 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 TMR0_H +#define TMR0_H + +#include +#include +#include "tmr0_deprecated.h" + +/** + * @misradeviation{@advisory,2.5} + * MCC Melody drivers provide macros that can be added to an application. + * It depends on the application whether a macro is used or not. + */ + +/** + * @ingroup tmr08bit + * @brief Defines the maximum count value of the timer. + */ +#define TMR0_MAX_COUNT (255U) +/** + * @ingroup tmr08bit + * @brief Defines the timer prescaled clock frequency in hertz. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR0_CLOCK_FREQ (10000UL) +/** + * @ingroup tmr08bit + * @brief Defines the timer interrupt ticker factor. + */ +#define TMR0_INTERRUPT_TICKER_FACTOR (1U) +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_MAX_COUNT. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_MAX_COUNT TMR0_MAX_COUNT +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_CLOCK_FREQ. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_CLOCK_FREQ TMR0_CLOCK_FREQ +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_Initialize API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_Initialize TMR0_Initialize +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_Deinitialize API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_Deinitialize TMR0_Deinitialize +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_Start API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_Start TMR0_Start +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_Stop API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_Stop TMR0_Stop +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_CounterGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_CounterGet TMR0_CounterGet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_CounterSet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_CounterSet TMR0_CounterSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodSet API + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_PeriodSet TMR0_PeriodSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_PeriodGet TMR0_PeriodGet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_MaxCountGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_MaxCountGet TMR0_MaxCountGet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_TMRInterruptEnable API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_TMRInterruptEnable TMR0_TMRInterruptEnable +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_TMRInterruptDisable API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_TMRInterruptDisable TMR0_TMRInterruptDisable +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_ISR API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_ISR TMR0_ISR +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodMatchCallbackRegister API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_PeriodMatchCallbackRegister TMR0_PeriodMatchCallbackRegister + +/** + * @ingroup tmr08bit + * @brief Initializes the Timer0 (TMR0) module. + * This routine must be called before any other TMR0 routines. + * @param None. + * @return None. + */ +void TMR0_Initialize(void); + +/** + * @ingroup tmr08bit + * @brief Deinitializes the TMR0 module. + * @param None. + * @return None. + */ +void TMR0_Deinitialize(void); + +/** + * @ingroup tmr08bit + * @brief Starts the TMR0 timer. + * @pre Initialize TMR0 with TMR0_Initialize() before calling this API. + * @param None. + * @return None. + */ +void TMR0_Start(void); + +/** + * @ingroup tmr08bit + * @brief Stops the TMR0 timer. + * @pre Initialize TMR0 with TMR0_Initialize() before calling this API. + * @param None. + * @return None. + */ +void TMR0_Stop(void); + +/** + * @ingroup tmr08bit + * @brief Returns the current counter value. + * @pre Initialize TMR0 with TMR0_Initialize() before calling this API. + * @param None. + * @return Counter value from the TMR0L register + */ +uint8_t TMR0_CounterGet(void); + +/** + * @ingroup tmr08bit + * @brief Sets the counter value. + * @pre Initialize TMR0 with TMR0_Initialize() before calling this API. + * @param counterValue - Counter value to be written to the TMR0L register + * @return None. + */ +void TMR0_CounterSet(uint8_t counterValue); + +/** + * @ingroup tmr08bit + * @brief Sets the period value. + * @pre Initialize TMR0 with TMR0_Initialize() before calling this API. + * @param periodCount - Period count value written to the TMR0H register + * @return None. + */ +void TMR0_PeriodSet(uint8_t periodCount); + +/** + * @ingroup tmr08bit + * @brief Returns the current period value. + * @pre Initialize TMR0 with TMR0_Initialize() before calling this API. + * @param None. + * @return Period count value from the TMR0H register + */ +uint8_t TMR0_PeriodGet(void); + +/** + * @ingroup tmr08bit + * @brief Returns the maximum count value. + * @param None. + * @return Maximum count value + */ +uint8_t TMR0_MaxCountGet(void); + +/** + * @ingroup tmr08bit + * @brief Enables the TMR0 interrupt. + * @param None. + * @return None. + */ +void TMR0_TMRInterruptEnable(void); + +/** + * @ingroup tmr08bit + * @brief Disables the TMR0 interrupt. + * @param None. + * @return None. + */ +void TMR0_TMRInterruptDisable(void); + +/** + * @ingroup tmr08bit + * @brief Interrupt Service Routine (ISR) for the TMR0 overflow or period match interrupt. + * @param None. + * @return None. + */ +void TMR0_ISR(void); + +/** + * @ingroup tmr08bit + * @brief Registers a callback function for the TMR0 overflow or period match event. + * @param CallbackHandler - Address to the custom callback function + * @return None. + */ +void TMR0_PeriodMatchCallbackRegister(void (* CallbackHandler)(void)); + +#endif //TMR0_H \ No newline at end of file diff --git a/mcc_generated_files/timer/tmr0_deprecated.h b/mcc_generated_files/timer/tmr0_deprecated.h new file mode 100644 index 0000000..2716c2d --- /dev/null +++ b/mcc_generated_files/timer/tmr0_deprecated.h @@ -0,0 +1,136 @@ +/** + * TMR0 Generated Driver API Header File + * + * @file tmr0.h + * + * @defgroup tmr08bit TMR0 in 8-Bit Mode + * + * @brief This file contains the deprecated macros or APIs for the TMR0 driver. + * + * @version TMR0 Driver Version 3.0.0 + * + * @version Package Version 5.0.0 +*/ +/* +© [2025] 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 TMR0_DEPRECATED_H +#define TMR0_DEPRECATED_H + +#include +#include + +#warning "The tmr0_deprecated.h file contains the deprecated macros or functions. Replace the deprecated macro or functions with the recommended alternative." + +/** + * @misradeviation{@advisory,2.5} + * MCC Melody drivers provide macros that can be added to an application. + * It depends on the application whether a macro is used or not. + */ + +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_CounterGet API. + * The TMR0_Read will be deprecated in the future release. Use TMR0_CounterGet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR0_Read TMR0_CounterGet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_CounterGet API. + * The TMR_TX_Read will be deprecated in the future release. Use TMR0_CounterGet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_Read TMR0_CounterGet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_CounterSet API. + * The TMR0_Write will be deprecated in the future release. Use TMR0_CounterSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR0_Write TMR0_CounterSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_CounterSet API. + * The TMR_TX_Write will be deprecated in the future release. Use TMR0_CounterSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_Write TMR0_CounterSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodSet API. + * The TMR0_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR0_PeriodCountSet TMR0_PeriodSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodSet API. + * The TMR_TX_PeriodCountSet will be deprecated in the future release. Use TMR0_PeriodSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_PeriodCountSet TMR0_PeriodSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodSet API. + * The TMR0_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR0_Reload TMR0_PeriodSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodSet API. + * The TMR_TX_Reload will be deprecated in the future release. Use TMR0_PeriodSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_Reload TMR0_PeriodSet +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_ISR API. + * The TMR0_OverflowISR will be deprecated in the future release. Use TMR0_ISR instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR0_OverflowISR TMR0_ISR +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_ISR API. + * The TMR_TX_OverflowISR will be deprecated in the future release. Use TMR0_ISR instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_OverflowISR TMR0_ISR +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodMatchCallbackRegister API. + * The TMR0_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR0_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister +/** + * @ingroup tmr08bit + * @brief Defines the Custom Name for the \ref TMR0_PeriodMatchCallbackRegister API. + * The TMR_TX_OverflowCallbackRegister will be deprecated in the future release. Use TMR0_PeriodMatchCallbackRegister instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_TX_OverflowCallbackRegister TMR0_PeriodMatchCallbackRegister +/** + * @} + */ +#endif //TMR0_DEPRECATED_H \ No newline at end of file diff --git a/mcc_generated_files/timer/tmr1.h b/mcc_generated_files/timer/tmr1.h new file mode 100644 index 0000000..4c49a4d --- /dev/null +++ b/mcc_generated_files/timer/tmr1.h @@ -0,0 +1,318 @@ +/** + * TMR1 Generated Driver API Header File + * + * @file tmr1.h + * + * @defgroup tmr1 TMR1 + * + * @brief This file contains API prototypes and other data types for the TMR1 driver. + * + * @version TMR1 Driver Version 4.0.0 + * + * @version Package Version 5.0.0 + */ +/* +© [2025] 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 TMR1_H +#define TMR1_H + +#include +#include +#include "tmr1_deprecated.h" + +/** + * @misradeviation{@advisory,2.5} + * MCC Melody drivers provide macros that can be added to an application. + * It depends on the application whether a macro is used or not. + */ + +/** + * @ingroup tmr1 + * @brief Defines the maximum count value of the timer. + */ +#define TMR1_MAX_COUNT (65535U) +/** + * @ingroup tmr1 + * @brief Defines the TMR1 prescaled clock frequency in hertz. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR1_CLOCK_FREQ (31000UL) +/** + * @ingroup tmr1 + * @brief Defines the TMR1 ticker factor for callback function call. + */ +#define TMR1_INTERRUPT_TICKER_FACTOR (5U) +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_MAX_COUNT. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_MAX_COUNT TMR1_MAX_COUNT +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_CLOCK_FREQ. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_CLOCK_FREQ TMR1_CLOCK_FREQ +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_Initialize API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_Initialize TMR1_Initialize +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_Deinitialize API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_Deinitialize TMR1_Deinitialize +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_Start API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_Start TMR1_Start +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_Stop API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_Stop TMR1_Stop +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_CounterGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_CounterGet TMR1_CounterGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_CounterSet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_CounterSet TMR1_CounterSet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_PeriodSet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_PeriodSet TMR1_PeriodSet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_PeriodGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_PeriodGet TMR1_PeriodGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_MaxCountGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_MaxCountGet TMR1_MaxCountGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_Reload API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_Reload TMR1_Reload +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_GateStateGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_GateStateGet TMR1_GateStateGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_SinglePulseAcquisitionStart API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_SinglePulseAcquisitionStart TMR1_SinglePulseAcquisitionStart +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_GateCallbackRegister API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_GateCallbackRegister TMR1_GateCallbackRegister + /** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_TMRInterruptEnable API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_TMRInterruptEnable TMR1_TMRInterruptEnable +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_TMRInterruptDisable API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_TMRInterruptDisable TMR1_TMRInterruptDisable +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_OverflowCallbackRegister API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_OverflowCallbackRegister TMR1_OverflowCallbackRegister + +/** + * @ingroup tmr1 + * @brief Initializes the Timer1 (TMR1) module. + * This routine must be called before any other TMR1 routines. + * @param None. + * @return None. + */ +void TMR1_Initialize(void); + +/** + * @ingroup tmr1 + * @brief Deinitializes the TMR1 to POR values. + * @param None. + * @return None. + */ +void TMR1_Deinitialize(void); + +/** + * @ingroup tmr1 + * @brief Starts the TMR1 timer. + * @pre Initialize TMR1 with TMR1_Initialize() before calling this API. + * @param None. + * @return None. + */ +void TMR1_Start(void); + +/** + * @ingroup tmr1 + * @brief Stops the TMR1 timer. + * @pre Initialize TMR1 with TMR1_Initialize() before calling this API. + * @param None. + * @return None. + */ +void TMR1_Stop(void); + +/** + * @ingroup tmr1 + * @brief Returns the current counter value. + * @pre Initialize TMR1 with TMR1_Initialize() before calling this API. + * @param None. + * @return Counter value from the TMR1 register + */ +uint16_t TMR1_CounterGet(void); + +/** + * @ingroup tmr1 + * @brief Sets the counter value. + * @pre Initialize TMR1 with TMR1_Initialize() before calling this API. + * @param timerVal - Counter value to be written to the TMR1 register + * @return None. + */ +void TMR1_CounterSet(uint16_t timerVal); + +/** + * @ingroup tmr1 + * @brief Sets the period count value for the TMR1 timer. + * The period count is calculated by subtracting the number of ticks required for the period from the maximum count. + * @param periodVal - Period value to be stored in the timer period variable + * @return None. + */ +void TMR1_PeriodSet(uint16_t periodVal); + +/** + * @ingroup tmr1 + * @brief Returns the period count value. + * @param None. + * @return Period count value + */ +uint16_t TMR1_PeriodGet(void); + +/** + * @ingroup tmr1 + * @brief Loads the period count value to the TMR1 register. + * @pre Initialize TMR1 with TMR1_Initialize() before calling this API. + * @param None. + * @return None. + */ +void TMR1_Reload(void); + +/** + * @ingroup tmr1 + * @brief Returns the TMR1 maximum count value. + * @param None. + * @return Maximum count value of the timer + */ +uint16_t TMR1_MaxCountGet(void); + +/** + * @ingroup tmr1 + * @brief Starts the single pulse acquisition in TMR1 gate operation. + * @pre Use this function only when the TMR1 gate is enabled. + * @param None. + * @return None. + */ +void TMR1_SinglePulseAcquisitionStart(void); + +/** + * @ingroup tmr1 + * @brief Returns the TMR1 gate state value. + * @pre Use this function only when the TMR1 gate is enabled. + * @param None. + * @return Gate state value + */ +uint8_t TMR1_GateStateGet(void); + +/** + * @ingroup tmr1 + * @brief Enables the TMR1 overflow interrupt. + * @param None. + * @return None. + */ +void TMR1_TMRInterruptEnable(void); + +/** + * @ingroup tmr1 + * @brief Disables the TMR1 overflow interrupt. + * @param None. + * @return None. + */ +void TMR1_TMRInterruptDisable(void); + +/** + * @ingroup tmr1 + * @brief Interrupt Service Routine (ISR) for the TMR1 overflow interrupt. + * @param None. + * @return None. + */ +void TMR1_OverflowISR(void); + +/** + * @ingroup tmr1 + * @brief Registers a callback function for the TMR1 overflow event. + * @param CallbackHandler - Address of the custom callback function + * @return None. + */ + void TMR1_OverflowCallbackRegister(void (* CallbackHandler)(void)); + +/** + * @ingroup tmr1 + * @brief Registers a callback function for the TMR1 gate event. + * @param CallbackHandler - Address of the custom callback function + * @return None. + */ + void TMR1_GateCallbackRegister(void (* CallbackHandler)(void)); + +#endif // TMR1_H \ No newline at end of file diff --git a/mcc_generated_files/timer/tmr1_deprecated.h b/mcc_generated_files/timer/tmr1_deprecated.h new file mode 100644 index 0000000..a5cdbe1 --- /dev/null +++ b/mcc_generated_files/timer/tmr1_deprecated.h @@ -0,0 +1,117 @@ +/** + * TMR1 Generated Driver API Header File + * + * @file tmr1.h + * + * @defgroup tmr1 TMR1 + * + * @brief This file contains the deprecated macros or APIs for the TMR1 driver. + * + * @version TMR1 Driver Version 4.0.0 + * + * @version Package Version 5.0.0 + */ +/* +© [2025] 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 TMR1_DEPRECATED_H +#define TMR1_DEPRECATED_H + +#warning "The tmr1_deprecated.h file contains the deprecated macros or functions. Replace the deprecated macro or functions with the recommended alternative." + +/** + * @misradeviation{@advisory,2.5} + * MCC Melody drivers provide macros that can be added to an application. + * It depends on the application whether a macro is used or not. + */ + +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_CounterGet API. + * The TMR1_Read will be deprecated in the future release. Use TMR1_CounterGet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR1_Read TMR1_CounterGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_CounterGet API. + * The TMR_SENSOR_Read will be deprecated in the future release. Use TMR_SENSOR_CounterGet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_Read TMR1_CounterGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_CounterSet API. + * The TMR1_Write will be deprecated in the future release. Use TMR1_CounterSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR1_Write TMR1_CounterSet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_CounterSet API. + * The TMR_SENSOR_Write will be deprecated in the future release. Use TMR_SENSOR_CounterSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_Write TMR1_CounterSet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_PeriodSet API. + * The TMR1_PeriodCountSet will be deprecated in the future release. Use TMR1_PeriodSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR1_PeriodCountSet TMR1_PeriodSet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_PeriodSet API. + * The TMR_SENSOR_PeriodCountSet will be deprecated in the future release. Use TMR_SENSOR_PeriodSet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_PeriodCountSet TMR1_PeriodSet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_GateStateGet API. + * The TMR1_CheckGateValueStatus will be deprecated in the future release. Use TMR1_GateStateGet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR1_CheckGateValueStatus TMR1_GateStateGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_GateStateGet API. + * The TMR_SENSOR_CheckGateValueStatus will be deprecated in the future release. Use TMR_SENSOR_GateStateGet instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_CheckGateValueStatus TMR1_GateStateGet +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_SinglePulseAcquisitionStart API. + * The TMR1_StartSinglePulseAcquisition will be deprecated in the future release. Use TMR1_SinglePulseAcquisitionStart instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR1_StartSinglePulseAcquisition TMR1_SinglePulseAcquisitionStart +/** + * @ingroup tmr1 + * @brief Defines the Custom Name for the \ref TMR1_SinglePulseAcquisitionStart API. + * The TMR_SENSOR_StartSinglePulseAcquisition will be deprecated in the future release. Use TMR_SENSOR_SinglePulseAcquisitionStart instead. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR_SENSOR_StartSinglePulseAcquisition TMR1_SinglePulseAcquisitionStart + +#endif // TMR1_DEPRECATED_H \ No newline at end of file diff --git a/mcc_generated_files/timer/tmr2.h b/mcc_generated_files/timer/tmr2.h new file mode 100644 index 0000000..22843ea --- /dev/null +++ b/mcc_generated_files/timer/tmr2.h @@ -0,0 +1,248 @@ +/** + * TMR2 Generated Timer Driver API Header File + * + * @file tmr2.h + * + * @ingroup timerdriver + * + * @brief This file contains API prototypes and other data types for the TMR2 Timer driver. + * + * @version Driver Version 4.0.0 + * + * @version Package Version 5.0.0 + */ + +/* +© [2025] 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 TMR2_H +#define TMR2_H + +#include +#include +#include "timer_interface.h" + +/** + * @misradeviation{@advisory,2.5} + * MCC Melody drivers provide macros that can be added to an application. + * It depends on the application whether a macro is used or not. + */ + +/** + * @ingroup timerdriver + * @brief Defines the TMR2 maximum count value. + */ +#define TMR2_MAX_COUNT (255U) +/** + * @ingroup timerdriver + * @brief Defines the TMR2 prescaled clock frequency in hertz. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define TMR2_CLOCK_FREQ (250000UL) +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_MAX_COUNT. + */ + /* cppcheck-suppress misra-c2012-2.5 */ +#define TIMER2_MAX_COUNT TMR2_MAX_COUNT +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_CLOCK_FREQ. + */ + /* cppcheck-suppress misra-c2012-2.5 */ +#define TIMER2_CLOCK_FREQ TMR2_CLOCK_FREQ +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_Initialize API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_Initialize TMR2_Initialize +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_Deinitialize API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_Deinitialize TMR2_Deinitialize +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_Start API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_Start TMR2_Start +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_Stop API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_Stop TMR2_Stop +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_CounterGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_CounterGet TMR2_CounterGet +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_CounterSet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_CounterSet TMR2_CounterSet +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_PeriodSet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_PeriodSet TMR2_PeriodSet +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_PeriodGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_PeriodGet TMR2_PeriodGet +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_MaxCountGet API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_MaxCountGet TMR2_MaxCountGet +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_PeriodMatchCallbackRegister API. + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_PeriodMatchCallbackRegister TMR2_PeriodMatchCallbackRegister +/** + * @ingroup timerdriver + * @brief Defines the Custom Name for the \ref TMR2_ISR API + */ +/* cppcheck-suppress misra-c2012-2.5 */ +#define Timer2_ISR TMR2_ISR + +/** + @ingroup timerdriver + @struct TIMER_INTERFACE + @brief This is an instance of TIMER_INTERFACE for the TMR2 module. + */ +extern const struct TIMER_INTERFACE Timer2; + +/** + * Section: TMR2 APIs + */ + +/** + * @ingroup timerdriver + * @brief Initializes the Timer2 (TMR2) module. + * This routine must be called before any other TMR2 routines. + * @param None. + * @return None. + */ +void TMR2_Initialize(void); + +/** + * @ingroup timerdriver + * @brief Deinitializes the TMR2 to Power-on Reset (POR) values. + * @param None. + * @return None. + */ +void TMR2_Deinitialize(void); + +/** + * @ingroup timerdriver + * @brief Starts the TMR2 timer. + * @pre Initialize TMR2 with TMR2_Initialize() before calling this API. + * @param None. + * @return None. + */ +void TMR2_Start(void); + +/** + * @ingroup timerdriver + * @brief Stops the TMR2 timer. + * @pre Initialize TMR2 with TMR2_Initialize() before calling this API. + * @param None. + * @return None. + */ +void TMR2_Stop(void); + +/** + * @ingroup timerdriver + * @brief Returns the current counter value. + * @pre Initialize TMR2 with TMR2_Initialize() before calling this API. + * @param None. + * @return Counter value from the T2TMR register + */ +uint32_t TMR2_CounterGet(void); + +/** + * @ingroup timerdriver + * @brief Sets the counter value. + * @pre Initialize TMR2 with TMR2_Initialize() before calling this API. + * @param count - Counter value to be written to the T2TMR register + * @return None. + */ +void TMR2_CounterSet(uint32_t count); + +/** + * @ingroup timerdriver + * @brief Sets the period count value. + * @pre Initialize TMR2 with TMR2_Initialize() before calling this API. + * @param periodVal - Period count value to be written to the T2PR register + * @return None. + */ +void TMR2_PeriodSet(uint32_t periodVal); + +/** + * @ingroup timerdriver + * @brief Returns the current period value. + * @pre Initialize TMR2 with TMR2_Initialize() before calling this API. + * @param None. + * @return Period count value + */ +uint32_t TMR2_PeriodGet(void); + +/** + * @ingroup timerdriver + * @brief Returns the maximum count value of the timer. + * @param None. + * @return Maximum count value of the timer + */ +uint32_t TMR2_MaxCountGet(void); + +/** + * @ingroup timerdriver + * @brief Interrupt Service Routine (ISR) for the TMR2 period match event. + * @param None. + * @return None. + */ +void TMR2_ISR(void); + +/** + * @ingroup timerdriver + * @brief Registers a callback function for the TMR2 period match event. + * @param CallbackHandler - Address of the custom callback function + * @return None. + */ +void TMR2_PeriodMatchCallbackRegister(void (* callbackHandler)(void)); + +#endif // TMR2_H +/** + End of File +*/ diff --git a/mcc_generated_files/uart/eusart1.h b/mcc_generated_files/uart/eusart1.h new file mode 100644 index 0000000..d639c53 --- /dev/null +++ b/mcc_generated_files/uart/eusart1.h @@ -0,0 +1,305 @@ +/** + * EUSART1 Generated Driver API Header File + * + * @file eusart1.h + * + * @defgroup eusart1 EUSART1 + * + * @brief This file contains API prototypes and other datatypes for the Enhanced Universal Synchronous and Asynchronous Receiver Transceiver (EUSART) module. + * + * @version EUSART1 Driver Version 3.0.1 +*/ +/* +© [2025] 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 EUSART1_H +#define EUSART1_H + + +#include +#include +/** + @ingroup eusart1 + @def Standard Input Output functions + @misradeviation{@required, 21.6} This inclusion is essential for UART module to use Printf function for print the character. +*/ +/* cppcheck-suppress misra-c2012-21.6 */ +#include +#include "../system/system.h" +#include "uart_drv_interface.h" + +#ifdef __cplusplus // Provide C++ Compatibility + + extern "C" { + +#endif + + +#define UART1_interface UART1 + + +#define UART1_Initialize EUSART1_Initialize +#define UART1_Deinitialize EUSART1_Deinitialize +#define UART1_Write EUSART1_Write +#define UART1_Read EUSART1_Read +#define UART1__IsRxReady EUSART1_IsRxReady +#define UART1_IsTxReady EUSART1_IsTxReady +#define UART1_IsTxDone EUSART1_IsTxDone + +#define UART1_TransmitEnable EUSART1_TransmitEnable +#define UART1_TransmitDisable EUSART1_TransmitDisable +#define UART1_AutoBaudSet EUSART1_AutoBaudSet +#define UART1_AutoBaudQuery EUSART1_AutoBaudQuery +#define UART1_BRGCountSet (NULL) +#define UART1_BRGCountGet (NULL) +#define UART1_BaudRateSet (NULL) +#define UART1_BaudRateGet (NULL) +#define UART1__AutoBaudEventEnableGet (NULL) +#define UART1_ErrorGet EUSART1_ErrorGet + +#define UART1_TxCompleteCallbackRegister (NULL) +#define UART1_RxCompleteCallbackRegister (NULL) +#define UART1_TxCollisionCallbackRegister (NULL) +#define UART1_FramingErrorCallbackRegister EUSART1_FramingErrorCallbackRegister +#define UART1_OverrunErrorCallbackRegister EUSART1_OverrunErrorCallbackRegister +#define UART1_ParityErrorCallbackRegister (NULL) +#define UART1_EventCallbackRegister (NULL) + + +/** + @ingroup eusart1 + @struct eusart1_status_t + @brief This is a structure defined for errors in reception of data. + */ +typedef union { + struct { + uint8_t perr : 1; /** +#include +#include +#include "uart_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + Section: Data Type Definitions +*/ + +/** + @ingroup UART + @struct uart_drv_interface_t + @brief Structure containing the function pointers of UART driver. +*/ +typedef struct { +void (*Initialize)(void); +void (*Deinitialize)(void); +uint8_t (*Read)(void); +void (*Write)(uint8_t); +bool (*IsRxReady)(void); +bool (*IsTxReady)(void); +bool (*IsTxDone)(void); +void (*TransmitEnable)(void); +void (*TransmitDisable)(void); +void (*AutoBaudSet)(bool enable); +bool (*AutoBaudQuery)(void); +bool (*AutoBaudEventEnableGet)(void); +void (*BRGCountSet)(uint32_t brgValue); +uint32_t (*BRGCountGet)(void); +void (*BaudRateSet)(uint32_t baudRate); +uint32_t (*BaudRateGet)(void); +size_t (*ErrorGet)(void); +void (*TxCompleteCallbackRegister)(void (*CallbackHandler) (void)); +void (*RxCompleteCallbackRegister)(void (*CallbackHandler) (void)); +void (*TxCollisionCallbackRegister)(void (*CallbackHandler) (void)); +void (*FramingErrorCallbackRegister)(void (*CallbackHandler) (void)); +void (*OverrunErrorCallbackRegister)(void (*CallbackHandler) (void)); +void (*ParityErrorCallbackRegister)(void (*CallbackHandler) (void)); +void (*EventCallbackRegister)(void (*CallbackHandler) (void)); +}uart_drv_interface_t; + + +#ifdef __cplusplus +} +#endif + +#endif /* UART_DRV_INTERFACE_H */ + diff --git a/mcc_generated_files/uart/uart_types.h b/mcc_generated_files/uart/uart_types.h new file mode 100644 index 0000000..b0db624 --- /dev/null +++ b/mcc_generated_files/uart/uart_types.h @@ -0,0 +1,81 @@ +/** + * UART Generated Driver Interface Header File + * + * @file uart_types.h + * + * @defgroup uart_types UART_TYPES + * + * @brief This file contains the enumeration of different Universal Asynchronous Receiver and Transmitter (UART) baud rates. + * + * @version UART Driver Version 3.0.2 +*/ +/* +© [2025] 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 UART_TYPES_H +#define UART_TYPES_H + +/** + Section: Included Files +*/ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + Section: Data Type Definitions +*/ + +/** +@ingroup uartdriver +@enum UART_STANDARD_BAUDS +@brief This Enum can be used to set the UART standard +baud rates using \ref UARTx_BRGSet function e.g. \ref UART1_BRGSet. +*/ +enum UART_STANDARD_BAUDS{ +UART_110 = 0, +UART_300 = 1, +UART_600 = 2, +UART_1200 = 3, +UART_2400 = 4, +UART_4800 = 5, +UART_9600 = 6, +UART_14400 = 7, +UART_19200 = 8, +UART_38400 = 9, +UART_57600 = 10, +UART_115200 = 11, +UART_230400 = 12, +UART_460800 = 13, +UART_921600 = 14, +}; + + +#ifdef __cplusplus +} +#endif + +#endif /* UART_TYPES_H */ + diff --git a/nbproject/Makefile-default.mk b/nbproject/Makefile-default.mk new file mode 100644 index 0000000..ad4288e --- /dev/null +++ b/nbproject/Makefile-default.mk @@ -0,0 +1,366 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Include project Makefile +ifeq "${IGNORE_LOCAL}" "TRUE" +# do not include local makefile. User is passing all local related variables already +else +include Makefile +# Include makefile containing local settings +ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk" +include nbproject/Makefile-local-default.mk +endif +endif + +# Environment +MKDIR=mkdir -p +RM=rm -f +MV=mv +CP=cp + +# Macros +CND_CONF=default +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +IMAGE_TYPE=debug +OUTPUT_SUFFIX=elf +DEBUGGABLE_SUFFIX=elf +FINAL_IMAGE=${DISTDIR}/pw-module.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +else +IMAGE_TYPE=production +OUTPUT_SUFFIX=hex +DEBUGGABLE_SUFFIX=elf +FINAL_IMAGE=${DISTDIR}/pw-module.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +endif + +ifeq ($(COMPARE_BUILD), true) +COMPARISON_BUILD=-mafrlcsj +else +COMPARISON_BUILD= +endif + +# Object Directory +OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE} + +# Distribution Directory +DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE} + +# Source Files Quoted if spaced +SOURCEFILES_QUOTED_IF_SPACED=mcc_generated_files/adc/src/adc.c mcc_generated_files/pwm/src/pwm4.c mcc_generated_files/pwm/src/pwm3.c mcc_generated_files/system/src/config_bits.c mcc_generated_files/system/src/interrupt.c mcc_generated_files/system/src/pins.c mcc_generated_files/system/src/clock.c mcc_generated_files/system/src/system.c mcc_generated_files/timer/src/tmr2.c mcc_generated_files/timer/src/tmr1.c mcc_generated_files/timer/src/tmr0.c mcc_generated_files/uart/src/eusart1.c main.c proto.c + +# Object Files Quoted if spaced +OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1 ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1 ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1 ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1 ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1 ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1 ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1 ${OBJECTDIR}/mcc_generated_files/system/src/system.p1 ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1 ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1 ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1 ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/proto.p1 +POSSIBLE_DEPFILES=${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1.d ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1.d ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1.d ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1.d ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1.d ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1.d ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1.d ${OBJECTDIR}/mcc_generated_files/system/src/system.p1.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1.d ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1.d ${OBJECTDIR}/main.p1.d ${OBJECTDIR}/proto.p1.d + +# Object Files +OBJECTFILES=${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1 ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1 ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1 ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1 ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1 ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1 ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1 ${OBJECTDIR}/mcc_generated_files/system/src/system.p1 ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1 ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1 ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1 ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/proto.p1 + +# Source Files +SOURCEFILES=mcc_generated_files/adc/src/adc.c mcc_generated_files/pwm/src/pwm4.c mcc_generated_files/pwm/src/pwm3.c mcc_generated_files/system/src/config_bits.c mcc_generated_files/system/src/interrupt.c mcc_generated_files/system/src/pins.c mcc_generated_files/system/src/clock.c mcc_generated_files/system/src/system.c mcc_generated_files/timer/src/tmr2.c mcc_generated_files/timer/src/tmr1.c mcc_generated_files/timer/src/tmr0.c mcc_generated_files/uart/src/eusart1.c main.c proto.c + + + +CFLAGS= +ASFLAGS= +LDLIBSOPTIONS= + +############# Tool locations ########################################## +# If you copy a project from one host to another, the path where the # +# compiler is installed may be different. # +# If you open this project with MPLAB X in the new host, this # +# makefile will be regenerated and the paths will be corrected. # +####################################################################### +# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build +FIXDEPS=fixDeps + +.build-conf: ${BUILD_SUBPROJECTS} +ifneq ($(INFORMATION_MESSAGE), ) + @echo $(INFORMATION_MESSAGE) +endif + ${MAKE} -f nbproject/Makefile-default.mk ${DISTDIR}/pw-module.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} + +MP_PROCESSOR_OPTION=16F15323 +# ------------------------------------------------------------------------------------ +# Rules for buildStep: compile +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1: mcc_generated_files/adc/src/adc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/adc/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1 mcc_generated_files/adc/src/adc.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.d ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1: mcc_generated_files/pwm/src/pwm4.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/pwm/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1 mcc_generated_files/pwm/src/pwm4.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.d ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1: mcc_generated_files/pwm/src/pwm3.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/pwm/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1 mcc_generated_files/pwm/src/pwm3.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.d ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1: mcc_generated_files/system/src/config_bits.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1 mcc_generated_files/system/src/config_bits.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.d ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1: mcc_generated_files/system/src/interrupt.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1 mcc_generated_files/system/src/interrupt.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.d ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/pins.p1: mcc_generated_files/system/src/pins.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1 mcc_generated_files/system/src/pins.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/pins.d ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/clock.p1: mcc_generated_files/system/src/clock.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1 mcc_generated_files/system/src/clock.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/clock.d ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/system.p1: mcc_generated_files/system/src/system.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/system.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/system.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/system.p1 mcc_generated_files/system/src/system.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/system.d ${OBJECTDIR}/mcc_generated_files/system/src/system.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/system.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1: mcc_generated_files/timer/src/tmr2.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/timer/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1 mcc_generated_files/timer/src/tmr2.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1: mcc_generated_files/timer/src/tmr1.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/timer/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1 mcc_generated_files/timer/src/tmr1.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1: mcc_generated_files/timer/src/tmr0.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/timer/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1 mcc_generated_files/timer/src/tmr0.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1: mcc_generated_files/uart/src/eusart1.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/uart/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1 mcc_generated_files/uart/src/eusart1.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.d ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/main.p1.d + @${RM} ${OBJECTDIR}/main.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/main.p1 main.c + @-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d + @${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/proto.p1: proto.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/proto.p1.d + @${RM} ${OBJECTDIR}/proto.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=pickit3 -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/proto.p1 proto.c + @-${MV} ${OBJECTDIR}/proto.d ${OBJECTDIR}/proto.p1.d + @${FIXDEPS} ${OBJECTDIR}/proto.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +else +${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1: mcc_generated_files/adc/src/adc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/adc/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1 mcc_generated_files/adc/src/adc.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.d ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/adc/src/adc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1: mcc_generated_files/pwm/src/pwm4.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/pwm/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1 mcc_generated_files/pwm/src/pwm4.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.d ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm4.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1: mcc_generated_files/pwm/src/pwm3.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/pwm/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1 mcc_generated_files/pwm/src/pwm3.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.d ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/pwm/src/pwm3.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1: mcc_generated_files/system/src/config_bits.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1 mcc_generated_files/system/src/config_bits.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.d ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/config_bits.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1: mcc_generated_files/system/src/interrupt.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1 mcc_generated_files/system/src/interrupt.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.d ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/interrupt.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/pins.p1: mcc_generated_files/system/src/pins.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1 mcc_generated_files/system/src/pins.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/pins.d ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/pins.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/clock.p1: mcc_generated_files/system/src/clock.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1 mcc_generated_files/system/src/clock.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/clock.d ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/clock.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/system/src/system.p1: mcc_generated_files/system/src/system.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/system/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/system.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/system/src/system.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/system/src/system.p1 mcc_generated_files/system/src/system.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/system/src/system.d ${OBJECTDIR}/mcc_generated_files/system/src/system.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/system/src/system.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1: mcc_generated_files/timer/src/tmr2.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/timer/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1 mcc_generated_files/timer/src/tmr2.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr2.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1: mcc_generated_files/timer/src/tmr1.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/timer/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1 mcc_generated_files/timer/src/tmr1.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr1.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1: mcc_generated_files/timer/src/tmr0.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/timer/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1 mcc_generated_files/timer/src/tmr0.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.d ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/timer/src/tmr0.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1: mcc_generated_files/uart/src/eusart1.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files/uart/src" + @${RM} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1 mcc_generated_files/uart/src/eusart1.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.d ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/uart/src/eusart1.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/main.p1.d + @${RM} ${OBJECTDIR}/main.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/main.p1 main.c + @-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d + @${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/proto.p1: proto.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/proto.p1.d + @${RM} ${OBJECTDIR}/proto.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -o ${OBJECTDIR}/proto.p1 proto.c + @-${MV} ${OBJECTDIR}/proto.d ${OBJECTDIR}/proto.p1.d + @${FIXDEPS} ${OBJECTDIR}/proto.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: assemble +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +else +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: assembleWithPreprocess +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +else +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: link +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +${DISTDIR}/pw-module.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${DISTDIR} + ${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=${DISTDIR}/pw-module.X.${IMAGE_TYPE}.map -D__DEBUG=1 -mdebugger=pickit3 -DXPRJ_default=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="${DFP_DIR}/xc8" $(COMPARISON_BUILD) -Wl,--memorysummary,${DISTDIR}/memoryfile.xml -o ${DISTDIR}/pw-module.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} + @${RM} ${DISTDIR}/pw-module.X.${IMAGE_TYPE}.hex + + +else +${DISTDIR}/pw-module.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${DISTDIR} + ${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=${DISTDIR}/pw-module.X.${IMAGE_TYPE}.map -DXPRJ_default=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="${DFP_DIR}/xc8" $(COMPARISON_BUILD) -Wl,--memorysummary,${DISTDIR}/memoryfile.xml -o ${DISTDIR}/pw-module.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} + + +endif + + +# Subprojects +.build-subprojects: + + +# Subprojects +.clean-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r ${OBJECTDIR} + ${RM} -r ${DISTDIR} + +# Enable dependency checking +.dep.inc: .depcheck-impl + +DEPFILES=$(wildcard ${POSSIBLE_DEPFILES}) +ifneq (${DEPFILES},) +include ${DEPFILES} +endif diff --git a/nbproject/Makefile-genesis.properties b/nbproject/Makefile-genesis.properties new file mode 100644 index 0000000..43ed06a --- /dev/null +++ b/nbproject/Makefile-genesis.properties @@ -0,0 +1,7 @@ +# +#Thu Jan 30 19:56:07 EST 2025 +proj.dir=/home/lefake/NAS/1 - Personnal/1 - Projects/plant_watcher/pw-module.X +host.id=8fas-8km +configurations-xml=caddf42f6f07381d97d80261a255c941 +com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=f612087c95360c842296d189edfe3321 +host.platform=linux diff --git a/nbproject/Makefile-impl.mk b/nbproject/Makefile-impl.mk new file mode 100644 index 0000000..ce3999d --- /dev/null +++ b/nbproject/Makefile-impl.mk @@ -0,0 +1,69 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a pre- and a post- target defined where you can add customization code. +# +# This makefile implements macros and targets common to all configurations. +# +# NOCDDL + + +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf +# and .clean-reqprojects-conf unless SUB has the value 'no' +SUB_no=NO +SUBPROJECTS=${SUB_${SUB}} +BUILD_SUBPROJECTS_=.build-subprojects +BUILD_SUBPROJECTS_NO= +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} +CLEAN_SUBPROJECTS_=.clean-subprojects +CLEAN_SUBPROJECTS_NO= +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} + + +# Project Name +PROJECTNAME=pw-module.X + +# Active Configuration +DEFAULTCONF=default +CONF=${DEFAULTCONF} + +# All Configurations +ALLCONFS=default + + +# build +.build-impl: .build-pre + ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf + + +# clean +.clean-impl: .clean-pre + ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf + +# clobber +.clobber-impl: .clobber-pre .depcheck-impl + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean + + + +# all +.all-impl: .all-pre .depcheck-impl + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build + + + +# dependency checking support +.depcheck-impl: +# @echo "# This code depends on make tool being used" >.dep.inc +# @if [ -n "${MAKE_VERSION}" ]; then \ +# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ +# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ +# echo "include \$${DEPFILES}" >>.dep.inc; \ +# echo "endif" >>.dep.inc; \ +# else \ +# echo ".KEEP_STATE:" >>.dep.inc; \ +# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ +# fi diff --git a/nbproject/Makefile-local-default.mk b/nbproject/Makefile-local-default.mk new file mode 100644 index 0000000..ef2480a --- /dev/null +++ b/nbproject/Makefile-local-default.mk @@ -0,0 +1,36 @@ +# +# Generated Makefile - do not edit! +# +# +# This file contains information about the location of compilers and other tools. +# If you commmit this file into your revision control server, you will be able to +# to checkout the project and build it from the command line with make. However, +# if more than one person works on the same project, then this file might show +# conflicts since different users are bound to have compilers in different places. +# In that case you might choose to not commit this file and let MPLAB X recreate this file +# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at +# least once so the file gets created and the project can be built. Finally, you can also +# avoid using this file at all if you are only building from the command line with make. +# You can invoke make with the values of the macros: +# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ... +# +PATH_TO_IDE_BIN=/opt/microchip/mplabx/v6.20/mplab_platform/platform/../mplab_ide/modules/../../bin/ +# Adding MPLAB X bin directory to path. +PATH:=/opt/microchip/mplabx/v6.20/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH) +# Path to java used to run MPLAB X when this makefile was created +MP_JAVA_PATH="/usr/lib/jvm/java-8-openjdk/jre/bin/" +OS_CURRENT="$(shell uname -s)" +MP_CC="/opt/microchip/xc8/v2.45/bin/xc8-cc" +# MP_CPPC is not defined +# MP_BC is not defined +MP_AS="/opt/microchip/xc8/v2.45/bin/xc8-cc" +MP_LD="/opt/microchip/xc8/v2.45/bin/xc8-cc" +MP_AR="/opt/microchip/xc8/v2.45/bin/xc8-ar" +DEP_GEN=${MP_JAVA_PATH}java -jar "/opt/microchip/mplabx/v6.20/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar" +MP_CC_DIR="/opt/microchip/xc8/v2.45/bin" +# MP_CPPC_DIR is not defined +# MP_BC_DIR is not defined +MP_AS_DIR="/opt/microchip/xc8/v2.45/bin" +MP_LD_DIR="/opt/microchip/xc8/v2.45/bin" +MP_AR_DIR="/opt/microchip/xc8/v2.45/bin" +DFP_DIR=/opt/microchip/mplabx/v6.20/packs/Microchip/PIC16F1xxxx_DFP/1.24.387 diff --git a/nbproject/Makefile-variables.mk b/nbproject/Makefile-variables.mk new file mode 100644 index 0000000..9194936 --- /dev/null +++ b/nbproject/Makefile-variables.mk @@ -0,0 +1,10 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +CND_BASEDIR=`pwd` +# default configuration +CND_ARTIFACT_DIR_default=dist/default/production +CND_ARTIFACT_NAME_default=pw-module.X.production.hex +CND_ARTIFACT_PATH_default=dist/default/production/pw-module.X.production.hex diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml new file mode 100644 index 0000000..e60d43c --- /dev/null +++ b/nbproject/configurations.xml @@ -0,0 +1,1289 @@ + + + + + + + mcc_generated_files/adc/adc.h + + + mcc_generated_files/pwm/pwm3.h + mcc_generated_files/pwm/pwm4.h + + + mcc_generated_files/system/interrupt.h + mcc_generated_files/system/system.h + mcc_generated_files/system/clock.h + mcc_generated_files/system/pins.h + mcc_generated_files/system/config_bits.h + + + mcc_generated_files/timer/tmr2.h + mcc_generated_files/timer/timer_interface.h + mcc_generated_files/timer/tmr0.h + mcc_generated_files/timer/tmr1.h + mcc_generated_files/timer/tmr1_deprecated.h + mcc_generated_files/timer/tmr0_deprecated.h + + + mcc_generated_files/uart/eusart1.h + mcc_generated_files/uart/uart_drv_interface.h + mcc_generated_files/uart/uart_types.h + + + commons.h + proto.h + + + Makefile + test_pcb.mc3 + + + + + + + + mcc_generated_files/adc/src/adc.c + + + + + mcc_generated_files/pwm/src/pwm4.c + mcc_generated_files/pwm/src/pwm3.c + + + + + mcc_generated_files/system/src/config_bits.c + mcc_generated_files/system/src/interrupt.c + mcc_generated_files/system/src/pins.c + mcc_generated_files/system/src/clock.c + mcc_generated_files/system/src/system.c + + + + + mcc_generated_files/timer/src/tmr2.c + mcc_generated_files/timer/src/tmr1.c + mcc_generated_files/timer/src/tmr0.c + + + + + mcc_generated_files/uart/src/eusart1.c + + + + main.c + proto.c + + + + rs485 + + Makefile + + + + localhost + PIC16F15323 + + + PICkit3PlatformTool + XC8 + 2.45 + 2 + + + + + + + + + + + + + + + false + false + + + + + + + false + false + + false + + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/private/SuppressibleMessageMemo.properties b/nbproject/private/SuppressibleMessageMemo.properties new file mode 100644 index 0000000..b90c27e --- /dev/null +++ b/nbproject/private/SuppressibleMessageMemo.properties @@ -0,0 +1,3 @@ +# +#Wed Jan 08 19:58:57 EST 2025 +pk3/CHECK_4_HIGH_VOLTAGE_VPP=true diff --git a/nbproject/private/configurations.xml b/nbproject/private/configurations.xml new file mode 100644 index 0000000..b48a6ab --- /dev/null +++ b/nbproject/private/configurations.xml @@ -0,0 +1,25 @@ + + + Makefile + 0 + + + :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>900A:=<rev>0002:=<man>Microchip Technology Inc.:=<prod>PICkit 3:=<sn>BUR161106801:=<drv>x:=<xpt>h:=end + /opt/microchip/xc8/v2.45/bin + + place holder 1 + place holder 2 + + + + + true + 0 + 0 + 0 + + + + + + diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..284eeec --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..f5d5357 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,25 @@ + + + com.microchip.mplab.nbide.embedded.makeproject + + + pw-module + 2c68de8c-e52b-42d8-bfeb-6a9e2be937ac + 0 + ISO-8859-1 + + + rs485 + + + + default + 2 + + + + false + + + + diff --git a/proto.c b/proto.c new file mode 100644 index 0000000..902bbe4 --- /dev/null +++ b/proto.c @@ -0,0 +1,281 @@ +#include "commons.h" +#include "proto.h" + +#ifdef IS_MASTER +#include +#else +#include "mcc_generated_files/system/system.h" +#endif + +static uint8_t in_index; +static bool is_started = false; +static bool led_set = false; +static bool sensor_set = false; +static bool error_set = false; +static bool next_in_should_be_end = false; + +#ifndef IS_MASTER +extern bool tx_timed_out; +#endif + + +//============================================================================== +// Private Declarations +//============================================================================== + +//============================================================================== +// Public +//============================================================================== +/*=****************************************************************************/ +bool byte_in (uint8_t in, uint8_t* p_cmd, uint8_t* p_id, uint16_t* p_led1, + uint16_t* p_led2, uint16_t* p_sensor, errors_t* p_error) +{ + if (!is_started) + { + if (in == START_DEL) + { + // Start at 1 since this 'in' is now useless + in_index = 1; + is_started = true; + next_in_should_be_end = false; + } + } + else + { + if (ID_INDEX == in_index) + { +#ifdef MASTER_ID + // Don't bother with messages not meant for us + if (MY_ID != in) + { + is_started = false; + return false; + } +#else + // Test if in valid in slave list + *p_id = in; +#endif + } + + // If should be done + if (next_in_should_be_end) + { + is_started = false; + return in == END_DEL; + } + + // Save command for when finished + if (CMD_INDEX == in_index) + { +#ifdef IS_MASTER + // Invalid inputs for MASTER + if (GET_CMD_ID == in || + SET_CMD_ID == in) + { + Serial.println("Ignored cmd"); + is_started = false; + return false; + } +#else + // Invalid inputs for SLAVE + if (ERROR_CMD_ID == in || + DATA_CMD_ID == in) + { + is_started = false; + return false; + } +#endif + *p_cmd = in; + if (GET_CMD_ID == in) + next_in_should_be_end = true; + } + else if (in_index > CMD_INDEX) + { + switch (*p_cmd) + { + case GET_CMD_ID: + // Do nothing + break; + case SET_CMD_ID: + // LED1 + if (LED1_INDEX == in_index) + *p_led1 = in << 8; + else if (LED1_INDEX + 1 == in_index) + *p_led1 |= in; + // LED2 + else if (LED2_INDEX == in_index) + *p_led2 = in << 8; + else if (LED2_INDEX + 1 == in_index) + { + *p_led2 |= in; + next_in_should_be_end = true; + led_set = true; + } + + break; + case DATA_CMD_ID: + if (SENSOR_INDEX == in_index) + *p_sensor = in << 8; + else if (SENSOR_INDEX + 1 == in_index) + { + *p_sensor |= in; + next_in_should_be_end = true; + sensor_set = true; + } + + break; + case ERROR_CMD_ID: + if (ERR_INDEX == in_index) + { + *p_error = (errors_t) in; + next_in_should_be_end = true; + error_set = true; + } + + break; + default: + is_started = false; + break; + } + } + + ++in_index; + } + + return false; +} + +#ifdef IS_MASTER +/*=****************************************************************************/ +errors_t send_get (uint8_t peer_id) +{ + SET_WRITE(); + + errors_t ret = uart_tx_byte(START_DEL); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(peer_id); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(GET_CMD_ID); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(END_DEL); + + Serial2.flush(); + + SET_READ(); + return ret; +} + +/*=****************************************************************************/ +errors_t send_set (uint8_t peer_id, uint16_t led1, uint16_t led2) +{ + SET_WRITE(); + + errors_t ret = uart_tx_byte(START_DEL); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(peer_id); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(SET_CMD_ID); + + // LED1 + if (RET_SUCCESS(ret)) ret = uart_tx_byte((led1 >> 8) & 0xFF); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(led1 & 0xFF); + + // LED2 + if (RET_SUCCESS(ret)) ret = uart_tx_byte((led2 >> 8) & 0xFF); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(led2 & 0xFF); + + if (RET_SUCCESS(ret)) ret = uart_tx_byte(END_DEL); + + Serial2.flush(); + + SET_READ(); + return ret; +} + +#else + +/*=****************************************************************************/ +errors_t send_data (uint8_t peer_id, uint16_t sensor) +{ + SET_WRITE(); + + errors_t ret = uart_tx_byte(START_DEL); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(peer_id); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(DATA_CMD_ID); + + if (RET_SUCCESS(ret)) ret = uart_tx_byte((sensor >> 8) & 0xFF); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(sensor & 0xFF); + + if (RET_SUCCESS(ret)) ret = uart_tx_byte(END_DEL); + + SET_READ(); + return ret; +} + +/*=****************************************************************************/ +errors_t send_error (uint8_t peer_id, errors_t err) +{ + SET_WRITE(); + + errors_t ret = uart_tx_byte(START_DEL); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(peer_id); + if (RET_SUCCESS(ret)) ret = uart_tx_byte(ERROR_CMD_ID); + + if (RET_SUCCESS(ret)) ret = uart_tx_byte(err); + + if (RET_SUCCESS(ret)) ret = uart_tx_byte(END_DEL); + + SET_READ(); + return ret; +} +#endif + +/*=****************************************************************************/ +errors_t uart_rx_byte (uint8_t* p_byte) +{ + SET_READ(); + +#ifdef IS_MASTER + if (Serial2.available() > 0) + *p_byte = Serial2.read(); + else + return NO_RX; +#else + if(UART1.IsRxReady()) + *p_byte = UART1.Read(); + else + return NO_RX; +#endif + + return SUCCESS; +} + +/*=****************************************************************************/ +errors_t uart_tx_byte (uint8_t byte) +{ +#ifdef IS_MASTER +#ifdef DEBUG + Serial.print(byte, HEX); + Serial.print(' '); +#else + Serial2.write(byte); +#endif +#else + tx_timed_out = false; + TMR_TX_Write(0); + TMR_TX_Start(); + while (!UART1.IsTxReady() && !tx_timed_out) + ; + TMR_TX_Stop(); + if (tx_timed_out) + return TX_READY_ERR; + + UART1.Write(byte); + + tx_timed_out = false; + TMR_TX_Write(0); + TMR_TX_Start(); + while (!UART1.IsTxDone() && !tx_timed_out) + ; + TMR_TX_Stop(); + if (tx_timed_out) + return TX_DONE_ERR; +#endif + + return SUCCESS; +} \ No newline at end of file diff --git a/proto.h b/proto.h new file mode 100644 index 0000000..4ed4b4b --- /dev/null +++ b/proto.h @@ -0,0 +1,43 @@ +#ifndef PROTO_H +#define PROTO_H + +#include +#include +#include "commons.h" + +#ifdef IS_MASTER +#define SET_WRITE() do{digitalWrite(RS485_RX_TX_SELECT, 1);} while(0) +#define SET_READ() do{digitalWrite(RS485_RX_TX_SELECT, 0);} while(0) +#else +#define SET_WRITE() do { RS_MODE_SetHigh();} while(0) +#define SET_READ() do { RS_MODE_SetLow();} while(0) +#endif + +/*=****************************************************************************/ +bool byte_in (uint8_t in, uint8_t* p_cmd, uint8_t* p_id, uint16_t* p_led1, + uint16_t* p_led2, uint16_t* p_sensor, errors_t* p_error); + +#ifdef IS_MASTER +/*=****************************************************************************/ +errors_t send_get (uint8_t peer_id); + +/*=****************************************************************************/ +errors_t send_set (uint8_t peer_id, uint16_t led1, uint16_t led2); + +#else + +/*=****************************************************************************/ +errors_t send_data (uint8_t peer_id, uint16_t sensor); + +/*=****************************************************************************/ +errors_t send_error (uint8_t peer_id, errors_t err); +#endif + +/*=****************************************************************************/ +errors_t uart_rx_byte (uint8_t* p_byte); + +/*=****************************************************************************/ +errors_t uart_tx_byte (uint8_t byte); + + +#endif \ No newline at end of file