From 482612524d786c2c8f5dbabc9eb304508e504d89 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 1 May 2018 22:18:39 +0200 Subject: Add HAL generated by MCC --- main.cpp | 96 +++++++++++++++++++++++++++------------------------------------- 1 file changed, 41 insertions(+), 55 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 4189181..af9e2aa 100644 --- a/main.cpp +++ b/main.cpp @@ -1,58 +1,44 @@ - -// PIC32MX470F512H Configuration Bit Settings - -// 'C' source line config statements - -// DEVCFG3 -// USERID = No Setting -#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 = ON // Watchdog Timer Enable (WDT Enabled) -#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) - -// #pragma config statements should precede project file includes. -// Use project enums instead of #define for ON and OFF. - -#include -#include - -#include "Led.hpp" - - - -int main(int argc, char **argv) { +/* + * File: main.c + * Author: naopross + * + * Created on May 1, 2018, 6:18 PM + */ + +#include +#include + +#include "mcc_generated_files/mcc.hpp" + +/* + * + */ +int main(int argc, char** argv) +{ + char c; - Led redLed(Led::Color::RED); - - return 0; + SYSTEM_Initialize(); + + LED1_SetHigh(); + LED2_SetHigh(); + LED3_SetHigh(); + + // UART1_WriteBuffer("Hello\n\r", 7); + UART1_Write('S'); + UART1_Write('\n'); + UART1_Write('\r'); + + while (1) { + while (UART1_ReceiveBufferIsEmpty()); + + c = UART1_Read(); + LED1_Toggle(); + + UART1_Write(c); + UART1_Write('\n'); + UART1_Write('\r'); + } + + return (EXIT_SUCCESS); } -- cgit v1.2.1