From c3767ac0c6bcb9a1aed1e7b666061f829a371e1f Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 4 May 2018 00:16:36 +0200 Subject: Start own HAL implementation based on MCC's generated files Other changes: - Undo conversion of MCC files to C++ - Delete old Led implementation --- Led.cpp | 34 -- Led.hpp | 34 -- hal/pin.hpp | 23 ++ hal/pin.tpp | 30 ++ hal/uart.hpp | 87 +++++ hal/uart1.tpp | 45 +++ main.cpp | 43 +- mcc_generated_files/interrupt_manager.c | 74 ++++ mcc_generated_files/interrupt_manager.cpp | 67 ---- mcc_generated_files/interrupt_manager.h | 86 ++++ mcc_generated_files/interrupt_manager.hpp | 78 ---- mcc_generated_files/mcc.c | 160 ++++++++ mcc_generated_files/mcc.cpp | 156 -------- mcc_generated_files/mcc.h | 143 +++++++ mcc_generated_files/mcc.hpp | 134 ------- mcc_generated_files/pin_manager.c | 138 +++++++ mcc_generated_files/pin_manager.cpp | 131 ------- mcc_generated_files/pin_manager.h | 539 ++++++++++++++++++++++++++ mcc_generated_files/pin_manager.hpp | 530 ------------------------- mcc_generated_files/uart1.c | 398 +++++++++++++++++++ mcc_generated_files/uart1.cpp | 390 ------------------- mcc_generated_files/uart1.h | 623 +++++++++++++++++++++++++++++ mcc_generated_files/uart1.hpp | 624 ------------------------------ nbproject/Makefile-default.mk | 76 ++-- nbproject/Makefile-genesis.properties | 4 +- nbproject/configurations.xml | 19 +- nbproject/project.xml | 4 +- 27 files changed, 2409 insertions(+), 2261 deletions(-) delete mode 100644 Led.cpp delete mode 100644 Led.hpp create mode 100644 hal/pin.hpp create mode 100644 hal/pin.tpp create mode 100644 hal/uart.hpp create mode 100644 hal/uart1.tpp create mode 100644 mcc_generated_files/interrupt_manager.c delete mode 100644 mcc_generated_files/interrupt_manager.cpp create mode 100644 mcc_generated_files/interrupt_manager.h delete mode 100644 mcc_generated_files/interrupt_manager.hpp create mode 100644 mcc_generated_files/mcc.c delete mode 100644 mcc_generated_files/mcc.cpp create mode 100644 mcc_generated_files/mcc.h delete mode 100644 mcc_generated_files/mcc.hpp create mode 100644 mcc_generated_files/pin_manager.c delete mode 100644 mcc_generated_files/pin_manager.cpp create mode 100644 mcc_generated_files/pin_manager.h delete mode 100644 mcc_generated_files/pin_manager.hpp create mode 100644 mcc_generated_files/uart1.c delete mode 100644 mcc_generated_files/uart1.cpp create mode 100644 mcc_generated_files/uart1.h delete mode 100644 mcc_generated_files/uart1.hpp diff --git a/Led.cpp b/Led.cpp deleted file mode 100644 index a01bb54..0000000 --- a/Led.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * File: Led.cpp - * Author: _prossn - * - * Created on 10. aprile 2018, 16:07 - */ - -#include "Led.hpp" - -Led::Led(Color color) : _color(color) -{ - -} - - -Led::~Led() -{ - -} - -Led::Color Led::color() const -{ - return _color; -} - -void Led::set(bool state) -{ - _state = state; -} - -bool Led::state() const -{ - return _state; -} diff --git a/Led.hpp b/Led.hpp deleted file mode 100644 index b082d7d..0000000 --- a/Led.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * File: Led.hpp - * Author: _prossn - * - * Created on 10. aprile 2018, 16:07 - */ - -#ifndef LED_HPP -#define LED_HPP - -#include - -class Led { -public: - enum class Color { - RED, GREEN, BLUE - }; - - Led(Color color); - Led() = delete; - virtual ~Led(); - - Color color() const; - - void set(bool status); - bool state() const; - -private: - bool _state; - Color _color; -}; - -#endif /* LED_HPP */ - diff --git a/hal/pin.hpp b/hal/pin.hpp new file mode 100644 index 0000000..9df22d4 --- /dev/null +++ b/hal/pin.hpp @@ -0,0 +1,23 @@ +/* + * File: pin.hpp + * Author: naopross + * + * Created on May 3, 2018, 8:02 PM + */ + +#ifndef PIN_HPP +#define PIN_HPP + +template +class pin { +public: + pin(reg *r); + virtual ~pin(); + + void set(bool v); + +private: + reg *_register; +}; + +#endif /* PIN_HPP */ \ No newline at end of file diff --git a/hal/pin.tpp b/hal/pin.tpp new file mode 100644 index 0000000..4f6bd4a --- /dev/null +++ b/hal/pin.tpp @@ -0,0 +1,30 @@ +/* + * File: pin.cpp + * Author: naopross + * + * Created on May 3, 2018, 8:02 PM + */ + +#include "pin.hpp" + +template +pin::pin(reg *r) +{ + _register = r; +} + + +template +pin::~pin() +{ + +} + +template +void pin::set(bool v) +{ + if (v) + *reinterpret_cast(_register) |= 1<(_register) &= ~(1< +#include +#include + +extern "C" { +void usart_1_isr(); +void usart_2_isr(); +void usart_3_isr(); +void usart_4_isr(); +} + +namespace uart +{ + const unsigned devices_count = 4; + + enum class status : unsigned int + { + rx_data_available = 1<<0, + rx_overrun_error = 1<<1, + framing_error = 1<<2, + parity_error = 1<<3, + receiver_ide = 1<<4, + tx_complete = 1<<8, + tx_full = 1<<9, + }; + + enum class transfer_status : unsigned int + { + rx_full = 1<<0, + rx_data_present = 1<<1, + rx_empty = 1<<2, + tx_full = 1<<3, + tx_empty = 1<<4, + }; + + std::string rx_buffer[devices_count]; + std::string tx_buffer[devices_count]; + + template + void initialize(); + + template + uint8_t peek(uint16_t offset); + + template + uint8_t read(void); + + template + unsigned read(uint8_t *buffer, const unsigned numbytes); + + template + void write(const uint8_t byte); + + template + unsigned write(const uint8_t *buffer, const unsigned numbytes); + + template + status status(); + + template + transfer_status tranfer_status(); + + template + unsigned rx_buffer_size(); + + template + unsigned tx_buffer_size(); + + template + bool rx_buffer_empty(); + + template + bool tx_buffer_full(); +} + +#endif /* UART_HPP */ + diff --git a/hal/uart1.tpp b/hal/uart1.tpp new file mode 100644 index 0000000..a8a32f0 --- /dev/null +++ b/hal/uart1.tpp @@ -0,0 +1,45 @@ +/* + * File: uart.cpp + * Author: naopross + * + * Created on May 2, 2018, 7:05 PM + */ + +#include "uart.hpp" + +extern "C" { +#include +#include +} + + +void __ISR(_UART_1_VECTOR, IPL1AUTO) usart_1_isr() +{ + if (IFS1bits.U1RXIF) { + uart::rx_buffer[0].push_back(static_cast(U1RXREG)); + } +} + +namespace uart +{ + template<> + void initialize<1>() + { + // STSEL 1S; IREN disabled; PDSEL 8N; RTSMD disabled; RXINV disabled; SIDL disabled; WAKE disabled; ABAUD disabled; LPBACK disabled; BRGH enabled; UEN TX_RX; ON enabled; + U1MODE = 0x8008; + // UTXISEL TX_ONE_CHAR; UTXINV disabled; ADDR 0; URXEN disabled; OERR disabled; ADM_EN disabled; URXISEL RX_ONE_CHAR; UTXBRK disabled; UTXEN disabled; ADDEN disabled; + U1STA = 0x0; + // U1TXREG 0; + U1TXREG = 0x0; + // BaudRate = 9600; Frequency = 1000000 Hz; BRG 25; + U1BRG = 0x19; + + IEC1bits.U1RXIE = 1; + + U1STAbits.UTXEN = 1; + U1STAbits.URXEN = 1; + + //Enabling UART + U1MODEbits.ON = 1; + } +} \ No newline at end of file diff --git a/main.cpp b/main.cpp index a1b4407..5347507 100644 --- a/main.cpp +++ b/main.cpp @@ -8,36 +8,29 @@ #include #include -#include "mcc_generated_files/mcc.hpp" +// #include "mcc_generated_files/mcc.h" + +#include "hal/uart1.tpp" +#include "hal/pin.tpp" + +extern "C" { + #include +} + + -/* - * - */ int main(int argc, char** argv) { - char c; - - SYSTEM_Initialize(); - - LED1_SetHigh(); - LED2_SetHigh(); - LED3_SetHigh(); - - UART1_Write('S'); - UART1_Write('\n'); - UART1_Write('\r'); + LATE = 0x0000; + TRISE = 0x002f; + CNPUE = 0x0000; + + pin led1(&LATEbits); + led1.set(1); - while (1) { - while (UART1_ReceiveBufferIsEmpty()); - - c = UART1_Read(); - LED1_Toggle(); - - UART1_Write(c); - UART1_Write('\n'); - UART1_Write('\r'); + while (true) { } - return (EXIT_SUCCESS); + return 0; } diff --git a/mcc_generated_files/interrupt_manager.c b/mcc_generated_files/interrupt_manager.c new file mode 100644 index 0000000..67c5d29 --- /dev/null +++ b/mcc_generated_files/interrupt_manager.c @@ -0,0 +1,74 @@ +/** + System Interrupts Generated Driver File + + @Company: + Microchip Technology Inc. + + @File Name: + interrupt_manager.h + + @Summary: + This is the generated driver implementation file for setting up the + interrupts using PIC32MX MCUs + + @Description: + This source file provides implementations for PIC32MX MCUs interrupts. + Generation Information : + Product Revision : PIC32MX MCUs - pic32mx : v1.35 + Device : PIC32MX470F512H + Version : 1.01 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 +*/ +/* + (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this + software and any derivatives exclusively with Microchip products. + + 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION + WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. + + 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. + + MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE + TERMS. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + Section: Includes +*/ +#include + +/** + void INTERRUPT_Initialize (void) +*/ +void INTERRUPT_Initialize (void) +{ + // UERI: UART1 Error + // Priority: 1 + // SubPriority: 0 + IPC7bits.U1IP = 1; + IPC7bits.U1IS = 0; + + // Enable the multi vector + INTCONbits.MVEC = 1; + // Enable Global Interrupts + __builtin_mtc0(12,0,(__builtin_mfc0(12,0) | 0x0001)); + +} + +#ifdef __cplusplus +} +#endif diff --git a/mcc_generated_files/interrupt_manager.cpp b/mcc_generated_files/interrupt_manager.cpp deleted file mode 100644 index 32ca3f4..0000000 --- a/mcc_generated_files/interrupt_manager.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/** - System Interrupts Generated Driver File - - @Company: - Microchip Technology Inc. - - @File Name: - interrupt_manager.h - - @Summary: - This is the generated driver implementation file for setting up the - interrupts using PIC32MX MCUs - - @Description: - This source file provides implementations for PIC32MX MCUs interrupts. - Generation Information : - Product Revision : PIC32MX MCUs - pic32mx : v1.35 - Device : PIC32MX470F512H - Version : 1.01 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 -*/ -/* - (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this - software and any derivatives exclusively with Microchip products. - - 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION - WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. - - 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. - - MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE - TERMS. -*/ - -/** - Section: Includes -*/ -#include - -/** - void INTERRUPT_Initialize (void) -*/ -void INTERRUPT_Initialize (void) -{ - // UERI: UART1 Error - // Priority: 1 - // SubPriority: 0 - IPC7bits.U1IP = 1; - IPC7bits.U1IS = 0; - - // Enable the multi vector - INTCONbits.MVEC = 1; - // Enable Global Interrupts - __builtin_mtc0(12,0,(__builtin_mfc0(12,0) | 0x0001)); - -} diff --git a/mcc_generated_files/interrupt_manager.h b/mcc_generated_files/interrupt_manager.h new file mode 100644 index 0000000..83dac16 --- /dev/null +++ b/mcc_generated_files/interrupt_manager.h @@ -0,0 +1,86 @@ +/** + System Interrupts Generated Driver File + + @Company: + Microchip Technology Inc. + + @File Name: + interrupt_manager.h + + @Summary: + This is the generated driver implementation file for setting up the + interrupts using PIC32MX MCUs + + @Description: + This source file provides implementations for PIC32MX MCUs interrupts. + Generation Information : + Product Revision : PIC32MX MCUs - pic32mx : v1.35 + Device : PIC32MX470F512H + Version : 1.01 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 +*/ +/* + (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this + software and any derivatives exclusively with Microchip products. + + 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION + WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. + + 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. + + MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE + TERMS. +*/ + +#ifndef _INTERRUPT_MANAGER_H +#define _INTERRUPT_MANAGER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + @Summary + Initializes the interrupt priorities of the PIC32MX470F512H + + @Description + This routine sets the interrupt priorities of the modules that have been configured + for the PIC32MX470F512H + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + void SYSTEM_Initialize(void) + { + // Other initializers are called from this function + INTERRUPT_Initialize (); + } + + +*/ +void INTERRUPT_Initialize(void); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/mcc_generated_files/interrupt_manager.hpp b/mcc_generated_files/interrupt_manager.hpp deleted file mode 100644 index a01aacd..0000000 --- a/mcc_generated_files/interrupt_manager.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/** - System Interrupts Generated Driver File - - @Company: - Microchip Technology Inc. - - @File Name: - interrupt_manager.h - - @Summary: - This is the generated driver implementation file for setting up the - interrupts using PIC32MX MCUs - - @Description: - This source file provides implementations for PIC32MX MCUs interrupts. - Generation Information : - Product Revision : PIC32MX MCUs - pic32mx : v1.35 - Device : PIC32MX470F512H - Version : 1.01 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 -*/ -/* - (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this - software and any derivatives exclusively with Microchip products. - - 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION - WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. - - 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. - - MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE - TERMS. -*/ - -#ifndef _INTERRUPT_MANAGER_H -#define _INTERRUPT_MANAGER_H - -/** - @Summary - Initializes the interrupt priorities of the PIC32MX470F512H - - @Description - This routine sets the interrupt priorities of the modules that have been configured - for the PIC32MX470F512H - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - void SYSTEM_Initialize(void) - { - // Other initializers are called from this function - INTERRUPT_Initialize (); - } - - -*/ -void INTERRUPT_Initialize(void); - -#endif \ No newline at end of file diff --git a/mcc_generated_files/mcc.c b/mcc_generated_files/mcc.c new file mode 100644 index 0000000..7f3a675 --- /dev/null +++ b/mcc_generated_files/mcc.c @@ -0,0 +1,160 @@ +/** + @Generated PIC32MX MCUs Source File + + @Company: + Microchip Technology Inc. + + @File Name: + mcc.c + + @Summary: + This is the mcc.c file generated using PIC32MX MCUs + + @Description: + This header file provides implementations for driver APIs for all modules selected in the GUI. + Generation Information : + Product Revision : PIC32MX MCUs - pic32mx : v1.35 + Device : PIC32MX470F512H + Driver Version : 1.02 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 +*/ + +/* + (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this + software and any derivatives exclusively with Microchip products. + + 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION + WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. + + 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. + + MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE + TERMS. +*/ + +// Configuration bits: selected in the GUI + +// DEVCFG3 +#pragma config FSRSSEL = PRIORITY_7 // Shadow Register Set Priority Select->SRS Priority 7 +#pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration->Allow only one reconfiguration +#pragma config IOL1WAY = ON // Peripheral Pin Select Configuration->Allow only one reconfiguration +#pragma config FUSBIDIO = ON // USB USID Selection->Controlled by the USB Module +#pragma config FVBUSONIO = ON // USB VBUS ON Selection->Controlled by USB Module + +// DEVCFG2 +#pragma config FPLLIDIV = DIV_12 // PLL Input Divider->12x Divider +#pragma config FPLLMUL = MUL_24 // PLL Multiplier->24x Multiplier +#pragma config UPLLIDIV = DIV_12 // USB PLL Input Divider->12x Divider +#pragma config UPLLEN = OFF // USB PLL Enable->Disabled and Bypassed +#pragma config FPLLODIV = DIV_256 // System PLL Output Clock Divider->PLL Divide by 256 + +// DEVCFG1 +#pragma config FNOSC = FRCDIV // Oscillator Selection Bits->Fast RC Osc w/Div-by-N (FRCDIV) +#pragma config FSOSCEN = ON // Secondary Oscillator Enable->Enabled +#pragma config IESO = ON // Internal/External Switch Over->Enabled +#pragma config POSCMOD = OFF // Primary Oscillator Configuration->Primary osc disabled +#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin->Disabled +#pragma config FPBDIV = DIV_8 // Peripheral Clock Divisor->Pb_Clk is Sys_Clk/8 +#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection->Clock Switch Disable, FSCM Disabled +#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler->1:1048576 +#pragma config WINDIS = OFF // Watchdog Timer Window Enable->Watchdog Timer is in Non-Window Mode +#pragma config FWDTEN = OFF // Watchdog Timer Enable->WDT Disabled (SWDTEN Bit Controls) +#pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size->Window Size is 25% + +// DEVCFG0 +#pragma config DEBUG = OFF // Background Debugger Enable->Debugger is Disabled +#pragma config JTAGEN = ON // JTAG Enable->JTAG Port Enabled +#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select->Communicate on PGEC1/PGED1 +#pragma config PWP = OFF // Program Flash Write Protect->Disable +#pragma config BWP = OFF // Boot Flash Write Protect bit->Protection Disabled +#pragma config CP = OFF // Code Protect->Protection Disabled + +#include "mcc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + @Summary + Indicates the exception cause. + + @Description + This array identifies the cause for exception. + */ + +static const char *cause[] = +{ + "Interrupt", "Undefined", "Undefined", "Undefined", + "Load/fetch address error", "Store address error", + "Instruction bus error", "Data bus error", "Syscall", + "Breakpoint", "Reserved instruction", "Coprocessor unusable", + "Arithmetic overflow", "Trap", "Reserved", "Reserved", + "Reserved", "Reserved", "Reserved" +}; + +void SYSTEM_Initialize(void) +{ + PIN_MANAGER_Initialize(); + OSCILLATOR_Initialize(); + UART1_Initialize(); + INTERRUPT_Initialize(); +} + +void SYSTEM_RegUnlock(void) +{ + SYSKEY = 0x12345678; + SYSKEY = 0xAA996655; + SYSKEY = 0x556699AA; +} + +void SYSTEM_RegLock(void) +{ + SYSKEY = 0x00000000; +} + +void OSCILLATOR_Initialize(void) +{ + SYSTEM_RegUnlock(); + // CF no clock failure; COSC FRCDIV; PLLODIV DIV_256; UFRCEN disabled; PBDIVRDY disabled; SLOCK out of lock; FRCDIV FRC/1; SLPEN Idle on WAIT instruction; NOSC FRCDIV; PLLMULT MUL_24; SOSCEN disabled; PBDIV DIV_8; CLKLOCK unlocked; OSWEN Switch is Complete; SOSCRDY disabled; + OSCCON = 0x381F7700; + SYSTEM_RegLock(); + // TUN Center Frequency; + OSCTUN = 0x0; + // DIVSWEN disabled; RSLP disabled; ACTIVE Active; ROSEL SYSCLK; OE Not Driven out on REFCLKO pin; SIDL disabled; RODIV 0; ON disabled; + REFOCON = 0x100; + // ROTRIM 0; + REFOTRIM = 0x0; +} + +void _general_exception_handler () +{ + /* Mask off the ExcCode Field from the Cause Register + Refer to the MIPs Software User's manual */ + uint8_t _excep_code; + uint8_t _excep_addr; + const uint8_t *_cause_str; + + _excep_code = (_CP0_GET_CAUSE() & 0x0000007C) >> 2; + _excep_addr = _CP0_GET_EPC(); + _cause_str = cause[_excep_code]; + + while(1) { + + } +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/mcc_generated_files/mcc.cpp b/mcc_generated_files/mcc.cpp deleted file mode 100644 index 3d34379..0000000 --- a/mcc_generated_files/mcc.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/** - @Generated PIC32MX MCUs Source File - - @Company: - Microchip Technology Inc. - - @File Name: - mcc.c - - @Summary: - This is the mcc.c file generated using PIC32MX MCUs - - @Description: - This header file provides implementations for driver APIs for all modules selected in the GUI. - Generation Information : - Product Revision : PIC32MX MCUs - pic32mx : v1.35 - Device : PIC32MX470F512H - Driver Version : 1.02 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 -*/ - -/* - (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this - software and any derivatives exclusively with Microchip products. - - 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION - WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. - - 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. - - MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE - TERMS. -*/ - -// Configuration bits: selected in the GUI - -// DEVCFG3 -#pragma config FSRSSEL = PRIORITY_7 // Shadow Register Set Priority Select->SRS Priority 7 -#pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration->Allow only one reconfiguration -#pragma config IOL1WAY = ON // Peripheral Pin Select Configuration->Allow only one reconfiguration -#pragma config FUSBIDIO = ON // USB USID Selection->Controlled by the USB Module -#pragma config FVBUSONIO = ON // USB VBUS ON Selection->Controlled by USB Module - -// DEVCFG2 -#pragma config FPLLIDIV = DIV_12 // PLL Input Divider->12x Divider -#pragma config FPLLMUL = MUL_24 // PLL Multiplier->24x Multiplier -#pragma config UPLLIDIV = DIV_12 // USB PLL Input Divider->12x Divider -#pragma config UPLLEN = OFF // USB PLL Enable->Disabled and Bypassed -#pragma config FPLLODIV = DIV_256 // System PLL Output Clock Divider->PLL Divide by 256 - -// DEVCFG1 -#pragma config FNOSC = FRCDIV // Oscillator Selection Bits->Fast RC Osc w/Div-by-N (FRCDIV) -#pragma config FSOSCEN = ON // Secondary Oscillator Enable->Enabled -#pragma config IESO = ON // Internal/External Switch Over->Enabled -#pragma config POSCMOD = OFF // Primary Oscillator Configuration->Primary osc disabled -#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin->Disabled -#pragma config FPBDIV = DIV_8 // Peripheral Clock Divisor->Pb_Clk is Sys_Clk/8 -#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection->Clock Switch Disable, FSCM Disabled -#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler->1:1048576 -#pragma config WINDIS = OFF // Watchdog Timer Window Enable->Watchdog Timer is in Non-Window Mode -#pragma config FWDTEN = OFF // Watchdog Timer Enable->WDT Disabled (SWDTEN Bit Controls) -#pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size->Window Size is 25% - -// DEVCFG0 -#pragma config DEBUG = OFF // Background Debugger Enable->Debugger is Disabled -#pragma config JTAGEN = ON // JTAG Enable->JTAG Port Enabled -#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select->Communicate on PGEC1/PGED1 -#pragma config PWP = OFF // Program Flash Write Protect->Disable -#pragma config BWP = OFF // Boot Flash Write Protect bit->Protection Disabled -#pragma config CP = OFF // Code Protect->Protection Disabled - -#include "mcc.hpp" - -/** - @Summary - Indicates the exception cause. - - @Description - This array identifies the cause for exception. - */ - -static char *cause[] = -{ - "Interrupt", "Undefined", "Undefined", "Undefined", - "Load/fetch address error", "Store address error", - "Instruction bus error", "Data bus error", "Syscall", - "Breakpoint", "Reserved instruction", "Coprocessor unusable", - "Arithmetic overflow", "Trap", "Reserved", "Reserved", - "Reserved", "Reserved", "Reserved" -}; - -void SYSTEM_Initialize(void) -{ - PIN_MANAGER_Initialize(); - OSCILLATOR_Initialize(); - UART1_Initialize(); - INTERRUPT_Initialize(); -} - -void SYSTEM_RegUnlock(void) -{ - SYSKEY = 0x12345678; - SYSKEY = 0xAA996655; - SYSKEY = 0x556699AA; -} - -void SYSTEM_RegLock(void) -{ - SYSKEY = 0x00000000; -} - -void OSCILLATOR_Initialize(void) -{ - SYSTEM_RegUnlock(); - // CF no clock failure; COSC FRCDIV; PLLODIV DIV_256; UFRCEN disabled; PBDIVRDY disabled; SLOCK out of lock; FRCDIV FRC/1; SLPEN Idle on WAIT instruction; NOSC FRCDIV; PLLMULT MUL_24; SOSCEN disabled; PBDIV DIV_8; CLKLOCK unlocked; OSWEN Switch is Complete; SOSCRDY disabled; - OSCCON = 0x381F7700; - SYSTEM_RegLock(); - // TUN Center Frequency; - OSCTUN = 0x0; - // DIVSWEN disabled; RSLP disabled; ACTIVE Active; ROSEL SYSCLK; OE Not Driven out on REFCLKO pin; SIDL disabled; RODIV 0; ON disabled; - REFOCON = 0x100; - // ROTRIM 0; - REFOTRIM = 0x0; -} - -void _general_exception_handler () -{ - /* Mask off the ExcCode Field from the Cause Register - Refer to the MIPs Software User's manual */ - uint8_t _excep_code; - uint8_t _excep_addr; - uint8_t *_cause_str; - - _excep_code = (_CP0_GET_CAUSE() & 0x0000007C) >> 2; - _excep_addr = _CP0_GET_EPC(); - _cause_str = reinterpret_cast(cause[_excep_code]); - - while(1) { - - } -} - -/** - End of File -*/ \ No newline at end of file diff --git a/mcc_generated_files/mcc.h b/mcc_generated_files/mcc.h new file mode 100644 index 0000000..8fc44bf --- /dev/null +++ b/mcc_generated_files/mcc.h @@ -0,0 +1,143 @@ +/** + @Generated PIC32MX MCUs Header File + + @Company: + Microchip Technology Inc. + + @File Name: + mcc.h + + @Summary: + This is the mcc.h file generated using PIC32MX MCUs + + @Description: + This header file provides implementations for driver APIs for all modules selected in the GUI. + Generation Information : + Product Revision : PIC32MX MCUs - pic32mx : v1.35 + Device : PIC32MX470F512H + Version : 1.02 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 +*/ + +/* + (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this + software and any derivatives exclusively with Microchip products. + + 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION + WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. + + 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. + + MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE + TERMS. +*/ + +#ifndef MCC_H +#define MCC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "pin_manager.h" +#include +#include +#include "uart1.h" +#include "interrupt_manager.h" + +#define _XTAL_FREQ 8000000UL + +/** + * @Param + none + * @Returns + none + * @Description + Unlocks the write protected register to enable any write operation + * MCC GUI + * @Example + SYSTEM_RegUnlock(); + */ +void SYSTEM_RegUnlock(void); + +/** + * @Param + none + + * @Returns + none + + * @Description + Locks the write protected register to disable any write operation + + * @Example + SYSTEM_RegLock(); + */ + +void SYSTEM_RegLock(void); + +/** + * @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); + +/** + * @Param + none + + * @Returns + none + + * @Description + Automatically called whenever there is a un-handled exception + + * @Example + none + */ + +void _general_exception_handler (void); + +#ifdef __cplusplus +} +#endif + +#endif /* MCC_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/mcc_generated_files/mcc.hpp b/mcc_generated_files/mcc.hpp deleted file mode 100644 index fe747b5..0000000 --- a/mcc_generated_files/mcc.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/** - @Generated PIC32MX MCUs Header File - - @Company: - Microchip Technology Inc. - - @File Name: - mcc.h - - @Summary: - This is the mcc.h file generated using PIC32MX MCUs - - @Description: - This header file provides implementations for driver APIs for all modules selected in the GUI. - Generation Information : - Product Revision : PIC32MX MCUs - pic32mx : v1.35 - Device : PIC32MX470F512H - Version : 1.02 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 -*/ - -/* - (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this - software and any derivatives exclusively with Microchip products. - - 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION - WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. - - 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. - - MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE - TERMS. -*/ - -#ifndef MCC_H -#define MCC_H -#include -#include "pin_manager.hpp" -#include -#include -#include "uart1.hpp" -#include "interrupt_manager.hpp" - -#define _XTAL_FREQ 8000000UL - -/** - * @Param - none - * @Returns - none - * @Description - Unlocks the write protected register to enable any write operation - * MCC GUI - * @Example - SYSTEM_RegUnlock(); - */ -void SYSTEM_RegUnlock(void); - -/** - * @Param - none - - * @Returns - none - - * @Description - Locks the write protected register to disable any write operation - - * @Example - SYSTEM_RegLock(); - */ - -void SYSTEM_RegLock(void); - -/** - * @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); - -/** - * @Param - none - - * @Returns - none - - * @Description - Automatically called whenever there is a un-handled exception - - * @Example - none - */ - -void _general_exception_handler (void); - -#endif /* MCC_H */ -/** - End of File -*/ \ No newline at end of file diff --git a/mcc_generated_files/pin_manager.c b/mcc_generated_files/pin_manager.c new file mode 100644 index 0000000..b0d4a93 --- /dev/null +++ b/mcc_generated_files/pin_manager.c @@ -0,0 +1,138 @@ +/** + System Interrupts Generated Driver File + + @Company: + Microchip Technology Inc. + + @File Name: + pin_manager.c + + @Summary: + This is the generated manager file for the MPLAB(c) Code Configurator device. This manager + configures the pins direction, initial state, analog setting. + The peripheral pin select, PPS, configuration is also handled by this manager. + + @Description: + This source file provides implementations for MPLAB(c) Code Configurator interrupts. + Generation Information : + Product Revision : MPLAB(c) Code Configurator - 4.45 + Device : PIC32MX470F512H + Version : 1.02 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 + + Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved. + + Microchip licenses to you the right to use, modify, copy and distribute + Software only when embedded on a Microchip microcontroller or digital signal + controller that is integrated into your product or third party product + (pursuant to the sublicense terms in the accompanying license agreement). + + You should refer to the license agreement accompanying this Software for + additional information regarding your rights and obligations. + + SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF + MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. + IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER + CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR + OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES + INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR + CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF + SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES + (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. + +*/ + + +/** + Section: Includes +*/ +#include "pin_manager.h" +#ifdef __cplusplus +extern "C" { +#endif + +#include "mcc.h" +#include +#include + +/** + void PIN_MANAGER_Initialize(void) +*/ +void PIN_MANAGER_Initialize(void) +{ + /**************************************************************************** + * Setting the Output Latch SFR(s) + ***************************************************************************/ + LATB = 0x0000; + LATC = 0x0000; + LATD = 0x0000; + LATE = 0x0000; + LATF = 0x0000; + LATG = 0x0000; + + /**************************************************************************** + * Setting the GPIO Direction SFR(s) + ***************************************************************************/ + TRISB = 0xFFFF; + TRISC = 0xF000; + TRISD = 0x0FFF; + TRISE = 0x002F; + TRISF = 0x003A; + TRISG = 0x03C0; + + /**************************************************************************** + * Setting the Weak Pull Up and Weak Pull Down SFR(s) + ***************************************************************************/ + CNPDB = 0x0000; + CNPDC = 0x0000; + CNPDD = 0x0000; + CNPDE = 0x0000; + CNPDF = 0x0000; + CNPDG = 0x0000; + CNPUB = 0x0000; + CNPUC = 0x0000; + CNPUD = 0x0000; + CNPUE = 0x0000; + CNPUF = 0x0000; + CNPUG = 0x0000; + + /**************************************************************************** + * Setting the Open Drain SFR(s) + ***************************************************************************/ + ODCB = 0x0000; + ODCC = 0x0000; + ODCD = 0x0000; + ODCE = 0x0000; + ODCF = 0x0000; + ODCG = 0x0000; + + /**************************************************************************** + * Setting the Analog/Digital Configuration SFR(s) + ***************************************************************************/ + ANSELB = 0xFFFC; + ANSELC = 0xF000; + ANSELD = 0x000E; + ANSELE = 0x00F4; + ANSELG = 0x03C0; + + /**************************************************************************** + * Set the PPS + ***************************************************************************/ + SYSTEM_RegUnlock(); // unlock PPS + CFGCONbits.IOLOCK = 0; + + U1RXRbits.U1RXR = 0x0004; //RF1->UART1:U1RX; + RPF0Rbits.RPF0R = 0x0003; //RF0->UART1:U1TX; + + CFGCONbits.IOLOCK = 1; // lock PPS + SYSTEM_RegLock(); + + +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/mcc_generated_files/pin_manager.cpp b/mcc_generated_files/pin_manager.cpp deleted file mode 100644 index 6124d56..0000000 --- a/mcc_generated_files/pin_manager.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/** - System Interrupts Generated Driver File - - @Company: - Microchip Technology Inc. - - @File Name: - pin_manager.c - - @Summary: - This is the generated manager file for the MPLAB(c) Code Configurator device. This manager - configures the pins direction, initial state, analog setting. - The peripheral pin select, PPS, configuration is also handled by this manager. - - @Description: - This source file provides implementations for MPLAB(c) Code Configurator interrupts. - Generation Information : - Product Revision : MPLAB(c) Code Configurator - 4.45 - Device : PIC32MX470F512H - Version : 1.02 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 - - Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved. - - Microchip licenses to you the right to use, modify, copy and distribute - Software only when embedded on a Microchip microcontroller or digital signal - controller that is integrated into your product or third party product - (pursuant to the sublicense terms in the accompanying license agreement). - - You should refer to the license agreement accompanying this Software for - additional information regarding your rights and obligations. - - SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, - EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF - MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. - IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER - CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR - OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES - INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR - CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF - SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES - (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. - -*/ - - -/** - Section: Includes -*/ -#include -#include -#include "pin_manager.hpp" -#include "mcc.hpp" - -/** - void PIN_MANAGER_Initialize(void) -*/ -void PIN_MANAGER_Initialize(void) -{ - /**************************************************************************** - * Setting the Output Latch SFR(s) - ***************************************************************************/ - LATB = 0x0000; - LATC = 0x0000; - LATD = 0x0000; - LATE = 0x0000; - LATF = 0x0000; - LATG = 0x0000; - - /**************************************************************************** - * Setting the GPIO Direction SFR(s) - ***************************************************************************/ - TRISB = 0xFFFF; - TRISC = 0xF000; - TRISD = 0x0FFF; - TRISE = 0x002F; - TRISF = 0x003A; - TRISG = 0x03C0; - - /**************************************************************************** - * Setting the Weak Pull Up and Weak Pull Down SFR(s) - ***************************************************************************/ - CNPDB = 0x0000; - CNPDC = 0x0000; - CNPDD = 0x0000; - CNPDE = 0x0000; - CNPDF = 0x0000; - CNPDG = 0x0000; - CNPUB = 0x0000; - CNPUC = 0x0000; - CNPUD = 0x0000; - CNPUE = 0x0000; - CNPUF = 0x0000; - CNPUG = 0x0000; - - /**************************************************************************** - * Setting the Open Drain SFR(s) - ***************************************************************************/ - ODCB = 0x0000; - ODCC = 0x0000; - ODCD = 0x0000; - ODCE = 0x0000; - ODCF = 0x0000; - ODCG = 0x0000; - - /**************************************************************************** - * Setting the Analog/Digital Configuration SFR(s) - ***************************************************************************/ - ANSELB = 0xFFFC; - ANSELC = 0xF000; - ANSELD = 0x000E; - ANSELE = 0x00F4; - ANSELG = 0x03C0; - - /**************************************************************************** - * Set the PPS - ***************************************************************************/ - SYSTEM_RegUnlock(); // unlock PPS - CFGCONbits.IOLOCK = 0; - - U1RXRbits.U1RXR = 0x0004; //RF1->UART1:U1RX; - RPF0Rbits.RPF0R = 0x0003; //RF0->UART1:U1TX; - - CFGCONbits.IOLOCK = 1; // lock PPS - SYSTEM_RegLock(); - - -} - diff --git a/mcc_generated_files/pin_manager.h b/mcc_generated_files/pin_manager.h new file mode 100644 index 0000000..f79a0ec --- /dev/null +++ b/mcc_generated_files/pin_manager.h @@ -0,0 +1,539 @@ +/** + System Interrupts Generated Driver File + + @Company: + Microchip Technology Inc. + + @File Name: + pin_manager.h + + @Summary: + This is the generated manager file for the MPLAB(c) Code Configurator device. This manager + configures the pins direction, initial state, analog setting. + The peripheral pin select, PPS, configuration is also handled by this manager. + + @Description: + This source file provides implementations for MPLAB(c) Code Configurator interrupts. + Generation Information : + Product Revision : MPLAB(c) Code Configurator - 4.45 + Device : PIC32MX470F512H + Version : 1.02 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 + + Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved. + + Microchip licenses to you the right to use, modify, copy and distribute + Software only when embedded on a Microchip microcontroller or digital signal + controller that is integrated into your product or third party product + (pursuant to the sublicense terms in the accompanying license agreement). + + You should refer to the license agreement accompanying this Software for + additional information regarding your rights and obligations. + + SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF + MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. + IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER + CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR + OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES + INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR + CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF + SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES + (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. + +*/ + +#ifndef _PIN_MANAGER_H +#define _PIN_MANAGER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + Section: Includes +*/ +#include +/** + Section: Device Pin Macros +*/ +/** + @Summary + Sets the GPIO pin, RE4, high using LATEbits.LATE4. + + @Description + Sets the GPIO pin, RE4, high using LATEbits.LATE4. + + @Preconditions + The RE4 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Set RE4 high (1) + LED1_SetHigh(); + + +*/ +#define LED1_SetHigh() LATEbits.LATE4 = 1 +/** + @Summary + Sets the GPIO pin, RE4, low using LATEbits.LATE4. + + @Description + Sets the GPIO pin, RE4, low using LATEbits.LATE4. + + @Preconditions + The RE4 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Set RE4 low (0) + LED1_SetLow(); + + +*/ +#define LED1_SetLow() LATEbits.LATE4 = 0 +/** + @Summary + Toggles the GPIO pin, RE4, using LATEbits.LATE4. + + @Description + Toggles the GPIO pin, RE4, using LATEbits.LATE4. + + @Preconditions + The RE4 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Toggle RE4 + LED1_Toggle(); + + +*/ +#define LED1_Toggle() LATEbits.LATE4 ^= 1 +/** + @Summary + Reads the value of the GPIO pin, RE4. + + @Description + Reads the value of the GPIO pin, RE4. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + uint16_t portValue; + + // Read RE4 + postValue = LED1_GetValue(); + + +*/ +#define LED1_GetValue() PORTEbits.RE4 +/** + @Summary + Configures the GPIO pin, RE4, as an input. + + @Description + Configures the GPIO pin, RE4, as an input. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + // Sets the RE4 as an input + LED1_SetDigitalInput(); + + +*/ +#define LED1_SetDigitalInput() TRISEbits.TRISE4 = 1 +/** + @Summary + Configures the GPIO pin, RE4, as an output. + + @Description + Configures the GPIO pin, RE4, as an output. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + // Sets the RE4 as an output + LED1_SetDigitalOutput(); + + +*/ +#define LED1_SetDigitalOutput() TRISEbits.TRISE4 = 0 +/** + @Summary + Sets the GPIO pin, RE6, high using LATEbits.LATE6. + + @Description + Sets the GPIO pin, RE6, high using LATEbits.LATE6. + + @Preconditions + The RE6 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Set RE6 high (1) + LED2_SetHigh(); + + +*/ +#define LED2_SetHigh() LATEbits.LATE6 = 1 +/** + @Summary + Sets the GPIO pin, RE6, low using LATEbits.LATE6. + + @Description + Sets the GPIO pin, RE6, low using LATEbits.LATE6. + + @Preconditions + The RE6 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Set RE6 low (0) + LED2_SetLow(); + + +*/ +#define LED2_SetLow() LATEbits.LATE6 = 0 +/** + @Summary + Toggles the GPIO pin, RE6, using LATEbits.LATE6. + + @Description + Toggles the GPIO pin, RE6, using LATEbits.LATE6. + + @Preconditions + The RE6 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Toggle RE6 + LED2_Toggle(); + + +*/ +#define LED2_Toggle() LATEbits.LATE6 ^= 1 +/** + @Summary + Reads the value of the GPIO pin, RE6. + + @Description + Reads the value of the GPIO pin, RE6. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + uint16_t portValue; + + // Read RE6 + postValue = LED2_GetValue(); + + +*/ +#define LED2_GetValue() PORTEbits.RE6 +/** + @Summary + Configures the GPIO pin, RE6, as an input. + + @Description + Configures the GPIO pin, RE6, as an input. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + // Sets the RE6 as an input + LED2_SetDigitalInput(); + + +*/ +#define LED2_SetDigitalInput() TRISEbits.TRISE6 = 1 +/** + @Summary + Configures the GPIO pin, RE6, as an output. + + @Description + Configures the GPIO pin, RE6, as an output. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + // Sets the RE6 as an output + LED2_SetDigitalOutput(); + + +*/ +#define LED2_SetDigitalOutput() TRISEbits.TRISE6 = 0 +/** + @Summary + Sets the GPIO pin, RE7, high using LATEbits.LATE7. + + @Description + Sets the GPIO pin, RE7, high using LATEbits.LATE7. + + @Preconditions + The RE7 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Set RE7 high (1) + LED3_SetHigh(); + + +*/ +#define LED3_SetHigh() LATEbits.LATE7 = 1 +/** + @Summary + Sets the GPIO pin, RE7, low using LATEbits.LATE7. + + @Description + Sets the GPIO pin, RE7, low using LATEbits.LATE7. + + @Preconditions + The RE7 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Set RE7 low (0) + LED3_SetLow(); + + +*/ +#define LED3_SetLow() LATEbits.LATE7 = 0 +/** + @Summary + Toggles the GPIO pin, RE7, using LATEbits.LATE7. + + @Description + Toggles the GPIO pin, RE7, using LATEbits.LATE7. + + @Preconditions + The RE7 must be set to an output. + + @Returns + None. + + @Param + None. + + @Example + + // Toggle RE7 + LED3_Toggle(); + + +*/ +#define LED3_Toggle() LATEbits.LATE7 ^= 1 +/** + @Summary + Reads the value of the GPIO pin, RE7. + + @Description + Reads the value of the GPIO pin, RE7. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + uint16_t portValue; + + // Read RE7 + postValue = LED3_GetValue(); + + +*/ +#define LED3_GetValue() PORTEbits.RE7 +/** + @Summary + Configures the GPIO pin, RE7, as an input. + + @Description + Configures the GPIO pin, RE7, as an input. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + // Sets the RE7 as an input + LED3_SetDigitalInput(); + + +*/ +#define LED3_SetDigitalInput() TRISEbits.TRISE7 = 1 +/** + @Summary + Configures the GPIO pin, RE7, as an output. + + @Description + Configures the GPIO pin, RE7, as an output. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + // Sets the RE7 as an output + LED3_SetDigitalOutput(); + + +*/ +#define LED3_SetDigitalOutput() TRISEbits.TRISE7 = 0 + +/** + Section: Function Prototypes +*/ +/** + @Summary + Configures the pin settings of the PIC32MX470F512H + The peripheral pin select, PPS, configuration is also handled by this manager. + + @Description + This is the generated manager file for the MPLAB(c) Code Configurator device. This manager + configures the pins direction, initial state, analog setting. + The peripheral pin select, PPS, configuration is also handled by this manager. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Example + + void SYSTEM_Initialize(void) + { + // Other initializers are called from this function + PIN_MANAGER_Initialize(); + } + + +*/ +void PIN_MANAGER_Initialize(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mcc_generated_files/pin_manager.hpp b/mcc_generated_files/pin_manager.hpp deleted file mode 100644 index 650fe9a..0000000 --- a/mcc_generated_files/pin_manager.hpp +++ /dev/null @@ -1,530 +0,0 @@ -/** - System Interrupts Generated Driver File - - @Company: - Microchip Technology Inc. - - @File Name: - pin_manager.h - - @Summary: - This is the generated manager file for the MPLAB(c) Code Configurator device. This manager - configures the pins direction, initial state, analog setting. - The peripheral pin select, PPS, configuration is also handled by this manager. - - @Description: - This source file provides implementations for MPLAB(c) Code Configurator interrupts. - Generation Information : - Product Revision : MPLAB(c) Code Configurator - 4.45 - Device : PIC32MX470F512H - Version : 1.02 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 - - Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved. - - Microchip licenses to you the right to use, modify, copy and distribute - Software only when embedded on a Microchip microcontroller or digital signal - controller that is integrated into your product or third party product - (pursuant to the sublicense terms in the accompanying license agreement). - - You should refer to the license agreement accompanying this Software for - additional information regarding your rights and obligations. - - SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, - EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF - MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. - IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER - CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR - OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES - INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR - CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF - SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES - (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. - -*/ - -#ifndef _PIN_MANAGER_H -#define _PIN_MANAGER_H -/** - Section: Includes -*/ -#include -/** - Section: Device Pin Macros -*/ -/** - @Summary - Sets the GPIO pin, RE4, high using LATEbits.LATE4. - - @Description - Sets the GPIO pin, RE4, high using LATEbits.LATE4. - - @Preconditions - The RE4 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Set RE4 high (1) - LED1_SetHigh(); - - -*/ -#define LED1_SetHigh() LATEbits.LATE4 = 1 -/** - @Summary - Sets the GPIO pin, RE4, low using LATEbits.LATE4. - - @Description - Sets the GPIO pin, RE4, low using LATEbits.LATE4. - - @Preconditions - The RE4 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Set RE4 low (0) - LED1_SetLow(); - - -*/ -#define LED1_SetLow() LATEbits.LATE4 = 0 -/** - @Summary - Toggles the GPIO pin, RE4, using LATEbits.LATE4. - - @Description - Toggles the GPIO pin, RE4, using LATEbits.LATE4. - - @Preconditions - The RE4 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Toggle RE4 - LED1_Toggle(); - - -*/ -#define LED1_Toggle() LATEbits.LATE4 ^= 1 -/** - @Summary - Reads the value of the GPIO pin, RE4. - - @Description - Reads the value of the GPIO pin, RE4. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - uint16_t portValue; - - // Read RE4 - postValue = LED1_GetValue(); - - -*/ -#define LED1_GetValue() PORTEbits.RE4 -/** - @Summary - Configures the GPIO pin, RE4, as an input. - - @Description - Configures the GPIO pin, RE4, as an input. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - // Sets the RE4 as an input - LED1_SetDigitalInput(); - - -*/ -#define LED1_SetDigitalInput() TRISEbits.TRISE4 = 1 -/** - @Summary - Configures the GPIO pin, RE4, as an output. - - @Description - Configures the GPIO pin, RE4, as an output. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - // Sets the RE4 as an output - LED1_SetDigitalOutput(); - - -*/ -#define LED1_SetDigitalOutput() TRISEbits.TRISE4 = 0 -/** - @Summary - Sets the GPIO pin, RE6, high using LATEbits.LATE6. - - @Description - Sets the GPIO pin, RE6, high using LATEbits.LATE6. - - @Preconditions - The RE6 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Set RE6 high (1) - LED2_SetHigh(); - - -*/ -#define LED2_SetHigh() LATEbits.LATE6 = 1 -/** - @Summary - Sets the GPIO pin, RE6, low using LATEbits.LATE6. - - @Description - Sets the GPIO pin, RE6, low using LATEbits.LATE6. - - @Preconditions - The RE6 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Set RE6 low (0) - LED2_SetLow(); - - -*/ -#define LED2_SetLow() LATEbits.LATE6 = 0 -/** - @Summary - Toggles the GPIO pin, RE6, using LATEbits.LATE6. - - @Description - Toggles the GPIO pin, RE6, using LATEbits.LATE6. - - @Preconditions - The RE6 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Toggle RE6 - LED2_Toggle(); - - -*/ -#define LED2_Toggle() LATEbits.LATE6 ^= 1 -/** - @Summary - Reads the value of the GPIO pin, RE6. - - @Description - Reads the value of the GPIO pin, RE6. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - uint16_t portValue; - - // Read RE6 - postValue = LED2_GetValue(); - - -*/ -#define LED2_GetValue() PORTEbits.RE6 -/** - @Summary - Configures the GPIO pin, RE6, as an input. - - @Description - Configures the GPIO pin, RE6, as an input. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - // Sets the RE6 as an input - LED2_SetDigitalInput(); - - -*/ -#define LED2_SetDigitalInput() TRISEbits.TRISE6 = 1 -/** - @Summary - Configures the GPIO pin, RE6, as an output. - - @Description - Configures the GPIO pin, RE6, as an output. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - // Sets the RE6 as an output - LED2_SetDigitalOutput(); - - -*/ -#define LED2_SetDigitalOutput() TRISEbits.TRISE6 = 0 -/** - @Summary - Sets the GPIO pin, RE7, high using LATEbits.LATE7. - - @Description - Sets the GPIO pin, RE7, high using LATEbits.LATE7. - - @Preconditions - The RE7 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Set RE7 high (1) - LED3_SetHigh(); - - -*/ -#define LED3_SetHigh() LATEbits.LATE7 = 1 -/** - @Summary - Sets the GPIO pin, RE7, low using LATEbits.LATE7. - - @Description - Sets the GPIO pin, RE7, low using LATEbits.LATE7. - - @Preconditions - The RE7 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Set RE7 low (0) - LED3_SetLow(); - - -*/ -#define LED3_SetLow() LATEbits.LATE7 = 0 -/** - @Summary - Toggles the GPIO pin, RE7, using LATEbits.LATE7. - - @Description - Toggles the GPIO pin, RE7, using LATEbits.LATE7. - - @Preconditions - The RE7 must be set to an output. - - @Returns - None. - - @Param - None. - - @Example - - // Toggle RE7 - LED3_Toggle(); - - -*/ -#define LED3_Toggle() LATEbits.LATE7 ^= 1 -/** - @Summary - Reads the value of the GPIO pin, RE7. - - @Description - Reads the value of the GPIO pin, RE7. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - uint16_t portValue; - - // Read RE7 - postValue = LED3_GetValue(); - - -*/ -#define LED3_GetValue() PORTEbits.RE7 -/** - @Summary - Configures the GPIO pin, RE7, as an input. - - @Description - Configures the GPIO pin, RE7, as an input. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - // Sets the RE7 as an input - LED3_SetDigitalInput(); - - -*/ -#define LED3_SetDigitalInput() TRISEbits.TRISE7 = 1 -/** - @Summary - Configures the GPIO pin, RE7, as an output. - - @Description - Configures the GPIO pin, RE7, as an output. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - // Sets the RE7 as an output - LED3_SetDigitalOutput(); - - -*/ -#define LED3_SetDigitalOutput() TRISEbits.TRISE7 = 0 - -/** - Section: Function Prototypes -*/ -/** - @Summary - Configures the pin settings of the PIC32MX470F512H - The peripheral pin select, PPS, configuration is also handled by this manager. - - @Description - This is the generated manager file for the MPLAB(c) Code Configurator device. This manager - configures the pins direction, initial state, analog setting. - The peripheral pin select, PPS, configuration is also handled by this manager. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Example - - void SYSTEM_Initialize(void) - { - // Other initializers are called from this function - PIN_MANAGER_Initialize(); - } - - -*/ -void PIN_MANAGER_Initialize(void); - -#endif diff --git a/mcc_generated_files/uart1.c b/mcc_generated_files/uart1.c new file mode 100644 index 0000000..bf35ee3 --- /dev/null +++ b/mcc_generated_files/uart1.c @@ -0,0 +1,398 @@ +/** + UART1 Generated Driver File + + @Company + Microchip Technology Inc. + + @File Name + uart1.c + + @Summary + This is the generated source file for the UART1 driver using PIC32MX MCUs + + @Description + This source file provides APIs for driver for UART1. + Generation Information : + Product Revision : PIC32MX MCUs - pic32mx : v1.35 + Device : PIC32MX470F512H + Driver Version : 0.5 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 +*/ + +/* + (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this + software and any derivatives exclusively with Microchip products. + + 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION + WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. + + 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. + + MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE + TERMS. +*/ + +/** + Section: Included Files +*/ + +#include "uart1.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + Section: Data Type Definitions +*/ + +/** UART Driver Queue Status + + @Summary + Defines the object required for the status of the queue. +*/ + +typedef union +{ + struct + { + uint8_t full:1; + uint8_t empty:1; + uint8_t reserved:6; + } s; + uint8_t status; +} UART_BYTEQ_STATUS; + +/** UART Driver Hardware Instance Object + + @Summary + Defines the object required for the maintenance of the hardware instance. + +*/ +typedef struct +{ + /* RX Byte Q */ + uint8_t *rxTail; + uint8_t *rxHead; + + /* TX Byte Q */ + uint8_t *txTail; + uint8_t *txHead; + UART_BYTEQ_STATUS rxStatus; + UART_BYTEQ_STATUS txStatus; + +} UART_OBJECT; + +static UART_OBJECT uart1_obj; + +/** UART Driver Queue Length + + @Summary + Defines the length of the Transmit and Receive Buffers + +*/ + +#define UART1_CONFIG_TX_BYTEQ_LENGTH 8 +#define UART1_CONFIG_RX_BYTEQ_LENGTH 8 + + +/** UART Driver Queue + + @Summary + Defines the Transmit and Receive Buffers + +*/ + +static uint8_t uart1_txByteQ[UART1_CONFIG_TX_BYTEQ_LENGTH]; +static uint8_t uart1_rxByteQ[UART1_CONFIG_RX_BYTEQ_LENGTH]; + +/** UART Hardware FIFO Buffer Length + + @Summary + Defines the length of the Transmit and Receive FIFOs + +*/ + +#define UART1_TX_FIFO_LENGTH 1 +#define UART1_RX_FIFO_LENGTH 1 + +/** + Section: Driver Interface +*/ + + +void UART1_Initialize (void) +{ + // STSEL 1S; IREN disabled; PDSEL 8N; RTSMD disabled; RXINV disabled; SIDL disabled; WAKE disabled; ABAUD disabled; LPBACK disabled; BRGH enabled; UEN TX_RX; ON enabled; + U1MODE = 0x8008; + // UTXISEL TX_ONE_CHAR; UTXINV disabled; ADDR 0; URXEN disabled; OERR disabled; ADM_EN disabled; URXISEL RX_ONE_CHAR; UTXBRK disabled; UTXEN disabled; ADDEN disabled; + U1STA = 0x0; + // U1TXREG 0; + U1TXREG = 0x0; + // BaudRate = 9600; Frequency = 1000000 Hz; BRG 25; + U1BRG = 0x19; + + IEC1bits.U1RXIE = 1; + + U1STAbits.UTXEN = 1; + U1STAbits.URXEN = 1; + + //Enabling UART + U1MODEbits.ON = 1; + + uart1_obj.txHead = uart1_txByteQ; + uart1_obj.txTail = uart1_txByteQ; + uart1_obj.rxHead = uart1_rxByteQ; + uart1_obj.rxTail = uart1_rxByteQ; + uart1_obj.rxStatus.s.empty = true; + uart1_obj.txStatus.s.empty = true; + uart1_obj.txStatus.s.full = false; + uart1_obj.rxStatus.s.full = false; +} + + +/** + Maintains the driver's transmitter/receiver/error state machine and implements its ISR +*/ +void __ISR(_UART_1_VECTOR, IPL1AUTO) _UART_1 (void) +{ + if(IFS1bits.U1RXIF) { + int count = 0; + + while((count < UART1_RX_FIFO_LENGTH) && (U1STAbits.URXDA == 1)) { + count++; + + *uart1_obj.rxTail = U1RXREG; + uart1_obj.rxTail++; + + if(uart1_obj.rxTail == (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH)) { + uart1_obj.rxTail = uart1_rxByteQ; + } + + uart1_obj.rxStatus.s.empty = false; + + if(uart1_obj.rxTail == uart1_obj.rxHead) { + //Sets the flag RX full + uart1_obj.rxStatus.s.full = true; + break; + } + } + + IFS1CLR= 1 << _IFS1_U1RXIF_POSITION; + } else if (IFS1bits.U1TXIF) { + if(uart1_obj.txStatus.s.empty) { + IEC1bits.U1TXIE = false; + return; + } + + IFS1CLR= 1 << _IFS1_U1TXIF_POSITION; + + int count = 0; + while((count < UART1_TX_FIFO_LENGTH)&& !(U1STAbits.UTXBF == 1)) { + count++; + + U1TXREG = *uart1_obj.txHead; + + uart1_obj.txHead++; + + if(uart1_obj.txHead == (uart1_txByteQ + UART1_CONFIG_TX_BYTEQ_LENGTH)) { + uart1_obj.txHead = uart1_txByteQ; + } + + uart1_obj.txStatus.s.full = false; + + if(uart1_obj.txHead == uart1_obj.txTail) { + uart1_obj.txStatus.s.empty = true; + break; + } + } + } else { + if ((U1STAbits.OERR == 1)) { + U1STAbits.OERR = 0; + } + + IFS1CLR= 1 << _IFS1_U1EIF_POSITION; + } +} + +/** + Section: UART Driver Client Routines +*/ + +uint8_t UART1_Read(void) +{ + uint8_t data = 0; + + data = *uart1_obj.rxHead; + + uart1_obj.rxHead++; + + if (uart1_obj.rxHead == (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH)) { + uart1_obj.rxHead = uart1_rxByteQ; + } + + if (uart1_obj.rxHead == uart1_obj.rxTail) { + uart1_obj.rxStatus.s.empty = true; + } + + uart1_obj.rxStatus.s.full = false; + + return data; +} + + +unsigned int UART1_ReadBuffer(uint8_t *buffer, const unsigned int bufLen) +{ + unsigned int numBytesRead = 0; + + while (numBytesRead < ( bufLen )) { + if(uart1_obj.rxStatus.s.empty) { + break; + } else { + buffer[numBytesRead++] = UART1_Read () ; + } + } + + return numBytesRead ; +} + + + +void UART1_Write(const uint8_t byte) +{ + IEC1bits.U1TXIE = false; + + *uart1_obj.txTail = byte; + uart1_obj.txTail++; + + if (uart1_obj.txTail == (uart1_txByteQ + UART1_CONFIG_TX_BYTEQ_LENGTH)) { + uart1_obj.txTail = uart1_txByteQ; + } + + uart1_obj.txStatus.s.empty = false; + + if (uart1_obj.txHead == uart1_obj.txTail) { + uart1_obj.txStatus.s.full = true; + } + + IEC1bits.U1TXIE = true ; + +} + + +unsigned int UART1_WriteBuffer(const uint8_t *buffer , const unsigned int bufLen ) +{ + unsigned int numBytesWritten = 0 ; + + while ( numBytesWritten < ( bufLen )) { + if((uart1_obj.txStatus.s.full)) { + break; + } else { + UART1_Write (buffer[numBytesWritten++] ) ; + } + } + + return numBytesWritten ; + +} + + +UART1_TRANSFER_STATUS UART1_TransferStatusGet (void) +{ + uint8_t status = 0; + + if(uart1_obj.txStatus.s.full) { + status |= UART1_TRANSFER_STATUS_TX_FULL; + } + + if(uart1_obj.txStatus.s.empty) { + status |= UART1_TRANSFER_STATUS_TX_EMPTY; + } + + if(uart1_obj.rxStatus.s.full) { + status |= UART1_TRANSFER_STATUS_RX_FULL; + } + + if(uart1_obj.rxStatus.s.empty) { + status |= UART1_TRANSFER_STATUS_RX_EMPTY; + } else { + status |= UART1_TRANSFER_STATUS_RX_DATA_PRESENT; + } + + return (UART1_TRANSFER_STATUS) status; +} + + +uint8_t UART1_Peek(uint16_t offset) +{ + if( (uart1_obj.rxHead + offset) > (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH)) { + return uart1_rxByteQ[offset - (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH - uart1_obj.rxHead)]; + } else { + return *(uart1_obj.rxHead + offset); + } +} + + +unsigned int UART1_ReceiveBufferSizeGet(void) +{ + if(!uart1_obj.rxStatus.s.full) { + if(uart1_obj.rxHead > uart1_obj.rxTail) { + return(uart1_obj.rxHead - uart1_obj.rxTail); + } else { + return(UART1_CONFIG_RX_BYTEQ_LENGTH - (uart1_obj.rxTail - uart1_obj.rxHead)); + } + } + return 0; +} + + +unsigned int UART1_TransmitBufferSizeGet(void) +{ + if(!uart1_obj.txStatus.s.full) { + if(uart1_obj.txHead > uart1_obj.txTail) { + return (uart1_obj.txHead - uart1_obj.txTail); + } else { + return (UART1_CONFIG_TX_BYTEQ_LENGTH - (uart1_obj.txTail - uart1_obj.txHead)); + } + } + return 0; +} + + +bool UART1_ReceiveBufferIsEmpty (void) +{ + return(uart1_obj.rxStatus.s.empty); +} + + +bool UART1_TransmitBufferIsFull(void) +{ + return(uart1_obj.txStatus.s.full); +} + + +UART1_STATUS UART1_StatusGet (void) +{ + return (UART1_STATUS) U1STA; +} + + + +/** + End of File +*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/mcc_generated_files/uart1.cpp b/mcc_generated_files/uart1.cpp deleted file mode 100644 index 96ed3e3..0000000 --- a/mcc_generated_files/uart1.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/** - UART1 Generated Driver File - - @Company - Microchip Technology Inc. - - @File Name - uart1.c - - @Summary - This is the generated source file for the UART1 driver using PIC32MX MCUs - - @Description - This source file provides APIs for driver for UART1. - Generation Information : - Product Revision : PIC32MX MCUs - pic32mx : v1.35 - Device : PIC32MX470F512H - Driver Version : 0.5 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 -*/ - -/* - (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this - software and any derivatives exclusively with Microchip products. - - 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION - WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. - - 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. - - MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE - TERMS. -*/ - -/** - Section: Included Files -*/ - -#include "uart1.hpp" - -/** - Section: Data Type Definitions -*/ - -/** UART Driver Queue Status - - @Summary - Defines the object required for the status of the queue. -*/ - -union UART_BYTEQ_STATUS -{ - struct - { - uint8_t full:1; - uint8_t empty:1; - uint8_t reserved:6; - } s; - uint8_t status; -}; - -/** UART Driver Hardware Instance Object - - @Summary - Defines the object required for the maintenance of the hardware instance. - -*/ -struct UART_OBJECT -{ - /* RX Byte Q */ - uint8_t *rxTail; - uint8_t *rxHead; - - /* TX Byte Q */ - uint8_t *txTail; - uint8_t *txHead; - UART_BYTEQ_STATUS rxStatus; - UART_BYTEQ_STATUS txStatus; - -}; - -static UART_OBJECT uart1_obj; - -/** UART Driver Queue Length - - @Summary - Defines the length of the Transmit and Receive Buffers - -*/ - -#define UART1_CONFIG_TX_BYTEQ_LENGTH 8 -#define UART1_CONFIG_RX_BYTEQ_LENGTH 8 - - -/** UART Driver Queue - - @Summary - Defines the Transmit and Receive Buffers - -*/ - -static uint8_t uart1_txByteQ[UART1_CONFIG_TX_BYTEQ_LENGTH]; -static uint8_t uart1_rxByteQ[UART1_CONFIG_RX_BYTEQ_LENGTH]; - -/** UART Hardware FIFO Buffer Length - - @Summary - Defines the length of the Transmit and Receive FIFOs - -*/ - -#define UART1_TX_FIFO_LENGTH 1 -#define UART1_RX_FIFO_LENGTH 1 - -/** - Section: Driver Interface -*/ - - -void UART1_Initialize (void) -{ - // STSEL 1S; IREN disabled; PDSEL 8N; RTSMD disabled; RXINV disabled; SIDL disabled; WAKE disabled; ABAUD disabled; LPBACK disabled; BRGH enabled; UEN TX_RX; ON enabled; - U1MODE = 0x8008; - // UTXISEL TX_ONE_CHAR; UTXINV disabled; ADDR 0; URXEN disabled; OERR disabled; ADM_EN disabled; URXISEL RX_ONE_CHAR; UTXBRK disabled; UTXEN disabled; ADDEN disabled; - U1STA = 0x0; - // U1TXREG 0; - U1TXREG = 0x0; - // BaudRate = 9600; Frequency = 1000000 Hz; BRG 25; - U1BRG = 0x19; - - IEC1bits.U1RXIE = 1; - - U1STAbits.UTXEN = 1; - U1STAbits.URXEN = 1; - - //Enabling UART - U1MODEbits.ON = 1; - - uart1_obj.txHead = uart1_txByteQ; - uart1_obj.txTail = uart1_txByteQ; - uart1_obj.rxHead = uart1_rxByteQ; - uart1_obj.rxTail = uart1_rxByteQ; - uart1_obj.rxStatus.s.empty = true; - uart1_obj.txStatus.s.empty = true; - uart1_obj.txStatus.s.full = false; - uart1_obj.rxStatus.s.full = false; -} - - -/** - Maintains the driver's transmitter/receiver/error state machine and implements its ISR -*/ -void __ISR(_UART_1_VECTOR, IPL1AUTO) _UART_1 (void) -{ - if(IFS1bits.U1RXIF) { - int count = 0; - - while((count < UART1_RX_FIFO_LENGTH) && (U1STAbits.URXDA == 1)) { - count++; - - *uart1_obj.rxTail = U1RXREG; - uart1_obj.rxTail++; - - if(uart1_obj.rxTail == (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH)) { - uart1_obj.rxTail = uart1_rxByteQ; - } - - uart1_obj.rxStatus.s.empty = false; - - if(uart1_obj.rxTail == uart1_obj.rxHead) { - //Sets the flag RX full - uart1_obj.rxStatus.s.full = true; - break; - } - } - - IFS1CLR= 1 << _IFS1_U1RXIF_POSITION; - } else if (IFS1bits.U1TXIF) { - if(uart1_obj.txStatus.s.empty) { - IEC1bits.U1TXIE = false; - return; - } - - IFS1CLR= 1 << _IFS1_U1TXIF_POSITION; - - int count = 0; - while((count < UART1_TX_FIFO_LENGTH)&& !(U1STAbits.UTXBF == 1)) { - count++; - - U1TXREG = *uart1_obj.txHead; - - uart1_obj.txHead++; - - if(uart1_obj.txHead == (uart1_txByteQ + UART1_CONFIG_TX_BYTEQ_LENGTH)) { - uart1_obj.txHead = uart1_txByteQ; - } - - uart1_obj.txStatus.s.full = false; - - if(uart1_obj.txHead == uart1_obj.txTail) { - uart1_obj.txStatus.s.empty = true; - break; - } - } - } else { - if ((U1STAbits.OERR == 1)) { - U1STAbits.OERR = 0; - } - - IFS1CLR= 1 << _IFS1_U1EIF_POSITION; - } -} - -/** - Section: UART Driver Client Routines -*/ - -uint8_t UART1_Read(void) -{ - uint8_t data = 0; - - data = *uart1_obj.rxHead; - - uart1_obj.rxHead++; - - if (uart1_obj.rxHead == (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH)) { - uart1_obj.rxHead = uart1_rxByteQ; - } - - if (uart1_obj.rxHead == uart1_obj.rxTail) { - uart1_obj.rxStatus.s.empty = true; - } - - uart1_obj.rxStatus.s.full = false; - - return data; -} - - -unsigned int UART1_ReadBuffer(uint8_t *buffer, const unsigned int bufLen) -{ - unsigned int numBytesRead = 0; - - while (numBytesRead < ( bufLen )) { - if(uart1_obj.rxStatus.s.empty) { - break; - } else { - buffer[numBytesRead++] = UART1_Read () ; - } - } - - return numBytesRead ; -} - - - -void UART1_Write(const uint8_t byte) -{ - IEC1bits.U1TXIE = false; - - *uart1_obj.txTail = byte; - uart1_obj.txTail++; - - if (uart1_obj.txTail == (uart1_txByteQ + UART1_CONFIG_TX_BYTEQ_LENGTH)) { - uart1_obj.txTail = uart1_txByteQ; - } - - uart1_obj.txStatus.s.empty = false; - - if (uart1_obj.txHead == uart1_obj.txTail) { - uart1_obj.txStatus.s.full = true; - } - - IEC1bits.U1TXIE = true ; - -} - - -unsigned int UART1_WriteBuffer(const uint8_t *buffer , const unsigned int bufLen ) -{ - unsigned int numBytesWritten = 0 ; - - while ( numBytesWritten < ( bufLen )) { - if((uart1_obj.txStatus.s.full)) { - break; - } else { - UART1_Write (buffer[numBytesWritten++] ) ; - } - } - - return numBytesWritten ; - -} - - -UART1_TRANSFER_STATUS UART1_TransferStatusGet (void) -{ - uint8_t status = 0; - - if(uart1_obj.txStatus.s.full) { - status |= UART1_TRANSFER_STATUS_TX_FULL; - } - - if(uart1_obj.txStatus.s.empty) { - status |= UART1_TRANSFER_STATUS_TX_EMPTY; - } - - if(uart1_obj.rxStatus.s.full) { - status |= UART1_TRANSFER_STATUS_RX_FULL; - } - - if(uart1_obj.rxStatus.s.empty) { - status |= UART1_TRANSFER_STATUS_RX_EMPTY; - } else { - status |= UART1_TRANSFER_STATUS_RX_DATA_PRESENT; - } - - return static_cast(status); -} - - -uint8_t UART1_Peek(uint16_t offset) -{ - if( (uart1_obj.rxHead + offset) > (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH)) { - return uart1_rxByteQ[offset - (uart1_rxByteQ + UART1_CONFIG_RX_BYTEQ_LENGTH - uart1_obj.rxHead)]; - } else { - return *(uart1_obj.rxHead + offset); - } -} - - -unsigned int UART1_ReceiveBufferSizeGet(void) -{ - if(!uart1_obj.rxStatus.s.full) { - if(uart1_obj.rxHead > uart1_obj.rxTail) { - return(uart1_obj.rxHead - uart1_obj.rxTail); - } else { - return(UART1_CONFIG_RX_BYTEQ_LENGTH - (uart1_obj.rxTail - uart1_obj.rxHead)); - } - } - return 0; -} - - -unsigned int UART1_TransmitBufferSizeGet(void) -{ - if(!uart1_obj.txStatus.s.full) { - if(uart1_obj.txHead > uart1_obj.txTail) { - return (uart1_obj.txHead - uart1_obj.txTail); - } else { - return (UART1_CONFIG_TX_BYTEQ_LENGTH - (uart1_obj.txTail - uart1_obj.txHead)); - } - } - return 0; -} - - -bool UART1_ReceiveBufferIsEmpty (void) -{ - return(uart1_obj.rxStatus.s.empty); -} - - -bool UART1_TransmitBufferIsFull(void) -{ - return(uart1_obj.txStatus.s.full); -} - - -UART1_STATUS UART1_StatusGet (void) -{ - return static_cast(U1STA); -} - - - -/** - End of File -*/ diff --git a/mcc_generated_files/uart1.h b/mcc_generated_files/uart1.h new file mode 100644 index 0000000..bd3971a --- /dev/null +++ b/mcc_generated_files/uart1.h @@ -0,0 +1,623 @@ +/** + UART1 Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + uart1.h + + @Summary + This is the generated header file for the UART1 driver using PIC32MX MCUs + + @Description + This header file provides APIs for driver for UART1. + Generation Information : + Product Revision : PIC32MX MCUs - pic32mx : v1.35 + Device : PIC32MX470F512H + Driver Version : 0.5 + The generated drivers are tested against the following: + Compiler : XC32 1.42 + MPLAB : MPLAB X 3.55 +*/ + +/* + (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this + software and any derivatives exclusively with Microchip products. + + 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION + WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. + + 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. + + MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE + TERMS. +*/ + +#ifndef _UART1_H +#define _UART1_H + +#ifdef __cplusplus // Provide C++ Compatibility + extern "C" { +#endif + +/** + Section: Included Files +*/ + +#include +#include +#include +#include +#include + +/** + Section: Data Types +*/ + +/** UART1 Driver Hardware Flags + + @Summary + Specifies the status of the hardware receive or transmit + + @Description + This type specifies the status of the hardware receive or transmit. + More than one of these values may be OR'd together to create a complete + status value. To test a value of this type, the bit of interest must be + AND'ed with value and checked to see if the result is non-zero. +*/ +typedef enum +{ + /* Indicates that Receive buffer has data, at least one more character can be read */ + UART1_RX_DATA_AVAILABLE + /*DOM-IGNORE-BEGIN*/ = (1 << 0) /*DOM-IGNORE-END*/, + + /* Indicates that Receive buffer has overflowed */ + UART1_RX_OVERRUN_ERROR + /*DOM-IGNORE-BEGIN*/ = (1 << 1) /*DOM-IGNORE-END*/, + + /* Indicates that Framing error has been detected for the current character */ + UART1_FRAMING_ERROR + /*DOM-IGNORE-BEGIN*/ = (1 << 2) /*DOM-IGNORE-END*/, + + /* Indicates that Parity error has been detected for the current character */ + UART1_PARITY_ERROR + /*DOM-IGNORE-BEGIN*/ = (1 << 3) /*DOM-IGNORE-END*/, + + /* Indicates that Receiver is Idle */ + UART1_RECEIVER_IDLE + /*DOM-IGNORE-BEGIN*/ = (1 << 4) /*DOM-IGNORE-END*/, + + /* Indicates that the last transmission has completed */ + UART1_TX_COMPLETE + /*DOM-IGNORE-BEGIN*/ = (1 << 8) /*DOM-IGNORE-END*/, + + /* Indicates that Transmit buffer is full */ + UART1_TX_FULL + /*DOM-IGNORE-BEGIN*/ = (1 << 9) /*DOM-IGNORE-END*/ + +}UART1_STATUS; + + + +/** UART1 Driver Transfer Flags + + @Summary + Specifies the status of the receive or transmit + + @Description + This type specifies the status of the receive or transmit operation. + More than one of these values may be OR'd together to create a complete + status value. To test a value of this type, the bit of interest must be + AND'ed with value and checked to see if the result is non-zero. +*/ + +typedef enum +{ + /* Indicates that the core driver buffer is full */ + UART1_TRANSFER_STATUS_RX_FULL + /*DOM-IGNORE-BEGIN*/ = (1 << 0) /*DOM-IGNORE-END*/, + + /* Indicates that at least one byte of Data has been received */ + UART1_TRANSFER_STATUS_RX_DATA_PRESENT + /*DOM-IGNORE-BEGIN*/ = (1 << 1) /*DOM-IGNORE-END*/, + + /* Indicates that the core driver receiver buffer is empty */ + UART1_TRANSFER_STATUS_RX_EMPTY + /*DOM-IGNORE-BEGIN*/ = (1 << 2) /*DOM-IGNORE-END*/, + + /* Indicates that the core driver transmitter buffer is full */ + UART1_TRANSFER_STATUS_TX_FULL + /*DOM-IGNORE-BEGIN*/ = (1 << 3) /*DOM-IGNORE-END*/, + + /* Indicates that the core driver transmitter buffer is empty */ + UART1_TRANSFER_STATUS_TX_EMPTY + /*DOM-IGNORE-BEGIN*/ = (1 << 4) /*DOM-IGNORE-END*/ + +} UART1_TRANSFER_STATUS; + + +/** + Section: UART1 Driver Routines +*/ + +void _UART_1(void); + +/** + @Summary + Initializes the UART instance : 1 + + @Description + This routine initializes the UART driver instance for : 1 + index.0x8008 + This routine must be called before any other UART routine is called. + + @Preconditions + None. + + @Returns + None. + + @Param + None. + + @Comment + + + @Example + + const uint8_t writeBuffer[35] = "1234567890ABCDEFGHIJKLMNOP\n" ; + unsigned int numBytes = 0; + int writebufferLen = strlen((char *)writeBuffer); + UART1_Initialize(); + while(numBytes < writebufferLen) + { + int bytesToWrite = UART1_TransmitBufferSizeGet(); + numBytes = UART1_WriteBuffer ( writeBuffer+numBytes, bytesToWrite) ; + UART1_TasksTransmit ( ); + if (!UART1_TransmitBufferisFull()) + { + //continue other operation + } + } + + +*/ + +void UART1_Initialize(void); + +/** + @Summary + Read a byte of data from the UART1 + + @Description + This routine reads a byte of data from the UART1. + + @Preconditions + UART1_Initializer function should have been called + before calling this function. The transfer status should be checked to see + if the receiver is not empty before calling this function. + + @Param + None. + + @Returns + A data byte received by the driver. + + @Example + + char myBuffer[MY_BUFFER_SIZE]; + unsigned int numBytes; + + numBytes = 0; + do + { + if( UART1_TRANSFER_STATUS_RX_DATA_PRESENT & UART1_TransferStatusGet() ) + { + myBuffer[numBytes++] = UART1_Read(); + } + + // Do something else... + + } while( numBytes < MY_BUFFER_SIZE); + +*/ + +uint8_t UART1_Read( void); + +/** + @Summary + Returns the number of bytes read by the UART1 peripheral + + @Description + This routine returns the number of bytes read by the Peripheral and fills the + application read buffer with the read data. + + @Preconditions + UART1_Initializer function should have been called + before calling this function + + @Param + buffer - Buffer into which the data read from the UART1 + + @Param + numbytes - Total number of bytes that need to be read from the UART1 + (must be equal to or less than the size of the buffer) + + @Returns + Number of bytes actually copied into the caller's buffer or -1 if there + is an error. + + @Example + + char myBuffer[MY_BUFFER_SIZE]; + unsigned int numBytes; + UART1_TRANSFER_STATUS status ; + + // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. + + numBytes = 0; + while( numBytes < MY_BUFFER_SIZE); + { + status = UART1_TransferStatusGet ( ) ; + if (status & UART1_TRANSFER_STATUS_RX_FULL) + { + numBytes += UART1_ReadBuffer( myBuffer + numBytes, MY_BUFFER_SIZE - numBytes ) ; + if(numBytes < readbufferLen) + { + continue; + } + else + { + break; + } + } + else + { + continue; + } + + // Do something else... + } + +*/ + +unsigned int UART1_ReadBuffer( uint8_t *buffer , const unsigned int numbytes); + +/** + @Summary + Writes a byte of data to the UART1 + + @Description + This routine writes a byte of data to the UART1. + + @Preconditions + UART1_Initializer function should have been called + before calling this function. The transfer status should be checked to see if + transmitter is not full before calling this function. + + @Param + byte - Data byte to write to the UART1 + + @Returns + None. + + @Example + + char myBuffer[MY_BUFFER_SIZE]; + unsigned int numBytes; + + // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. + + numBytes = 0; + while( numBytes < MY_BUFFER_SIZE); + { + if( !(UART1_TRANSFER_STATUS_TX_FULL & UART1_TransferStatusGet()) ) + { + UART1_Write(handle, myBuffer[numBytes++]); + } + + // Do something else... + } + +*/ + +void UART1_Write( const uint8_t byte); + +/** + @Summary + Returns the number of bytes written into the internal buffer + + @Description + This API transfers the data from application buffer to internal buffer and + returns the number of bytes added in that queue + + @Preconditions + UART1_Initializer function should have been called + before calling this function + + @Example + + char myBuffer[MY_BUFFER_SIZE]; + unsigned int numBytes; + UART1_TRANSFER_STATUS status ; + + // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. + + numBytes = 0; + while( numBytes < MY_BUFFER_SIZE); + { + status = UART1_TransferStatusGet ( ) ; + if (status & UART1_TRANSFER_STATUS_TX_EMPTY) + { + numBytes += UART1_WriteBuffer ( myBuffer + numBytes, MY_BUFFER_SIZE - numBytes ) ; + if(numBytes < writebufferLen) + { + continue; + } + else + { + break; + } + } + else + { + continue; + } + + // Do something else... + } + +*/ + +unsigned int UART1_WriteBuffer( const uint8_t *buffer , const unsigned int numbytes ); + +/** + @Summary + Returns the transmitter and receiver transfer status + + @Description + This returns the transmitter and receiver transfer status.The returned status + may contain a value with more than one of the bits + specified in the UART1_TRANSFER_STATUS enumeration set. + The caller should perform an "AND" with the bit of interest and verify if the + result is non-zero (as shown in the example) to verify the desired status + bit. + + @Preconditions + UART1_Initializer function should have been called + before calling this function + + @Param + None. + + @Returns + A UART1_TRANSFER_STATUS value describing the current status + of the transfer. + + @Example + Refer to UART1_ReadBuffer and UART1_WriteBuffer for example + +*/ + +UART1_TRANSFER_STATUS UART1_TransferStatusGet (void ); + +/** + @Summary + Returns the character in the read sequence at the offset provided, without + extracting it + + @Description + This routine returns the character in the read sequence at the offset provided, + without extracting it + + @Param + None. + + @Example + + const uint8_t readBuffer[5]; + unsigned int data, numBytes = 0; + unsigned int readbufferLen = sizeof(readBuffer); + UART1_Initializer(); + + while(numBytes < readbufferLen) + { + UART1_TasksReceive ( ); + //Check for data at a particular place in the buffer + data = UART1_Peek(3); + if(data == 5) + { + //discard all other data if byte that is wanted is received. + //continue other operation + numBytes += UART1_ReadBuffer ( readBuffer + numBytes , readbufferLen ) ; + } + else + { + break; + } + } + + +*/ + +uint8_t UART1_Peek(uint16_t offset); + +/** + @Summary + Returns the size of the receive buffer + + @Description + This routine returns the size of the receive buffer. + + @Param + None. + + @Returns + Size of receive buffer. + + @Example + + const uint8_t readBuffer[5]; + unsigned int size, numBytes = 0; + unsigned int readbufferLen = sizeof(readBuffer); + UART1__Initializer(); + + while(size < readbufferLen) + { + UART1_TasksReceive ( ); + size = UART1_ReceiveBufferSizeGet(); + } + numBytes = UART1_ReadBuffer ( readBuffer , readbufferLen ) ; + + +*/ + +unsigned int UART1_ReceiveBufferSizeGet(void); + +/** + @Summary + Returns the size of the transmit buffer + + @Description + This routine returns the size of the transmit buffer. + + @Param + None. + + @Returns + Size of transmit buffer. + + @Example + Refer to UART1_Initializer(); for example. +*/ + +unsigned int UART1_TransmitBufferSizeGet(void); + +/** + @Summary + Returns the status of the receive buffer + + @Description + This routine returns if the receive buffer is empty or not. + + @Param + None. + + @Returns + True if the receive buffer is empty + False if the receive buffer is not empty + + @Example + + char myBuffer[MY_BUFFER_SIZE]; + unsigned int numBytes; + UART1_TRANSFER_STATUS status ; + + // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. + + numBytes = 0; + while( numBytes < MY_BUFFER_SIZE); + { + status = UART1_TransferStatusGet ( ) ; + if (!UART1_ReceiveBufferIsEmpty()) + { + numBytes += UART1_ReadBuffer( myBuffer + numBytes, MY_BUFFER_SIZE - numBytes ) ; + if(numBytes < readbufferLen) + { + continue; + } + else + { + break; + } + } + else + { + continue; + } + + // Do something else... + } + + +*/ + +bool UART1_ReceiveBufferIsEmpty (void); + +/** + @Summary + Returns the status of the transmit buffer + + @Description + This routine returns if the transmit buffer is full or not. + + @Param + None. + + @Returns + True if the transmit buffer is full + False if the transmit buffer is not full + + @Example + Refer to UART1_Initializer() for example. + +*/ + +bool UART1_TransmitBufferIsFull (void); + +/** + @Summary + Returns the transmitter and receiver status + + @Description + This returns the transmitter and receiver status. The returned status may + contain a value with more than one of the bits + specified in the UART1_STATUS enumeration set. + The caller should perform an "AND" with the bit of interest and verify if the + result is non-zero (as shown in the example) to verify the desired status + bit. + + @Preconditions + UART1_Initializer function should have been called + before calling this function + + @Param + None. + + @Returns + A UART1_STATUS value describing the current status + of the transfer. + + @Example + + while(!(UART1_StatusGet & UART1_TX_COMPLETE )) + { + // Wait for the tranmission to complete + } + +*/ + +UART1_STATUS UART1_StatusGet (void ); + +#ifdef __cplusplus // Provide C++ Compatibility + + } + +#endif + +#endif // _UART1_H + +/* + End of File +*/ + diff --git a/mcc_generated_files/uart1.hpp b/mcc_generated_files/uart1.hpp deleted file mode 100644 index db61d1e..0000000 --- a/mcc_generated_files/uart1.hpp +++ /dev/null @@ -1,624 +0,0 @@ -/** - UART1 Generated Driver API Header File - - @Company - Microchip Technology Inc. - - @File Name - uart1.h - - @Summary - This is the generated header file for the UART1 driver using PIC32MX MCUs - - @Description - This header file provides APIs for driver for UART1. - Generation Information : - Product Revision : PIC32MX MCUs - pic32mx : v1.35 - Device : PIC32MX470F512H - Driver Version : 0.5 - The generated drivers are tested against the following: - Compiler : XC32 1.42 - MPLAB : MPLAB X 3.55 -*/ - -/* - (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this - software and any derivatives exclusively with Microchip products. - - 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, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION - WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. - - 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. - - MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE - TERMS. -*/ - -#ifndef _UART1_H -#define _UART1_H - -/** - Section: Included Files -*/ - -#include -#include -#include -#include -#include -#ifdef __cplusplus // Provide C++ Compatibility - - extern "C" { - -#endif - -/** - Section: Data Types -*/ - -/** UART1 Driver Hardware Flags - - @Summary - Specifies the status of the hardware receive or transmit - - @Description - This type specifies the status of the hardware receive or transmit. - More than one of these values may be OR'd together to create a complete - status value. To test a value of this type, the bit of interest must be - AND'ed with value and checked to see if the result is non-zero. -*/ -typedef enum -{ - /* Indicates that Receive buffer has data, at least one more character can be read */ - UART1_RX_DATA_AVAILABLE - /*DOM-IGNORE-BEGIN*/ = (1 << 0) /*DOM-IGNORE-END*/, - - /* Indicates that Receive buffer has overflowed */ - UART1_RX_OVERRUN_ERROR - /*DOM-IGNORE-BEGIN*/ = (1 << 1) /*DOM-IGNORE-END*/, - - /* Indicates that Framing error has been detected for the current character */ - UART1_FRAMING_ERROR - /*DOM-IGNORE-BEGIN*/ = (1 << 2) /*DOM-IGNORE-END*/, - - /* Indicates that Parity error has been detected for the current character */ - UART1_PARITY_ERROR - /*DOM-IGNORE-BEGIN*/ = (1 << 3) /*DOM-IGNORE-END*/, - - /* Indicates that Receiver is Idle */ - UART1_RECEIVER_IDLE - /*DOM-IGNORE-BEGIN*/ = (1 << 4) /*DOM-IGNORE-END*/, - - /* Indicates that the last transmission has completed */ - UART1_TX_COMPLETE - /*DOM-IGNORE-BEGIN*/ = (1 << 8) /*DOM-IGNORE-END*/, - - /* Indicates that Transmit buffer is full */ - UART1_TX_FULL - /*DOM-IGNORE-BEGIN*/ = (1 << 9) /*DOM-IGNORE-END*/ - -}UART1_STATUS; - - - -/** UART1 Driver Transfer Flags - - @Summary - Specifies the status of the receive or transmit - - @Description - This type specifies the status of the receive or transmit operation. - More than one of these values may be OR'd together to create a complete - status value. To test a value of this type, the bit of interest must be - AND'ed with value and checked to see if the result is non-zero. -*/ - -typedef enum -{ - /* Indicates that the core driver buffer is full */ - UART1_TRANSFER_STATUS_RX_FULL - /*DOM-IGNORE-BEGIN*/ = (1 << 0) /*DOM-IGNORE-END*/, - - /* Indicates that at least one byte of Data has been received */ - UART1_TRANSFER_STATUS_RX_DATA_PRESENT - /*DOM-IGNORE-BEGIN*/ = (1 << 1) /*DOM-IGNORE-END*/, - - /* Indicates that the core driver receiver buffer is empty */ - UART1_TRANSFER_STATUS_RX_EMPTY - /*DOM-IGNORE-BEGIN*/ = (1 << 2) /*DOM-IGNORE-END*/, - - /* Indicates that the core driver transmitter buffer is full */ - UART1_TRANSFER_STATUS_TX_FULL - /*DOM-IGNORE-BEGIN*/ = (1 << 3) /*DOM-IGNORE-END*/, - - /* Indicates that the core driver transmitter buffer is empty */ - UART1_TRANSFER_STATUS_TX_EMPTY - /*DOM-IGNORE-BEGIN*/ = (1 << 4) /*DOM-IGNORE-END*/ - -} UART1_TRANSFER_STATUS; - - -/** - Section: UART1 Driver Routines -*/ - -void _UART_1(void); - -/** - @Summary - Initializes the UART instance : 1 - - @Description - This routine initializes the UART driver instance for : 1 - index. - This routine must be called before any other UART routine is called. - - @Preconditions - None. - - @Returns - None. - - @Param - None. - - @Comment - - - @Example - - const uint8_t writeBuffer[35] = "1234567890ABCDEFGHIJKLMNOP\n" ; - unsigned int numBytes = 0; - int writebufferLen = strlen((char *)writeBuffer); - UART1_Initialize(); - while(numBytes < writebufferLen) - { - int bytesToWrite = UART1_TransmitBufferSizeGet(); - numBytes = UART1_WriteBuffer ( writeBuffer+numBytes, bytesToWrite) ; - UART1_TasksTransmit ( ); - if (!UART1_TransmitBufferisFull()) - { - //continue other operation - } - } - - -*/ - -void UART1_Initialize(void); - -/** - @Summary - Read a byte of data from the UART1 - - @Description - This routine reads a byte of data from the UART1. - - @Preconditions - UART1_Initializer function should have been called - before calling this function. The transfer status should be checked to see - if the receiver is not empty before calling this function. - - @Param - None. - - @Returns - A data byte received by the driver. - - @Example - - char myBuffer[MY_BUFFER_SIZE]; - unsigned int numBytes; - - numBytes = 0; - do - { - if( UART1_TRANSFER_STATUS_RX_DATA_PRESENT & UART1_TransferStatusGet() ) - { - myBuffer[numBytes++] = UART1_Read(); - } - - // Do something else... - - } while( numBytes < MY_BUFFER_SIZE); - -*/ - -uint8_t UART1_Read( void); - -/** - @Summary - Returns the number of bytes read by the UART1 peripheral - - @Description - This routine returns the number of bytes read by the Peripheral and fills the - application read buffer with the read data. - - @Preconditions - UART1_Initializer function should have been called - before calling this function - - @Param - buffer - Buffer into which the data read from the UART1 - - @Param - numbytes - Total number of bytes that need to be read from the UART1 - (must be equal to or less than the size of the buffer) - - @Returns - Number of bytes actually copied into the caller's buffer or -1 if there - is an error. - - @Example - - char myBuffer[MY_BUFFER_SIZE]; - unsigned int numBytes; - UART1_TRANSFER_STATUS status ; - - // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. - - numBytes = 0; - while( numBytes < MY_BUFFER_SIZE); - { - status = UART1_TransferStatusGet ( ) ; - if (status & UART1_TRANSFER_STATUS_RX_FULL) - { - numBytes += UART1_ReadBuffer( myBuffer + numBytes, MY_BUFFER_SIZE - numBytes ) ; - if(numBytes < readbufferLen) - { - continue; - } - else - { - break; - } - } - else - { - continue; - } - - // Do something else... - } - -*/ - -unsigned int UART1_ReadBuffer( uint8_t *buffer , const unsigned int numbytes); - -/** - @Summary - Writes a byte of data to the UART1 - - @Description - This routine writes a byte of data to the UART1. - - @Preconditions - UART1_Initializer function should have been called - before calling this function. The transfer status should be checked to see if - transmitter is not full before calling this function. - - @Param - byte - Data byte to write to the UART1 - - @Returns - None. - - @Example - - char myBuffer[MY_BUFFER_SIZE]; - unsigned int numBytes; - - // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. - - numBytes = 0; - while( numBytes < MY_BUFFER_SIZE); - { - if( !(UART1_TRANSFER_STATUS_TX_FULL & UART1_TransferStatusGet()) ) - { - UART1_Write(handle, myBuffer[numBytes++]); - } - - // Do something else... - } - -*/ - -void UART1_Write( const uint8_t byte); - -/** - @Summary - Returns the number of bytes written into the internal buffer - - @Description - This API transfers the data from application buffer to internal buffer and - returns the number of bytes added in that queue - - @Preconditions - UART1_Initializer function should have been called - before calling this function - - @Example - - char myBuffer[MY_BUFFER_SIZE]; - unsigned int numBytes; - UART1_TRANSFER_STATUS status ; - - // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. - - numBytes = 0; - while( numBytes < MY_BUFFER_SIZE); - { - status = UART1_TransferStatusGet ( ) ; - if (status & UART1_TRANSFER_STATUS_TX_EMPTY) - { - numBytes += UART1_WriteBuffer ( myBuffer + numBytes, MY_BUFFER_SIZE - numBytes ) ; - if(numBytes < writebufferLen) - { - continue; - } - else - { - break; - } - } - else - { - continue; - } - - // Do something else... - } - -*/ - -unsigned int UART1_WriteBuffer( const uint8_t *buffer , const unsigned int numbytes ); - -/** - @Summary - Returns the transmitter and receiver transfer status - - @Description - This returns the transmitter and receiver transfer status.The returned status - may contain a value with more than one of the bits - specified in the UART1_TRANSFER_STATUS enumeration set. - The caller should perform an "AND" with the bit of interest and verify if the - result is non-zero (as shown in the example) to verify the desired status - bit. - - @Preconditions - UART1_Initializer function should have been called - before calling this function - - @Param - None. - - @Returns - A UART1_TRANSFER_STATUS value describing the current status - of the transfer. - - @Example - Refer to UART1_ReadBuffer and UART1_WriteBuffer for example - -*/ - -UART1_TRANSFER_STATUS UART1_TransferStatusGet (void ); - -/** - @Summary - Returns the character in the read sequence at the offset provided, without - extracting it - - @Description - This routine returns the character in the read sequence at the offset provided, - without extracting it - - @Param - None. - - @Example - - const uint8_t readBuffer[5]; - unsigned int data, numBytes = 0; - unsigned int readbufferLen = sizeof(readBuffer); - UART1_Initializer(); - - while(numBytes < readbufferLen) - { - UART1_TasksReceive ( ); - //Check for data at a particular place in the buffer - data = UART1_Peek(3); - if(data == 5) - { - //discard all other data if byte that is wanted is received. - //continue other operation - numBytes += UART1_ReadBuffer ( readBuffer + numBytes , readbufferLen ) ; - } - else - { - break; - } - } - - -*/ - -uint8_t UART1_Peek(uint16_t offset); - -/** - @Summary - Returns the size of the receive buffer - - @Description - This routine returns the size of the receive buffer. - - @Param - None. - - @Returns - Size of receive buffer. - - @Example - - const uint8_t readBuffer[5]; - unsigned int size, numBytes = 0; - unsigned int readbufferLen = sizeof(readBuffer); - UART1__Initializer(); - - while(size < readbufferLen) - { - UART1_TasksReceive ( ); - size = UART1_ReceiveBufferSizeGet(); - } - numBytes = UART1_ReadBuffer ( readBuffer , readbufferLen ) ; - - -*/ - -unsigned int UART1_ReceiveBufferSizeGet(void); - -/** - @Summary - Returns the size of the transmit buffer - - @Description - This routine returns the size of the transmit buffer. - - @Param - None. - - @Returns - Size of transmit buffer. - - @Example - Refer to UART1_Initializer(); for example. -*/ - -unsigned int UART1_TransmitBufferSizeGet(void); - -/** - @Summary - Returns the status of the receive buffer - - @Description - This routine returns if the receive buffer is empty or not. - - @Param - None. - - @Returns - True if the receive buffer is empty - False if the receive buffer is not empty - - @Example - - char myBuffer[MY_BUFFER_SIZE]; - unsigned int numBytes; - UART1_TRANSFER_STATUS status ; - - // Pre-initialize myBuffer with MY_BUFFER_SIZE bytes of valid data. - - numBytes = 0; - while( numBytes < MY_BUFFER_SIZE); - { - status = UART1_TransferStatusGet ( ) ; - if (!UART1_ReceiveBufferIsEmpty()) - { - numBytes += UART1_ReadBuffer( myBuffer + numBytes, MY_BUFFER_SIZE - numBytes ) ; - if(numBytes < readbufferLen) - { - continue; - } - else - { - break; - } - } - else - { - continue; - } - - // Do something else... - } - - -*/ - -bool UART1_ReceiveBufferIsEmpty (void); - -/** - @Summary - Returns the status of the transmit buffer - - @Description - This routine returns if the transmit buffer is full or not. - - @Param - None. - - @Returns - True if the transmit buffer is full - False if the transmit buffer is not full - - @Example - Refer to UART1_Initializer() for example. - -*/ - -bool UART1_TransmitBufferIsFull (void); - -/** - @Summary - Returns the transmitter and receiver status - - @Description - This returns the transmitter and receiver status. The returned status may - contain a value with more than one of the bits - specified in the UART1_STATUS enumeration set. - The caller should perform an "AND" with the bit of interest and verify if the - result is non-zero (as shown in the example) to verify the desired status - bit. - - @Preconditions - UART1_Initializer function should have been called - before calling this function - - @Param - None. - - @Returns - A UART1_STATUS value describing the current status - of the transfer. - - @Example - - while(!(UART1_StatusGet & UART1_TX_COMPLETE )) - { - // Wait for the tranmission to complete - } - -*/ - -UART1_STATUS UART1_StatusGet (void ); - -#ifdef __cplusplus // Provide C++ Compatibility - - } - -#endif - -#endif // _UART1_H - -/* - End of File -*/ - diff --git a/nbproject/Makefile-default.mk b/nbproject/Makefile-default.mk index a247945..4ebbf6b 100644 --- a/nbproject/Makefile-default.mk +++ b/nbproject/Makefile-default.mk @@ -57,17 +57,17 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE} DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE} # Source Files Quoted if spaced -SOURCEFILES_QUOTED_IF_SPACED=mcc_generated_files/interrupt_manager.cpp mcc_generated_files/mcc.cpp mcc_generated_files/pin_manager.cpp mcc_generated_files/uart1.cpp main.cpp Led.cpp +SOURCEFILES_QUOTED_IF_SPACED=mcc_generated_files/interrupt_manager.c mcc_generated_files/mcc.c mcc_generated_files/pin_manager.c mcc_generated_files/uart1.c main.cpp # Object Files Quoted if spaced -OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/mcc_generated_files/interrupt_manager.o ${OBJECTDIR}/mcc_generated_files/mcc.o ${OBJECTDIR}/mcc_generated_files/pin_manager.o ${OBJECTDIR}/mcc_generated_files/uart1.o ${OBJECTDIR}/main.o ${OBJECTDIR}/Led.o -POSSIBLE_DEPFILES=${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d ${OBJECTDIR}/mcc_generated_files/mcc.o.d ${OBJECTDIR}/mcc_generated_files/pin_manager.o.d ${OBJECTDIR}/mcc_generated_files/uart1.o.d ${OBJECTDIR}/main.o.d ${OBJECTDIR}/Led.o.d +OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/mcc_generated_files/interrupt_manager.o ${OBJECTDIR}/mcc_generated_files/mcc.o ${OBJECTDIR}/mcc_generated_files/pin_manager.o ${OBJECTDIR}/mcc_generated_files/uart1.o ${OBJECTDIR}/main.o +POSSIBLE_DEPFILES=${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d ${OBJECTDIR}/mcc_generated_files/mcc.o.d ${OBJECTDIR}/mcc_generated_files/pin_manager.o.d ${OBJECTDIR}/mcc_generated_files/uart1.o.d ${OBJECTDIR}/main.o.d # Object Files -OBJECTFILES=${OBJECTDIR}/mcc_generated_files/interrupt_manager.o ${OBJECTDIR}/mcc_generated_files/mcc.o ${OBJECTDIR}/mcc_generated_files/pin_manager.o ${OBJECTDIR}/mcc_generated_files/uart1.o ${OBJECTDIR}/main.o ${OBJECTDIR}/Led.o +OBJECTFILES=${OBJECTDIR}/mcc_generated_files/interrupt_manager.o ${OBJECTDIR}/mcc_generated_files/mcc.o ${OBJECTDIR}/mcc_generated_files/pin_manager.o ${OBJECTDIR}/mcc_generated_files/uart1.o ${OBJECTDIR}/main.o # Source Files -SOURCEFILES=mcc_generated_files/interrupt_manager.cpp mcc_generated_files/mcc.cpp mcc_generated_files/pin_manager.cpp mcc_generated_files/uart1.cpp main.cpp Led.cpp +SOURCEFILES=mcc_generated_files/interrupt_manager.c mcc_generated_files/mcc.c mcc_generated_files/pin_manager.c mcc_generated_files/uart1.c main.cpp CFLAGS= @@ -106,84 +106,72 @@ endif # ------------------------------------------------------------------------------------ # Rules for buildStep: compile ifeq ($(TYPE_IMAGE), DEBUG_RUN) -else -endif - -# ------------------------------------------------------------------------------------ -# Rules for buildStep: compileCPP -ifeq ($(TYPE_IMAGE), DEBUG_RUN) -${OBJECTDIR}/mcc_generated_files/interrupt_manager.o: mcc_generated_files/interrupt_manager.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/interrupt_manager.o: mcc_generated_files/interrupt_manager.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o mcc_generated_files/interrupt_manager.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o mcc_generated_files/interrupt_manager.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -${OBJECTDIR}/mcc_generated_files/mcc.o: mcc_generated_files/mcc.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/mcc.o: mcc_generated_files/mcc.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/mcc.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/mcc.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/mcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/mcc.o.d" -o ${OBJECTDIR}/mcc_generated_files/mcc.o mcc_generated_files/mcc.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/mcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/mcc.o.d" -o ${OBJECTDIR}/mcc_generated_files/mcc.o mcc_generated_files/mcc.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -${OBJECTDIR}/mcc_generated_files/pin_manager.o: mcc_generated_files/pin_manager.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/pin_manager.o: mcc_generated_files/pin_manager.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/pin_manager.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/pin_manager.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/pin_manager.o mcc_generated_files/pin_manager.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/pin_manager.o mcc_generated_files/pin_manager.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -${OBJECTDIR}/mcc_generated_files/uart1.o: mcc_generated_files/uart1.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/uart1.o: mcc_generated_files/uart1.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/uart1.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/uart1.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/uart1.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/uart1.o.d" -o ${OBJECTDIR}/mcc_generated_files/uart1.o mcc_generated_files/uart1.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) - -${OBJECTDIR}/main.o: main.cpp nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/main.o.d - @${RM} ${OBJECTDIR}/main.o - @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) - -${OBJECTDIR}/Led.o: Led.cpp nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/Led.o.d - @${RM} ${OBJECTDIR}/Led.o - @${FIXDEPS} "${OBJECTDIR}/Led.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/Led.o.d" -o ${OBJECTDIR}/Led.o Led.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/uart1.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/uart1.o.d" -o ${OBJECTDIR}/mcc_generated_files/uart1.o mcc_generated_files/uart1.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) else -${OBJECTDIR}/mcc_generated_files/interrupt_manager.o: mcc_generated_files/interrupt_manager.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/interrupt_manager.o: mcc_generated_files/interrupt_manager.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o mcc_generated_files/interrupt_manager.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/interrupt_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/interrupt_manager.o mcc_generated_files/interrupt_manager.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -${OBJECTDIR}/mcc_generated_files/mcc.o: mcc_generated_files/mcc.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/mcc.o: mcc_generated_files/mcc.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/mcc.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/mcc.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/mcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/mcc.o.d" -o ${OBJECTDIR}/mcc_generated_files/mcc.o mcc_generated_files/mcc.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/mcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/mcc.o.d" -o ${OBJECTDIR}/mcc_generated_files/mcc.o mcc_generated_files/mcc.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -${OBJECTDIR}/mcc_generated_files/pin_manager.o: mcc_generated_files/pin_manager.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/pin_manager.o: mcc_generated_files/pin_manager.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/pin_manager.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/pin_manager.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/pin_manager.o mcc_generated_files/pin_manager.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/pin_manager.o.d" -o ${OBJECTDIR}/mcc_generated_files/pin_manager.o mcc_generated_files/pin_manager.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -${OBJECTDIR}/mcc_generated_files/uart1.o: mcc_generated_files/uart1.cpp nbproject/Makefile-${CND_CONF}.mk +${OBJECTDIR}/mcc_generated_files/uart1.o: mcc_generated_files/uart1.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/mcc_generated_files" @${RM} ${OBJECTDIR}/mcc_generated_files/uart1.o.d @${RM} ${OBJECTDIR}/mcc_generated_files/uart1.o - @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/uart1.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/mcc_generated_files/uart1.o.d" -o ${OBJECTDIR}/mcc_generated_files/uart1.o mcc_generated_files/uart1.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/mcc_generated_files/uart1.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -MMD -MF "${OBJECTDIR}/mcc_generated_files/uart1.o.d" -o ${OBJECTDIR}/mcc_generated_files/uart1.o mcc_generated_files/uart1.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: compileCPP +ifeq ($(TYPE_IMAGE), DEBUG_RUN) ${OBJECTDIR}/main.o: main.cpp nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}" @${RM} ${OBJECTDIR}/main.o.d @${RM} ${OBJECTDIR}/main.o - @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -D__DEBUG -DPKOBSKDEPlatformTool=1 -fframe-base-loclist -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -${OBJECTDIR}/Led.o: Led.cpp nbproject/Makefile-${CND_CONF}.mk +else +${OBJECTDIR}/main.o: main.cpp nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/Led.o.d - @${RM} ${OBJECTDIR}/Led.o - @${FIXDEPS} "${OBJECTDIR}/Led.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/Led.o.d" -o ${OBJECTDIR}/Led.o Led.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) + @${RM} ${OBJECTDIR}/main.o.d + @${RM} ${OBJECTDIR}/main.o + @${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c ${MP_CPPC} $(MP_EXTRA_CC_PRE) -g -x c++ -c -mprocessor=$(MP_PROCESSOR_OPTION) -frtti -fexceptions -fno-check-new -fenforce-eh-specs -MMD -MF "${OBJECTDIR}/main.o.d" -o ${OBJECTDIR}/main.o main.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) endif diff --git a/nbproject/Makefile-genesis.properties b/nbproject/Makefile-genesis.properties index 4a2a718..15458e7 100644 --- a/nbproject/Makefile-genesis.properties +++ b/nbproject/Makefile-genesis.properties @@ -1,8 +1,8 @@ # -#Tue May 01 22:36:29 CEST 2018 +#Fri May 04 00:12:50 CEST 2018 default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=fcf9db1a3d46b4ef4e0a46afcbf02251 default.languagetoolchain.dir=/opt/microchip/xc32/v2.05/bin -configurations-xml=018face04edab806752607e0c7d190dd +configurations-xml=7da60577239442fa2d5644589c71b844 com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=c8c2915d32f5d7e4be49831bc9827ab0 default.languagetoolchain.version=2.05 host.platform=linux diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index dff0750..ced59db 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -7,12 +7,11 @@ - mcc_generated_files/interrupt_manager.hpp - mcc_generated_files/mcc.hpp - mcc_generated_files/pin_manager.hpp - mcc_generated_files/uart1.hpp + mcc_generated_files/interrupt_manager.h + mcc_generated_files/mcc.h + mcc_generated_files/pin_manager.h + mcc_generated_files/uart1.h - Led.hpp - mcc_generated_files/interrupt_manager.cpp - mcc_generated_files/mcc.cpp - mcc_generated_files/pin_manager.cpp - mcc_generated_files/uart1.cpp + mcc_generated_files/interrupt_manager.c + mcc_generated_files/mcc.c + mcc_generated_files/pin_manager.c + mcc_generated_files/uart1.c main.cpp - Led.cpp + diff --git a/nbproject/project.xml b/nbproject/project.xml index 9cfb6d3..2cba338 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -6,9 +6,9 @@ LiquidSmoke 26976773-df1d-4341-b350-948334294bed 0 - + c cpp - hpp + h ISO-8859-1 -- cgit v1.2.1