Initial commit
This commit is contained in:
135
solar_panel.X/mcc_generated_files/adc.c
Normal file
135
solar_panel.X/mcc_generated_files/adc.c
Normal file
@ -0,0 +1,135 @@
|
||||
/**
|
||||
ADC Generated Driver File
|
||||
|
||||
@Company
|
||||
Microchip Technology Inc.
|
||||
|
||||
@File Name
|
||||
adc.c
|
||||
|
||||
@Summary
|
||||
This is the generated driver implementation file for the ADC driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
@Description
|
||||
This source file provides implementations for driver APIs for ADC.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Driver Version : 2.02
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
Section: Included Files
|
||||
*/
|
||||
|
||||
#include <xc.h>
|
||||
#include "adc.h"
|
||||
#include "device_config.h"
|
||||
|
||||
void (*ADC_InterruptHandler)(void);
|
||||
|
||||
/**
|
||||
Section: ADC Module APIs
|
||||
*/
|
||||
|
||||
void ADC_Initialize(void)
|
||||
{
|
||||
// set the ADC to the options selected in the User Interface
|
||||
|
||||
// VCFG1 VSS; VCFG0 VDD;
|
||||
ADCON1 = 0x00;
|
||||
|
||||
// ADFM left; ACQT 0; ADCS FOSC/2;
|
||||
ADCON2 = 0x00;
|
||||
|
||||
// ADRESL 0;
|
||||
ADRESL = 0x00;
|
||||
|
||||
// ADRESH 0;
|
||||
ADRESH = 0x00;
|
||||
|
||||
// GO_nDONE stop; ADCAL Normal_a/d_operation; ADON enabled; CHS AN0;
|
||||
ADCON0 = 0x01;
|
||||
|
||||
}
|
||||
|
||||
void ADC_SelectChannel(adc_channel_t channel)
|
||||
{
|
||||
// select the A/D channel
|
||||
ADCON0bits.CHS = channel;
|
||||
// Turn on the ADC module
|
||||
ADCON0bits.ADON = 1;
|
||||
}
|
||||
|
||||
void ADC_StartConversion(void)
|
||||
{
|
||||
// Start the conversion
|
||||
ADCON0bits.GO_nDONE = 1;
|
||||
}
|
||||
|
||||
|
||||
bool ADC_IsConversionDone(void)
|
||||
{
|
||||
// Start the conversion
|
||||
return ((bool)(!ADCON0bits.GO_nDONE));
|
||||
}
|
||||
|
||||
adc_result_t ADC_GetConversionResult(void)
|
||||
{
|
||||
// Conversion finished, return the result
|
||||
return ((adc_result_t)((ADRESH << 8) + ADRESL));
|
||||
}
|
||||
|
||||
adc_result_t ADC_GetConversion(adc_channel_t channel)
|
||||
{
|
||||
// select the A/D channel
|
||||
ADCON0bits.CHS = channel;
|
||||
|
||||
// Turn on the ADC module
|
||||
ADCON0bits.ADON = 1;
|
||||
|
||||
// Start the conversion
|
||||
ADCON0bits.GO_nDONE = 1;
|
||||
|
||||
// Wait for the conversion to finish
|
||||
while (ADCON0bits.GO_nDONE)
|
||||
{
|
||||
}
|
||||
|
||||
// Conversion finished, return the result
|
||||
return ((adc_result_t)((ADRESH << 8) + ADRESL));
|
||||
}
|
||||
|
||||
void ADC_TemperatureAcquisitionDelay(void)
|
||||
{
|
||||
__delay_us(200);
|
||||
}
|
||||
/**
|
||||
End of File
|
||||
*/
|
326
solar_panel.X/mcc_generated_files/adc.h
Normal file
326
solar_panel.X/mcc_generated_files/adc.h
Normal file
@ -0,0 +1,326 @@
|
||||
/**
|
||||
ADC Generated Driver API Header File
|
||||
|
||||
@Company
|
||||
Microchip Technology Inc.
|
||||
|
||||
@File Name
|
||||
adc.h
|
||||
|
||||
@Summary
|
||||
This is the generated header file for the ADC driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
@Description
|
||||
This header file provides APIs for driver for ADC.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Driver Version : 2.02
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef ADC_H
|
||||
#define ADC_H
|
||||
|
||||
/**
|
||||
Section: Included Files
|
||||
*/
|
||||
|
||||
#include <xc.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus // Provide C++ Compatibility
|
||||
|
||||
extern "C" {
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
Section: Data Types Definitions
|
||||
*/
|
||||
|
||||
/**
|
||||
* result size of an A/D conversion
|
||||
*/
|
||||
|
||||
typedef uint16_t adc_result_t;
|
||||
|
||||
/**
|
||||
* result type of a Double ADC conversion
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
adc_result_t adcResult1;
|
||||
adc_result_t adcResult2;
|
||||
} adc_sync_double_result_t;
|
||||
|
||||
/** ADC Channel Definition
|
||||
|
||||
@Summary
|
||||
Defines the channels available for conversion.
|
||||
|
||||
@Description
|
||||
This routine defines the channels that are available for the module to use.
|
||||
|
||||
Remarks:
|
||||
None
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
voltage = 0x5,
|
||||
current = 0x6
|
||||
} adc_channel_t;
|
||||
|
||||
/**
|
||||
Section: ADC Module APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
@Summary
|
||||
Initializes the ADC
|
||||
|
||||
@Description
|
||||
This routine initializes the Initializes the ADC.
|
||||
This routine must be called before any other ADC routine is called.
|
||||
This routine should only be called once during system initialization.
|
||||
|
||||
@Preconditions
|
||||
None
|
||||
|
||||
@Param
|
||||
None
|
||||
|
||||
@Returns
|
||||
None
|
||||
|
||||
@Comment
|
||||
|
||||
|
||||
@Example
|
||||
<code>
|
||||
uint16_t convertedValue;
|
||||
|
||||
ADC_Initialize();
|
||||
convertedValue = ADC_GetConversionResult();
|
||||
</code>
|
||||
*/
|
||||
void ADC_Initialize(void);
|
||||
|
||||
/**
|
||||
@Summary
|
||||
Allows selection of a channel for conversion
|
||||
|
||||
@Description
|
||||
This routine is used to select desired channel for conversion.
|
||||
available
|
||||
|
||||
@Preconditions
|
||||
ADC_Initialize() function should have been called before calling this function.
|
||||
|
||||
@Returns
|
||||
None
|
||||
|
||||
@Param
|
||||
Pass in required channel number
|
||||
"For available channel refer to enum under adc.h file"
|
||||
|
||||
@Example
|
||||
<code>
|
||||
uint16_t convertedValue;
|
||||
|
||||
ADC_Initialize();
|
||||
ADC_SelectChannel(AN1_Channel);
|
||||
ADC_StartConversion();
|
||||
convertedValue = ADC_GetConversionResult();
|
||||
</code>
|
||||
*/
|
||||
void ADC_SelectChannel(adc_channel_t channel);
|
||||
|
||||
/**
|
||||
@Summary
|
||||
Starts conversion
|
||||
|
||||
@Description
|
||||
This routine is used to start conversion of desired channel.
|
||||
|
||||
@Preconditions
|
||||
ADC_Initialize() function should have been called before calling this function.
|
||||
|
||||
@Returns
|
||||
None
|
||||
|
||||
@Param
|
||||
None
|
||||
|
||||
@Example
|
||||
<code>
|
||||
uint16_t convertedValue;
|
||||
|
||||
ADC_Initialize();
|
||||
ADC_StartConversion();
|
||||
convertedValue = ADC_GetConversionResult();
|
||||
</code>
|
||||
*/
|
||||
void ADC_StartConversion(void);
|
||||
|
||||
/**
|
||||
@Summary
|
||||
Returns true when the conversion is completed otherwise false.
|
||||
|
||||
@Description
|
||||
This routine is used to determine if conversion is completed.
|
||||
When conversion is complete routine returns true. It returns false otherwise.
|
||||
|
||||
@Preconditions
|
||||
ADC_Initialize() and ADC_StartConversion(void)
|
||||
function should have been called before calling this function.
|
||||
|
||||
@Returns
|
||||
true - If conversion is complete
|
||||
false - If conversion is not completed
|
||||
|
||||
@Param
|
||||
None
|
||||
|
||||
@Example
|
||||
<code>
|
||||
uint16_t convertedValue;
|
||||
|
||||
ADC_Initialize();
|
||||
ADC_StartConversion();
|
||||
|
||||
while(!ADC_IsConversionDone());
|
||||
convertedValue = ADC_GetConversionResult();
|
||||
</code>
|
||||
*/
|
||||
bool ADC_IsConversionDone(void);
|
||||
|
||||
/**
|
||||
@Summary
|
||||
Returns the ADC conversion value.
|
||||
|
||||
@Description
|
||||
This routine is used to get the analog to digital converted value. This
|
||||
routine gets converted values from the channel specified.
|
||||
|
||||
@Preconditions
|
||||
This routine returns the conversion value only after the conversion is complete.
|
||||
Completion status can be checked using
|
||||
ADC_IsConversionDone() routine.
|
||||
|
||||
@Returns
|
||||
Returns the converted value.
|
||||
|
||||
@Param
|
||||
None
|
||||
|
||||
@Example
|
||||
<code>
|
||||
uint16_t convertedValue;
|
||||
|
||||
ADC_Initialize();
|
||||
ADC_StartConversion();
|
||||
|
||||
while(ADC_IsConversionDone());
|
||||
|
||||
convertedValue = ADC_GetConversionResult();
|
||||
</code>
|
||||
*/
|
||||
adc_result_t ADC_GetConversionResult(void);
|
||||
|
||||
/**
|
||||
@Summary
|
||||
Returns the ADC conversion value
|
||||
also allows selection of a channel for conversion.
|
||||
|
||||
@Description
|
||||
This routine is used to select desired channel for conversion
|
||||
and to get the analog to digital converted value.
|
||||
|
||||
@Preconditions
|
||||
ADC_Initialize() function should have been called before calling this function.
|
||||
|
||||
@Returns
|
||||
Returns the converted value.
|
||||
|
||||
@Param
|
||||
Pass in required channel number.
|
||||
"For available channel refer to enum under adc.h file"
|
||||
|
||||
@Example
|
||||
<code>
|
||||
uint16_t convertedValue;
|
||||
|
||||
ADC_Initialize();
|
||||
|
||||
conversion = ADC_GetConversion(AN1_Channel);
|
||||
</code>
|
||||
*/
|
||||
adc_result_t ADC_GetConversion(adc_channel_t channel);
|
||||
|
||||
/**
|
||||
@Summary
|
||||
Acquisition Delay for temperature sensor
|
||||
|
||||
@Description
|
||||
This routine should be called when temperature sensor is used.
|
||||
|
||||
@Preconditions
|
||||
ADC_Initialize() function should have been called before calling this function.
|
||||
|
||||
@Returns
|
||||
None
|
||||
|
||||
@Param
|
||||
None
|
||||
|
||||
@Example
|
||||
<code>
|
||||
uint16_t convertedValue;
|
||||
|
||||
ADC_Initialize();
|
||||
ADC_StartConversion();
|
||||
ADC_temperatureAcquisitionDelay();
|
||||
convertedValue = ADC_GetConversionResult();
|
||||
</code>
|
||||
*/
|
||||
void ADC_TemperatureAcquisitionDelay(void);
|
||||
|
||||
#ifdef __cplusplus // Provide C++ Compatibility
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif //ADC_H
|
||||
/**
|
||||
End of File
|
||||
*/
|
||||
|
76
solar_panel.X/mcc_generated_files/device_config.c
Normal file
76
solar_panel.X/mcc_generated_files/device_config.c
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
@Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Source File
|
||||
|
||||
@Company:
|
||||
Microchip Technology Inc.
|
||||
|
||||
@File Name:
|
||||
mcc.c
|
||||
|
||||
@Summary:
|
||||
This is the device_config.c file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
@Description:
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
// Configuration bits: selected in the GUI
|
||||
|
||||
// CONFIG1L
|
||||
#pragma config WDT = OFF // Watchdog Timer Enable bit->WDT disabled (control is placed on SWDTEN bit)
|
||||
#pragma config STVR = ON // Stack Overflow/Underflow Reset Enable bit->Reset on stack overflow/underflow enabled
|
||||
#pragma config XINST = OFF // Extended Instruction Set Enable bit->Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
|
||||
#pragma config DEBUG = OFF // Background Debugger Enable bit->Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins
|
||||
|
||||
// CONFIG1H
|
||||
#pragma config CP0 = OFF // Code Protection bit->Program memory is not code-protected
|
||||
|
||||
// CONFIG2L
|
||||
#pragma config FOSC = HS // Oscillator Selection bits->HS oscillator
|
||||
#pragma config FOSC2 = ON // Default/Reset System Clock Select bit->Clock selected by FOSC1:FOSC0 as system clock is enabled when OSCCON<1:0> = 00
|
||||
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor enabled
|
||||
#pragma config IESO = ON // Two-Speed Start-up (Internal/External Oscillator Switchover) Control bit->Two-Speed Start-up enabled
|
||||
|
||||
// CONFIG2H
|
||||
#pragma config WDTPS = 32768 // Watchdog Timer Postscaler Select bits->1:32768
|
||||
|
||||
// CONFIG3L
|
||||
#pragma config EASHFT = ON // External Address Bus Shift Enable bit->Address shifting enabled; address on external bus is offset to start at 000000h
|
||||
#pragma config MODE = MM // External Memory Bus->Microcontroller mode, external bus disabled
|
||||
#pragma config BW = 16 // Data Bus Width Select bit->16-Bit Data Width mode
|
||||
#pragma config WAIT = OFF // External Bus Wait Enable bit->Wait states for operations on external memory bus disabled
|
||||
|
||||
// CONFIG3H
|
||||
#pragma config CCP2MX = ON // ECCP2 MUX bit->ECCP2/P2A is multiplexed with RC1
|
||||
#pragma config ECCPMX = ON // ECCP MUX bit->ECCP1 outputs (P1B/P1C) are multiplexed with RE6 and RE5; ECCP3 outputs (P3B/P3C) are multiplexed with RE4 and RE3
|
||||
#pragma config ETHLED = ON // Ethernet LED Enable bit->RA0/RA1 are multiplexed with LEDA/LEDB when Ethernet module is enabled and function as I/O when Ethernet is disabled
|
55
solar_panel.X/mcc_generated_files/device_config.h
Normal file
55
solar_panel.X/mcc_generated_files/device_config.h
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
@Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Header File
|
||||
|
||||
@Company:
|
||||
Microchip Technology Inc.
|
||||
|
||||
@File Name:
|
||||
mcc.c
|
||||
|
||||
@Summary:
|
||||
This is the device_config.h file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
@Description:
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef DEVICE_CONFIG_H
|
||||
#define DEVICE_CONFIG_H
|
||||
|
||||
#define _XTAL_FREQ 25000000
|
||||
|
||||
#endif /* DEVICE_CONFIG_H */
|
||||
/**
|
||||
End of File
|
||||
*/
|
69
solar_panel.X/mcc_generated_files/mcc.c
Normal file
69
solar_panel.X/mcc_generated_files/mcc.c
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
@Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Source File
|
||||
|
||||
@Company:
|
||||
Microchip Technology Inc.
|
||||
|
||||
@File Name:
|
||||
mcc.c
|
||||
|
||||
@Summary:
|
||||
This is the mcc.c file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
@Description:
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mcc.h"
|
||||
|
||||
|
||||
void SYSTEM_Initialize(void)
|
||||
{
|
||||
|
||||
PIN_MANAGER_Initialize();
|
||||
OSCILLATOR_Initialize();
|
||||
ADC_Initialize();
|
||||
}
|
||||
|
||||
void OSCILLATOR_Initialize(void)
|
||||
{
|
||||
// SCS Primary_OSC; OSTS intosc; IDLEN disabled;
|
||||
OSCCON = 0x02;
|
||||
// PLLEN disabled; PPST0 disabled; PPRE divide_by_3; PPST1 divide_by_3;
|
||||
OSCTUNE = 0x00;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
End of File
|
||||
*/
|
88
solar_panel.X/mcc_generated_files/mcc.h
Normal file
88
solar_panel.X/mcc_generated_files/mcc.h
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
@Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Header File
|
||||
|
||||
@Company:
|
||||
Microchip Technology Inc.
|
||||
|
||||
@File Name:
|
||||
mcc.h
|
||||
|
||||
@Summary:
|
||||
This is the mcc.h file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
@Description:
|
||||
This header file provides implementations for driver APIs for all modules selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Driver Version : 2.00
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above or later
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MCC_H
|
||||
#define MCC_H
|
||||
#include <xc.h>
|
||||
#include "device_config.h"
|
||||
#include "pin_manager.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <conio.h>
|
||||
#include "adc.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
none
|
||||
* @Description
|
||||
Initializes the device to the default states configured in the
|
||||
* MCC GUI
|
||||
* @Example
|
||||
SYSTEM_Initialize(void);
|
||||
*/
|
||||
void SYSTEM_Initialize(void);
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
none
|
||||
* @Description
|
||||
Initializes the oscillator to the default states configured in the
|
||||
* MCC GUI
|
||||
* @Example
|
||||
OSCILLATOR_Initialize(void);
|
||||
*/
|
||||
void OSCILLATOR_Initialize(void);
|
||||
|
||||
#endif /* MCC_H */
|
||||
/**
|
||||
End of File
|
||||
*/
|
97
solar_panel.X/mcc_generated_files/pin_manager.c
Normal file
97
solar_panel.X/mcc_generated_files/pin_manager.c
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
Generated Pin Manager File
|
||||
|
||||
Company:
|
||||
Microchip Technology Inc.
|
||||
|
||||
File Name:
|
||||
pin_manager.c
|
||||
|
||||
Summary:
|
||||
This is the Pin Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
Description:
|
||||
This header file provides implementations for pin APIs for all pins selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Driver Version : 2.0
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
MPLAB : MPLAB X 6.00
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "pin_manager.h"
|
||||
|
||||
|
||||
void PIN_MANAGER_Initialize(void)
|
||||
{
|
||||
/**
|
||||
LATx registers
|
||||
*/
|
||||
LATE = 0x00;
|
||||
LATJ = 0x00;
|
||||
LATD = 0x00;
|
||||
LATA = 0x00;
|
||||
LATF = 0x00;
|
||||
LATB = 0x00;
|
||||
LATG = 0x00;
|
||||
LATC = 0x00;
|
||||
LATH = 0x00;
|
||||
|
||||
/**
|
||||
TRISx registers
|
||||
*/
|
||||
TRISE = 0xFF;
|
||||
TRISF = 0xFF;
|
||||
TRISA = 0x3F;
|
||||
TRISG = 0xFF;
|
||||
TRISB = 0xFF;
|
||||
TRISH = 0xFF;
|
||||
TRISC = 0xFF;
|
||||
TRISD = 0xFF;
|
||||
TRISJ = 0xFF;
|
||||
|
||||
/**
|
||||
PCFG setting
|
||||
*/
|
||||
ADCON1bits.PCFG = 0x00;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void PIN_MANAGER_IOC(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
End of File
|
||||
*/
|
128
solar_panel.X/mcc_generated_files/pin_manager.h
Normal file
128
solar_panel.X/mcc_generated_files/pin_manager.h
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
@Generated Pin Manager Header File
|
||||
|
||||
@Company:
|
||||
Microchip Technology Inc.
|
||||
|
||||
@File Name:
|
||||
pin_manager.h
|
||||
|
||||
@Summary:
|
||||
This is the Pin Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
|
||||
|
||||
@Description:
|
||||
This header file provides implementations for pin APIs for all pins selected in the GUI.
|
||||
Generation Information :
|
||||
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
|
||||
Device : PIC18F97J60
|
||||
Version : 2.0
|
||||
The generated drivers are tested against the following:
|
||||
Compiler : XC8 2.36 and above
|
||||
MPLAB : MPLAB X 6.00
|
||||
|
||||
Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
(c) 2018 Microchip Technology Inc. and its subsidiaries.
|
||||
|
||||
Subject to your compliance with these terms, you may use Microchip software and any
|
||||
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
|
||||
license terms applicable to your use of third party software (including open source software) that
|
||||
may accompany Microchip software.
|
||||
|
||||
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
|
||||
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
|
||||
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
|
||||
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
|
||||
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PIN_MANAGER_H
|
||||
#define PIN_MANAGER_H
|
||||
|
||||
/**
|
||||
Section: Included Files
|
||||
*/
|
||||
|
||||
#include <xc.h>
|
||||
|
||||
#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 voltage aliases
|
||||
#define voltage_TRIS TRISFbits.TRISF0
|
||||
#define voltage_LAT LATFbits.LATF0
|
||||
#define voltage_PORT PORTFbits.RF0
|
||||
#define voltage_ANS anselRF0bits.anselRF0
|
||||
#define voltage_SetHigh() do { LATFbits.LATF0 = 1; } while(0)
|
||||
#define voltage_SetLow() do { LATFbits.LATF0 = 0; } while(0)
|
||||
#define voltage_Toggle() do { LATFbits.LATF0 = ~LATFbits.LATF0; } while(0)
|
||||
#define voltage_GetValue() PORTFbits.RF0
|
||||
#define voltage_SetDigitalInput() do { TRISFbits.TRISF0 = 1; } while(0)
|
||||
#define voltage_SetDigitalOutput() do { TRISFbits.TRISF0 = 0; } while(0)
|
||||
#define voltage_SetAnalogMode() do { anselRF0bits.anselRF0 = 1; } while(0)
|
||||
#define voltage_SetDigitalMode() do { anselRF0bits.anselRF0 = 0; } while(0)
|
||||
|
||||
// get/set current aliases
|
||||
#define current_TRIS TRISFbits.TRISF1
|
||||
#define current_LAT LATFbits.LATF1
|
||||
#define current_PORT PORTFbits.RF1
|
||||
#define current_ANS anselRF1bits.anselRF1
|
||||
#define current_SetHigh() do { LATFbits.LATF1 = 1; } while(0)
|
||||
#define current_SetLow() do { LATFbits.LATF1 = 0; } while(0)
|
||||
#define current_Toggle() do { LATFbits.LATF1 = ~LATFbits.LATF1; } while(0)
|
||||
#define current_GetValue() PORTFbits.RF1
|
||||
#define current_SetDigitalInput() do { TRISFbits.TRISF1 = 1; } while(0)
|
||||
#define current_SetDigitalOutput() do { TRISFbits.TRISF1 = 0; } while(0)
|
||||
#define current_SetAnalogMode() do { anselRF1bits.anselRF1 = 1; } while(0)
|
||||
#define current_SetDigitalMode() do { anselRF1bits.anselRF1 = 0; } while(0)
|
||||
|
||||
|
||||
/**
|
||||
@Param
|
||||
none
|
||||
@Returns
|
||||
none
|
||||
@Description
|
||||
GPIO and peripheral I/O initialization
|
||||
@Example
|
||||
PIN_MANAGER_Initialize();
|
||||
*/
|
||||
void PIN_MANAGER_Initialize (void);
|
||||
|
||||
/**
|
||||
* @Param
|
||||
none
|
||||
* @Returns
|
||||
none
|
||||
* @Description
|
||||
Interrupt on Change Handling routine
|
||||
* @Example
|
||||
PIN_MANAGER_IOC();
|
||||
*/
|
||||
void PIN_MANAGER_IOC(void);
|
||||
|
||||
|
||||
|
||||
#endif // PIN_MANAGER_H
|
||||
/**
|
||||
End of File
|
||||
*/
|
Reference in New Issue
Block a user