From 3056e083d78b6edec6bab1ebac3fa9e3708644d7 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 20 Aug 2015 22:37:23 +0200 Subject: Initial commit --- firmware/src/T6963C_PIC | 1 + firmware/src/app.c | 78 ++++ firmware/src/app.h | 115 ++++++ firmware/src/editor.c | 87 +++++ firmware/src/editor.h | 50 +++ firmware/src/main.c | 92 +++++ firmware/src/screen.c | 38 ++ firmware/src/screen.h | 34 ++ .../src/system_config/default/configuration.xml | 113 ++++++ firmware/src/system_config/default/default.mhc | 433 +++++++++++++++++++++ .../framework/system/clk/src/sys_clk_static.c | 283 ++++++++++++++ .../default/framework/system/clk/sys_clk_static.h | 65 ++++ .../framework/system/ports/src/sys_ports_static.c | 130 +++++++ firmware/src/system_config/default/system_config.h | 165 ++++++++ .../src/system_config/default/system_definitions.h | 119 ++++++ .../src/system_config/default/system_exceptions.c | 143 +++++++ firmware/src/system_config/default/system_init.c | 210 ++++++++++ .../src/system_config/default/system_interrupt.c | 77 ++++ firmware/src/system_config/default/system_tasks.c | 91 +++++ firmware/src/t6963c_specific.c | 40 ++ firmware/src/t6963c_specific.h | 68 ++++ 21 files changed, 2432 insertions(+) create mode 160000 firmware/src/T6963C_PIC create mode 100644 firmware/src/app.c create mode 100644 firmware/src/app.h create mode 100644 firmware/src/editor.c create mode 100644 firmware/src/editor.h create mode 100644 firmware/src/main.c create mode 100644 firmware/src/screen.c create mode 100644 firmware/src/screen.h create mode 100644 firmware/src/system_config/default/configuration.xml create mode 100644 firmware/src/system_config/default/default.mhc create mode 100644 firmware/src/system_config/default/framework/system/clk/src/sys_clk_static.c create mode 100644 firmware/src/system_config/default/framework/system/clk/sys_clk_static.h create mode 100644 firmware/src/system_config/default/framework/system/ports/src/sys_ports_static.c create mode 100644 firmware/src/system_config/default/system_config.h create mode 100644 firmware/src/system_config/default/system_definitions.h create mode 100644 firmware/src/system_config/default/system_exceptions.c create mode 100644 firmware/src/system_config/default/system_init.c create mode 100644 firmware/src/system_config/default/system_interrupt.c create mode 100644 firmware/src/system_config/default/system_tasks.c create mode 100644 firmware/src/t6963c_specific.c create mode 100644 firmware/src/t6963c_specific.h (limited to 'firmware/src') diff --git a/firmware/src/T6963C_PIC b/firmware/src/T6963C_PIC new file mode 160000 index 0000000..d5a6e4b --- /dev/null +++ b/firmware/src/T6963C_PIC @@ -0,0 +1 @@ +Subproject commit d5a6e4bd67cdc8e03025c17590d612178b8f84d5 diff --git a/firmware/src/app.c b/firmware/src/app.c new file mode 100644 index 0000000..635c46f --- /dev/null +++ b/firmware/src/app.c @@ -0,0 +1,78 @@ +/******************************************************************************* + MPLAB Harmony Application Source File + + File Name: + app.c + + Summary: + This file contains the source code for the MPLAB Harmony application. + + Description: + This file contains the source code for the MPLAB Harmony application. It + implements the logic of the application's state machine and it may call + API routines of other MPLAB Harmony modules in the system, such as drivers, + system services, and middleware. However, it does not call any of the + system interfaces (such as the "Initialize" and "Tasks" functions) of any of + the modules in the system or make any assumptions about when those functions + are called. That is the responsibility of the configuration-specific system + files. + *******************************************************************************/ + +#include "app.h" +#include "T6963C_PIC/t6963c.h" +#include "t6963c_specific.h" +#include "T6963C_PIC/terminal.h" + +APP_DATA appData; +static Terminal* term; + +void APP_Initialize (void) { + t6963c_init(); + t6963c_clear(); + + term = terminal.construct(t6963c_rows * t6963c_columns); + term->update = t6963c_update_terminal; + + appData.state = APP_STATE_MAIN; +} + +void APP_Tasks (void) { + /* Check the application's current state. */ + switch (appData.state) { + /* Application's main state. */ + case APP_STATE_MAIN: { + if (term != NULL) { + unsigned char* string = "me@pic:~$ ls\nme@pic:~$ mkdir docs\nme@pic:~$ cd docs/\nme@pic:~/docs$ ls\nme@pic:~/docs$ touch doc.txt\nme@pic:~/docs$ ls\ndoc.txt\nme@pic:~/docs$ cat doc.txt\nme@pic:~/docs$ echo hello > doc.txt\nme@pic:~/docs$ cat doc.txt\nhello\nme@pic:~/docs$ cd ..\nme@pic:~$ tree -fFi\n.\n./docs/\n./docs/doc.txt\n\n1 directory, 1 file\nme@pic:~$ rm -r docs/\n"; + unsigned short i, j; + unsigned char state = 0; // 0 = quick, 1 = slow + for (i = 0; string[i]; i++) { + if (!terminal.appendChar(term, string[i])) { + terminal.free(term); + t6963c_clear(); + t6963c_set_address(5,5); + t6963c_writeString("ERROR"); + while (1); + } + if (string[i] == '$') { + state = 1; + terminal.appendChar(term, string[++i]); + for (j = 0; j < 10000; j++) + delay_ns(60000); + } else if (string[i] == '\n') { + state = 0; + } + if (state) + for (j = 0; j < 800; j++) + delay_ns(60000); + } + } + + break; + } + + default: { + /* TODO: Handle error in application's state machine. */ + break; + } + } +} diff --git a/firmware/src/app.h b/firmware/src/app.h new file mode 100644 index 0000000..50db318 --- /dev/null +++ b/firmware/src/app.h @@ -0,0 +1,115 @@ +/******************************************************************************* + MPLAB Harmony Application Header File + + File Name: + app.h + + Summary: + This header file provides prototypes and definitions for the application. + + Description: + This header file provides function prototypes and data type definitions for + the application. Some of these are required by the system (such as the + "APP_Initialize" and "APP_Tasks" prototypes) and some of them are only used + internally by the application (such as the "APP_STATES" definition). Both + are defined here for convenience. +*******************************************************************************/ + +#ifndef _APP_H +#define _APP_H + +#include +#include +#include +#include +#include "system_config.h" +#include "system_definitions.h" + +#ifdef __cplusplus // Provide C++ Compatibility + +extern "C" { + +#endif + +typedef enum +{ + APP_STATE_MAIN=0, + +} APP_STATES; + + +typedef struct +{ + APP_STATES state; +} APP_DATA; + +/******************************************************************************* + Function: + void APP_Initialize ( void ) + + Summary: + MPLAB Harmony application initialization routine. + + Description: + This function initializes the Harmony application. It places the + application in its initial state and prepares it to run so that its + APP_Tasks function can be called. + + Precondition: + All other system initialization routines should be called before calling + this routine (in "SYS_Initialize"). + + Parameters: + None. + + Returns: + None. + + Example: + + APP_Initialize(); + + + Remarks: + This routine must be called from the SYS_Initialize function. +*/ + +void APP_Initialize ( void ); + +/******************************************************************************* + Function: + void APP_Tasks ( void ) + + Summary: + MPLAB Harmony Demo application tasks function + + Description: + This routine is the Harmony Demo application's tasks function. It + defines the application's state machine and core logic. + + Precondition: + The system and application initialization ("SYS_Initialize") should be + called before calling this. + + Parameters: + None. + + Returns: + None. + + Example: + + APP_Tasks(); + + + Remarks: + This routine must be called from SYS_Tasks() routine. + */ + +void APP_Tasks( void ); + +#endif /* _APP_H */ + +#ifdef __cplusplus +} +#endif diff --git a/firmware/src/editor.c b/firmware/src/editor.c new file mode 100644 index 0000000..7b5eeb1 --- /dev/null +++ b/firmware/src/editor.c @@ -0,0 +1,87 @@ +#include "editor.h" +#include + +Editor newEditor(unsigned int size) { + unsigned char* block = calloc(1, size + 1); + if (block == NULL) + return NULL; + + Editor editor; + editor.front.start = editor.front.end = block; + editor.back.start = editor.back.end = block + size; + + return editor; +} + +inline void freeEditor(Editor editor) { + free(editor.front.start); +} + +inline unsigned int getFreeSpace(Editor editor) { + return editor.back.start - editor.front.end; +} + +inline unsigned isFull(Editor editor) { + return getFreeSpace(editor) == NULL; +} + +unsigned char* getNearCursor(Editor editor, signed int start, signed int end) { + unsigned char* block = (unsigned char*) calloc(1, end - start + 1); + if (block == NULL) + return NULL; + + memcpy(block, editor.front.end + start, min(end - start, max(0, 0 - start))); + memcpy(block + max(0, 0 - start), editor.back.start + max(0, start), end - max(0, start)); + return block; +} + +void moveCursor(Editor editor, signed int change) { + if (change > 0) { + change = max(editor.back.end - editor.back.start, change); + memcpy(editor.front.end, editor.back.start, change); + editor.front.end += change; + editor.back.start += change; + } else if (change < 0) { + change = max(editor.front.end - editor.front.start, 0 - change); + memcpy(editor.back.start - change, editor.front.end - change, change); + editor.front.end -= change; + editor.back.start -= change; + } +} + +inline void writeAtCursor(Editor editor, unsigned char character) { + editor.front.end++; + *editor.front.end = character; +} + +void writeStringAtCursor(Editor editor, unsigned char* string) { + editor.front.end++; + memcpy(editor.front.end, string, strlen(string)); + editor.front.end += strlen(string) - 1; +} + +inline void writeAfterCursor(Editor editor, unsigned char character) { + editor.back.start--; + *editor.back.start = character; +} + +void writeStringAfterCursor(Editor editor, unsigned char* string) { + editor.back.start -= strlen(string); + memcpy(editor.back.start, string, strlen(string)); +} + +inline void deleteAtCursor(Editor editor) { + editor.front.end--; +} + +inline void deleteNAtCursor(Editor editor, unsigned int length) { + editor.front.end -= length; +} + +inline void deleteAfterCursor(Editor editor) { + editor.back.start++; +} + +inline void deleteNAfterCursor(Editor editor, unsigned int length) { + editor.back.start += length; +} diff --git a/firmware/src/editor.h b/firmware/src/editor.h new file mode 100644 index 0000000..4d5cac2 --- /dev/null +++ b/firmware/src/editor.h @@ -0,0 +1,50 @@ +/* + * File: editor.h + * Author: camilstaps + * + * Created on August 18, 2015, 11:25 PM + */ + +#ifndef EDITOR_H +#define EDITOR_H + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct { + unsigned char* start; + unsigned char* end; +} EditorArea; + +typedef struct { + EditorArea front; + EditorArea back; +} Editor; + +Editor newEditor(unsigned int size); +inline void freeEditor(Editor editor); + +inline unsigned int getFreeSpace(Editor editor); +inline unsigned isFull(Editor editor); + +unsigned char* getNearCursor(Editor editor, signed int start, signed int end); +void moveCursor(Editor editor, signed int change); + +inline void writeAtCursor(Editor editor, unsigned char character); +void writeStringAtCursor(Editor editor, unsigned char* string); +inline void writeAfterCursor(Editor editor, unsigned char character); +void writeStringAfterCursor(Editor editor, unsigned char* string); + +inline void deleteAtCursor(Editor editor); +inline void deleteNAtCursor(Editor editor, unsigned int length); +inline void deleteAfterCursor(Editor editor); +inline void deleteNAfterCursor(Editor editor, unsigned int length); + +#ifdef __cplusplus +} +#endif + +#endif /* EDITOR_H */ + diff --git a/firmware/src/main.c b/firmware/src/main.c new file mode 100644 index 0000000..50de2fd --- /dev/null +++ b/firmware/src/main.c @@ -0,0 +1,92 @@ +/******************************************************************************* + MPLAB Harmony Project Main Source File + + Company: + Microchip Technology Inc. + + File Name: + main.c + + Summary: + This file contains the "main" function for an MPLAB Harmony project. + + Description: + This file contains the "main" function for an MPLAB Harmony project. The + "main" function calls the "SYS_Initialize" function to initialize the state + machines of all MPLAB Harmony modules in the system and it calls the + "SYS_Tasks" function from within a system-wide "super" loop to maintain + their correct operation. These two functions are implemented in + configuration-specific files (usually "system_init.c" and "system_tasks.c") + in a configuration-specific folder under the "src/system_config" folder + within this project's top-level folder. An MPLAB Harmony project may have + more than one configuration, each contained within it's own folder under + the "system_config" folder. + *******************************************************************************/ + +// DOM-IGNORE-BEGIN +/******************************************************************************* +Copyright (c) 2013-2014 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. + *******************************************************************************/ +// DOM-IGNORE-END + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Included Files +// ***************************************************************************** +// ***************************************************************************** + +#include // Defines NULL +#include // Defines true +#include // Defines EXIT_FAILURE +#include "system/common/sys_module.h" // SYS function prototypes + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Main Entry Point +// ***************************************************************************** +// ***************************************************************************** + +int main ( void ) +{ + /* Initialize all MPLAB Harmony modules, including application(s). */ + SYS_Initialize ( NULL ); + + + while ( true ) + { + /* Maintain state machines of all polled MPLAB Harmony modules. */ + SYS_Tasks ( ); + + } + + /* Execution should not come here during normal operation */ + + return ( EXIT_FAILURE ); +} + + +/******************************************************************************* + End of File +*/ + diff --git a/firmware/src/screen.c b/firmware/src/screen.c new file mode 100644 index 0000000..06f038c --- /dev/null +++ b/firmware/src/screen.c @@ -0,0 +1,38 @@ +#include "screen.h" +#include +#include + +Screen* newScreen(unsigned short rows, unsigned short columns, void (*update)(Screen)) { + unsigned short i; + + Screen* screen = calloc(1, sizeof(Screen)); + if (screen == NULL) + return NULL; + + screen->data = (unsigned char**) calloc(rows, sizeof(unsigned char*)); + if (screen->data == NULL) + return NULL; + for (i = 0; i < rows; i++) { + screen->data[i] = (unsigned char*) calloc(columns + 1, sizeof(unsigned char)); + if (screen->data[i] == NULL) { + for (; i >= 0; i--) + free(screen->data[i]); + free(screen->data); + return NULL; + } + } + + screen->rows = rows; + screen->columns = columns; + screen->first_visible_row = screen->first_visible_column = NULL; + screen->cursor_x = screen->cursor_y = NULL; + screen->update = update; + return screen; +} + +inline void freeScreen(Screen* screen) { + unsigned short i; + for (i = 0; i < screen->rows; i++) + free(screen->data[i]); + free(screen->data); +} diff --git a/firmware/src/screen.h b/firmware/src/screen.h new file mode 100644 index 0000000..b210619 --- /dev/null +++ b/firmware/src/screen.h @@ -0,0 +1,34 @@ +/* + * File: screen.h + * Author: camilstaps + * + * Created on August 19, 2015, 12:01 AM + */ + +#ifndef SCREEN_H +#define SCREEN_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct Screen { + unsigned short rows, columns, + first_visible_row, first_visible_column, + cursor_x, cursor_y; + unsigned char** data; + void (*update)(struct Screen); +} Screen; + +Screen* newScreen(unsigned short rows, unsigned short columns, void (*update)(Screen)); +inline void freeScreen(Screen* screen); + +//void writeOnS +//void appendToScreen + +#ifdef __cplusplus +} +#endif + +#endif /* SCREEN_H */ + diff --git a/firmware/src/system_config/default/configuration.xml b/firmware/src/system_config/default/configuration.xml new file mode 100644 index 0000000..4606dcc --- /dev/null +++ b/firmware/src/system_config/default/configuration.xml @@ -0,0 +1,113 @@ + + + + + + + + + + sys_devcon_cache_pic32mz.S + Source Files/framework/system/devcon/src + + + sys_module.h + Header Files/framework/system/common + + + sys_devcon.c + Source Files/framework/system/devcon/src + + + sys_devcon_cache.h + Header Files/framework/system/devcon + + + sys_common.h + Header Files/framework/system/common + + + sys_ports.h + Header Files/framework/system/ports + + + system.h + Header Files/framework/system + + + sys_ports.c + Source Files/framework/system/ports/src + + + sys_devcon.h + Header Files/framework/system/devcon + + + sys_devcon_pic32mz.c + Source Files/framework/system/devcon/src + + + + + + + + + + + + + + + + + + + + + diff --git a/firmware/src/system_config/default/default.mhc b/firmware/src/system_config/default/default.mhc new file mode 100644 index 0000000..94fdc77 --- /dev/null +++ b/firmware/src/system_config/default/default.mhc @@ -0,0 +1,433 @@ +# +# Configuration generated by Microchip Harmony Configurator (MHC) v1.0.6.12 +# Project name: PIC32MZ_harmony_tryout +# Configuration: default +# Device: PIC32MZ2048ECG064 +# Harmony version: 1.06 +# +# +# from $PROJECT_FIRMWARE_DIRECTORY/$PROJECT_NAME.hconfig +# +CONFIG_APP_INSTANCES=1 +# +# from $HARMONY_VERSION_PATH/utilities/mhc/config/app_name_idx.ftl +# +CONFIG_APP_MENU_IDX0=y +CONFIG_APP_NAME_0="app" +# +# from $PROJECT_FIRMWARE_DIRECTORY/$PROJECT_NAME.hconfig +# +CONFIG_USE_EXCEPTION_HANDLER=y +CONFIG_EXCEPTION_USE_SYS_DEBUG=y +CONFIG_EXCEPTION_BREAKPOINT=y +# +# from $HARMONY_VERSION_PATH/framework/bluetooth/config/bluetooth.hconfig +# +CONFIG_USE_BLUETOOTH_LIBRARIES=n +# +# from $HARMONY_VERSION_PATH/framework/bootloader/config/bootloader.hconfig +# +CONFIG_USE_BOOTLOADER=n +# +# from $HARMONY_VERSION_PATH/framework/crypto/config/crypto.hconfig +# +CONFIG_USE_CRYPTO_LIB=n +# +# from $HARMONY_VERSION_PATH/framework/driver/adc/config/drv_adc.hconfig +# +CONFIG_USE_DRV_ADC=n +# +# from $HARMONY_VERSION_PATH/framework/driver/camera/config/drv_camera.hconfig +# +CONFIG_USE_DRV_CAMERA=n +# +# from $HARMONY_VERSION_PATH/framework/driver/cmp/config/drv_cmp.hconfig +# +CONFIG_DRV_CVREF_ENABLE=n +CONFIG_USE_DRV_CMP=n +# +# from $HARMONY_VERSION_PATH/framework/driver/codec/config/drv_codec.hconfig +# +CONFIG_SELECT_DRV_AK4384=n +CONFIG_SELECT_DRV_AK4642=n +CONFIG_SELECT_DRV_AK4645=n +CONFIG_SELECT_DRV_AK4953=n +# +# from $HARMONY_VERSION_PATH/framework/driver/encx24j600/config/drv_encx24j600.hconfig +# +CONFIG_DRV_ENCX24J600_USE_DRIVER=n +# +# from $HARMONY_VERSION_PATH/framework/tcpip/config/tcpip_mac.hconfig +# +CONFIG_TCPIP_USE_ETH_MAC=n +# +# from $HARMONY_VERSION_PATH/framework/driver/gfx/controller/lcc/config/drv_gfx_lcc.hconfig +# +CONFIG_USE_DRV_GFX_LCC=n +# +# from $HARMONY_VERSION_PATH/framework/driver/gfx/controller/otm2201a/config/drv_gfx_otm2201a.hconfig +# +CONFIG_USE_DRV_GFX_OTM2201A=n +# +# from $HARMONY_VERSION_PATH/framework/driver/gfx/controller/ssd1926/config/drv_gfx_ssd1926.hconfig +# +CONFIG_USE_DRV_GFX_SSD1926=n +# +# from $HARMONY_VERSION_PATH/framework/driver/gfx/controller/ssd1289/config/drv_gfx_ssd1289.hconfig +# +CONFIG_USE_DRV_GFX_SSD1289=n +# +# from $HARMONY_VERSION_PATH/framework/driver/gfx/controller/s1d13517/config/drv_gfx_s1d13517.hconfig +# +CONFIG_USE_DRV_GFX_S1D13517=n +# +# from $HARMONY_VERSION_PATH/framework/driver/gfx/controller/tft002/config/drv_gfx_tft002.hconfig +# +CONFIG_USE_DRV_GFX_TFT002=n +# +# from $HARMONY_VERSION_PATH/framework/driver/gfx/display/config/drv_gfx_display.hconfig +# +CONFIG_USE_DRV_GFX_DISPLAY=n +# +# from $HARMONY_VERSION_PATH/framework/driver/i2c/config/drv_i2c.hconfig +# +CONFIG_USE_DRV_I2C=n +# +# from $HARMONY_VERSION_PATH/framework/driver/i2s/config/drv_i2s.hconfig +# +CONFIG_USE_DRV_I2S=n +# +# from $HARMONY_VERSION_PATH/framework/driver/ic/config/drv_ic.hconfig +# +CONFIG_USE_DRV_IC=n +# +# from $HARMONY_VERSION_PATH/framework/driver/nvm/config/drv_nvm.hconfig +# +CONFIG_USE_DRV_NVM=n +# +# from $HARMONY_VERSION_PATH/framework/driver/oc/config/drv_oc.hconfig +# +CONFIG_USE_DRV_OC=n +# +# from $HARMONY_VERSION_PATH/framework/driver/pmp/config/drv_pmp.hconfig +# +CONFIG_USE_DRV_PMP=n +# +# from $HARMONY_VERSION_PATH/framework/driver/rtcc/config/drv_rtcc.hconfig +# +CONFIG_USE_DRV_RTCC=n +# +# from $HARMONY_VERSION_PATH/framework/driver/sample/config/drv_sample.hconfig +# +CONFIG_USE_DRV_SAMPLE=n +# +# from $HARMONY_VERSION_PATH/framework/driver/sdcard/config/drv_sdcard.hconfig +# +CONFIG_USE_DRV_SDCARD=n +# +# from $HARMONY_VERSION_PATH/framework/driver/spi/config/drv_spi.hconfig +# +CONFIG_DRV_SPI_USE_DRIVER=n +# +# from $HARMONY_VERSION_PATH/framework/driver/sqi/config/drv_sqi.hconfig +# +CONFIG_DRV_SQI_USE_DRIVER=n +# +# from $HARMONY_VERSION_PATH/framework/driver/spi_flash/sst25vf016b/config/drv_sst25vf016b.hconfig +# +CONFIG_USE_DRV_SST25VF016B=n +# +# from $HARMONY_VERSION_PATH/framework/driver/spi_flash/sst25vf020b/config/drv_sst25vf020b.hconfig +# +CONFIG_USE_DRV_SST25VF020B=n +# +# from $HARMONY_VERSION_PATH/framework/driver/spi_flash/sst25vf064c/config/drv_sst25vf064c.hconfig +# +CONFIG_USE_DRV_SST25VF064C=n +# +# from $HARMONY_VERSION_PATH/framework/driver/tmr/config/drv_tmr.hconfig +# +CONFIG_USE_DRV_TMR=n +# +# from $HARMONY_VERSION_PATH/framework/driver/touch/adc10bit/config/drv_adc10bit.hconfig +# +CONFIG_USE_DRV_TOUCH_ADC10BIT=n +# +# from $HARMONY_VERSION_PATH/framework/driver/touch/ar1020/config/drv_ar1020.hconfig +# +CONFIG_USE_DRV_TOUCH_AR1020=n +# +# from $HARMONY_VERSION_PATH/framework/driver/touch/mtch6301/config/drv_mtch6301.hconfig +# +CONFIG_USE_DRV_TOUCH_MTCH6301=n +# +# from $HARMONY_VERSION_PATH/framework/driver/usart/config/drv_usart.hconfig +# +CONFIG_USE_DRV_USART=n +# +# from $HARMONY_VERSION_PATH/framework/driver/wifi/config/drv_wifi.hconfig +# +CONFIG_USE_DRV_WIFI=n +# +# from $HARMONY_VERSION_PATH/framework/gfx/config/gfx.hconfig +# +CONFIG_USE_GFX_STACK=n +# +# from $HARMONY_VERSION_PATH/framework/math/dsp/config/dsp.hconfig +# +CONFIG_USE_DSP=n +# +# from $HARMONY_VERSION_PATH/framework/math/libq/config/libq.hconfig +# +CONFIG_USE_LIBQ=n +# +# from $HARMONY_VERSION_PATH/framework/osal/config/osal.hconfig +# +CONFIG_USE_OSAL=y +# +# from $HARMONY_VERSION_PATH/framework/peripheral/config/peripheral.hconfig +# +CONFIG_PERIPHERAL_LIB=y +# +# from $HARMONY_VERSION_PATH/framework/system/clk/config/sys_clk.hconfig +# +CONFIG_USE_SYS_CLK=y +CONFIG_SYS_CLK_MODE="STATIC" +CONFIG_SYS_CLK_PBDIV0_MZ=2 +CONFIG_SYS_CLK_PBCLK1_ENABLE=n +CONFIG_SYS_CLK_PBCLK2_ENABLE=y +CONFIG_SYS_CLK_PBDIV2=2 +CONFIG_SYS_CLK_PBCLK3_ENABLE=y +CONFIG_SYS_CLK_PBDIV3=2 +CONFIG_SYS_CLK_PBCLK4_ENABLE=n +CONFIG_SYS_CLK_PBCLK6_ENABLE=y +CONFIG_SYS_CLK_PBDIV6=1 +CONFIG_SYS_CLK_PBCLK7_ENABLE=n +CONFIG_SYS_CLK_REFCLK0_ENABLE=n +CONFIG_SYS_CLK_REFCLK1_ENABLE=n +CONFIG_SYS_CLK_REFCLK2_ENABLE=n +CONFIG_SYS_CLK_REFCLK3_ENABLE=n +CONFIG_SYS_CLK_CONFIG_PRIMARY_XTAL="24000000" +CONFIG_SYS_CLK_CONFIG_SECONDARY_XTAL="32768" +CONFIG_SYS_CLK_FREQ="80000000" +CONFIG_SYS_CLK_PBCLK0_FREQ="40000000" +CONFIG_SYS_CLK_PBCLK2_FREQ="40000000" +CONFIG_SYS_CLK_PBCLK3_FREQ="40000000" +CONFIG_SYS_CLK_PBCLK6_FREQ="80000000" +# +# from $HARMONY_VERSION_PATH/framework/system/command/config/sys_command.hconfig +# +CONFIG_USE_SYS_COMMAND=n +# +# from $HARMONY_VERSION_PATH/framework/system/common/config/sys_common.hconfig +# +CONFIG_USE_SYS_COMMON=y +CONFIG_SYS_BUFFER=n +CONFIG_SYS_QUEUE=n +# +# from $HARMONY_VERSION_PATH/framework/system/console/config/sys_console.hconfig +# +CONFIG_USE_SYS_CONSOLE=n +# +# from $HARMONY_VERSION_PATH/framework/system/debug/config/sys_debug.hconfig +# +CONFIG_USE_SYS_DEBUG=n +# +# from $HARMONY_VERSION_PATH/framework/system/devcon/config/sys_devcon.hconfig +# +CONFIG_USE_SYS_DEVCON=y +CONFIG_SYS_DEVCON_USE_JTAG=n +CONFIG_SYS_DEVCON_USE_TRACE=n +# +# from $HARMONY_VERSION_PATH/framework/system/dma/config/sys_dma.hconfig +# +CONFIG_USE_SYS_DMA=n +# +# from $HARMONY_VERSION_PATH/framework/system/fs/config/sys_fs.hconfig +# +CONFIG_USE_SYS_FS=n +# +# from $HARMONY_VERSION_PATH/framework/system/int/config/sys_int.hconfig +# +CONFIG_USE_SYS_INT=n +CONFIG_USE_EXT_INT=n +# +# from $HARMONY_VERSION_PATH/framework/system/msg/config/sys_msg.hconfig +# +CONFIG_USE_SYS_MSG=n +# +# from $HARMONY_VERSION_PATH/framework/system/ports/config/sys_ports.hconfig +# +CONFIG_USE_SYS_PORTS=y +CONFIG_COMPONENT_PACKAGE="TQFP" +CONFIG_USE_SYS_PORTS_CN_INTERRUPT=n +# +# from $HARMONY_VERSION_PATH/framework/system/ports/config/sys_ports_idx.ftl +# +CONFIG_USE_PORT_B=y +CONFIG_SYS_PORT_B_ANSEL=0x0 +CONFIG_SYS_PORT_B_TRIS=0x0 +CONFIG_SYS_PORT_B_LAT=0x0 +CONFIG_SYS_PORT_B_ODC=0x0 +CONFIG_SYS_PORT_B_CNPU=0x0 +CONFIG_SYS_PORT_B_CNPD=0x0 +CONFIG_SYS_PORT_B_CNEN=0x0 +CONFIG_USE_PORT_C=y +CONFIG_SYS_PORT_C_ANSEL=0x0 +CONFIG_SYS_PORT_C_TRIS=0xf000 +CONFIG_SYS_PORT_C_LAT=0x0 +CONFIG_SYS_PORT_C_ODC=0x0 +CONFIG_SYS_PORT_C_CNPU=0x0 +CONFIG_SYS_PORT_C_CNPD=0x0 +CONFIG_SYS_PORT_C_CNEN=0x0 +CONFIG_USE_PORT_D=y +CONFIG_SYS_PORT_D_ANSEL=0x0 +CONFIG_SYS_PORT_D_TRIS=0xe3f +CONFIG_SYS_PORT_D_LAT=0x0 +CONFIG_SYS_PORT_D_ODC=0x0 +CONFIG_SYS_PORT_D_CNPU=0xe3f +CONFIG_SYS_PORT_D_CNPD=0x0 +CONFIG_SYS_PORT_D_CNEN=0x0 +CONFIG_USE_PORT_E=y +CONFIG_SYS_PORT_E_ANSEL=0x0 +CONFIG_SYS_PORT_E_TRIS=0xff +CONFIG_SYS_PORT_E_LAT=0x0 +CONFIG_SYS_PORT_E_ODC=0x0 +CONFIG_SYS_PORT_E_CNPU=0xff +CONFIG_SYS_PORT_E_CNPD=0x0 +CONFIG_SYS_PORT_E_CNEN=0x0 +CONFIG_USE_PORT_F=y +CONFIG_SYS_PORT_F_ANSEL=0x0 +CONFIG_SYS_PORT_F_TRIS=0x3b +CONFIG_SYS_PORT_F_LAT=0x0 +CONFIG_SYS_PORT_F_ODC=0x0 +CONFIG_SYS_PORT_F_CNPU=0x3b +CONFIG_SYS_PORT_F_CNPD=0x0 +CONFIG_SYS_PORT_F_CNEN=0x0 +CONFIG_USE_PORT_G=y +CONFIG_SYS_PORT_G_ANSEL=0x0 +CONFIG_SYS_PORT_G_TRIS=0x1c0 +CONFIG_SYS_PORT_G_LAT=0x0 +CONFIG_SYS_PORT_G_ODC=0x0 +CONFIG_SYS_PORT_G_CNPU=0x0 +CONFIG_SYS_PORT_G_CNPD=0x0 +CONFIG_SYS_PORT_G_CNEN=0x0 +# +# from $HARMONY_VERSION_PATH/framework/system/random/config/sys_random.hconfig +# +CONFIG_USE_SYS_RANDOM=n +# +# from $HARMONY_VERSION_PATH/framework/system/reset/config/sys_reset.hconfig +# +CONFIG_USE_SYS_RESET=n +# +# from $HARMONY_VERSION_PATH/framework/system/touch/config/sys_touch.hconfig +# +CONFIG_USE_SYS_TOUCH=n +# +# from $HARMONY_VERSION_PATH/framework/system/tmr/config/sys_tmr.hconfig +# +CONFIG_USE_SYS_TMR=n +# +# from $HARMONY_VERSION_PATH/framework/system/wdt/config/sys_wdt.hconfig +# +CONFIG_USE_SYS_WDT=n +# +# from $HARMONY_VERSION_PATH/framework/tcpip/config/tcpip_stack.hconfig +# +CONFIG_USE_TCPIP_STACK=n +# +# from $HARMONY_VERSION_PATH/framework/usb/config/usb.hconfig +# +CONFIG_USE_USB_STACK=n +# +# from $HARMONY_VERSION_PATH/framework/sample/config/sample_module.hconfig +# +CONFIG_USE_SAMPLE_MODULE=n +# +# from $HARMONY_VERSION_PATH/framework/test/config/test.hconfig +# +CONFIG_USE_TEST_HARNESS=n +# +# from $HARMONY_VERSION_PATH/framework/decoder/config/decoder.hconfig +# +CONFIG_USE_DECODER=n +# +# from $HARMONY_VERSION_PATH/framework/net/pres/config/net_pres.hconfig +# +CONFIG_NET_PRES_USE=n +# +# from $HARMONY_VERSION_PATH/bsp/config/bsp.hconfig +# +CONFIG_USE_BSP=n +# +# from $HARMONY_VERSION_PATH/third_party/rtos/config/rtos.hconfig +# +CONFIG_USE_3RDPARTY_RTOS=n +# +# from $HARMONY_VERSION_PATH/third_party/tcpip/config/wolfssl.hconfig +# +CONFIG_USE_3RDPARTY_WOLFSSL=n +# +# from $HARMONY_VERSION_PATH/third_party/tcpip/iniche/config/embtcp.hconfig +# +CONFIG_IN_EMB_TCPIP_USE_TCP=n +# +# from $HARMONY_VERSION_PATH/third_party/tcpip/iniche/config/embdual.hconfig +# +CONFIG_IN_EMB_DUAL_USE_TCP=n +# +# from $HARMONY_VERSION_PATH/third_party/tcpip/iniche/config/stack.hconfig +# +CONFIG_IN_TCPIP=n +# +# from $HARMONY_VERSION_PATH/config/harmony.hconfig +# +CONFIG_DEVICE_CONFIGURATION=y +# +# from $HARMONY_VERSION_PATH/utilities/mhc/config/PIC32MZ2048ECG064.hconfig +# +CONFIG_USERID=0xffff +CONFIG_FMIIEN="ON" +CONFIG_FETHIO="OFF" +CONFIG_PGL1WAY="ON" +CONFIG_PMDL1WAY="ON" +CONFIG_IOL1WAY="ON" +CONFIG_FUSBIDIO="OFF" +CONFIG_FPLLIDIV="DIV_1" +CONFIG_FPLLRNG="RANGE_5_10_MHZ" +CONFIG_FPLLICLK="PLL_FRC" +CONFIG_FPLLMULT="MUL_80" +CONFIG_FPLLODIV="DIV_8" +CONFIG_UPLLFSEL="FREQ_12MHZ" +CONFIG_UPLLEN="OFF" +CONFIG_FNOSC="SPLL" +CONFIG_DMTINTV="WIN_127_128" +CONFIG_FSOSCEN="OFF" +CONFIG_IESO="ON" +CONFIG_POSCMOD="OFF" +CONFIG_OSCIOFNC="OFF" +CONFIG_FCKSM="CSECME" +CONFIG_WDTPS="PS1048576" +CONFIG_WDTSPGM="STOP" +CONFIG_WINDIS="NORMAL" +CONFIG_FWDTEN="OFF" +CONFIG_FWDTWINSZ="WINSZ_25" +CONFIG_DMTCNT="DMT31" +CONFIG_FDMTEN="OFF" +CONFIG_DEBUG="OFF" +CONFIG_JTAGEN="OFF" +CONFIG_ICESEL="ICS_PGx1" +CONFIG_TRCEN="ON" +CONFIG_BOOTISA="MIPS32" +CONFIG_FECCCON="OFF_UNLOCKED" +CONFIG_FSLEEP="OFF" +CONFIG_DBGPER="PG_ALL" +CONFIG_EJTAGBEN="NORMAL" +CONFIG_CP="OFF" +CONFIG_TSEQ=0xffff +CONFIG_CSEQ=0xffff +# +# from $HARMONY_VERSION_PATH/utilities/mhc/config/project.hconfig +# +CONFIG_XC32_HEAP="4096" diff --git a/firmware/src/system_config/default/framework/system/clk/src/sys_clk_static.c b/firmware/src/system_config/default/framework/system/clk/src/sys_clk_static.c new file mode 100644 index 0000000..06a146b --- /dev/null +++ b/firmware/src/system_config/default/framework/system/clk/src/sys_clk_static.c @@ -0,0 +1,283 @@ +/******************************************************************************* + SYS CLK Static Functions for Clock System Service + + Company: + Microchip Technology Inc. + + File Name: + sys_clk_static.c + + Summary: + SYS CLK static function implementations for the Clock System Service. + + Description: + The Clock System Service provides a simple interface to manage the oscillators + on Microchip microcontrollers. This file defines the static implementation for the + Clock System Service. + + Remarks: + Static functions incorporate all system clock configuration settings as + determined by the user via the Microchip Harmony Configurator GUI. It provides + static version of the routines, eliminating the need for an object ID or + object handle. + + Static single-open interfaces also eliminate the need for the open handle. +*******************************************************************************/ + +//DOM-IGNORE-BEGIN +/******************************************************************************* +Copyright (c) 2014 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. +*******************************************************************************/ +//DOM-IGNORE-END + +// ***************************************************************************** +// ***************************************************************************** +// Section: Include Files +// ***************************************************************************** +// ***************************************************************************** + +#include "system_config.h" +#include "system_definitions.h" +#include "peripheral/osc/plib_osc.h" + +// ***************************************************************************** +// ***************************************************************************** +// Section: File Scope Functions +// ***************************************************************************** +// ***************************************************************************** + +// ***************************************************************************** +/* Function: + void SYS_CLK_Static_Initialize ( const SYS_CLK_INIT const * clkInit ) + + Summary: + Initializes hardware and internal data structure of the System Clock. + + Description: + This function initializes the hardware and internal data structure of System + Clock Service. + + Remarks: + This is configuration values for the static version of the Clock System Service + module is determined by the user via the Microchip Harmony Configurator GUI. + This template will build a sys_clk_static.h and sys_clk_static.c file with + the configuration per the user's choice. + + The objective is to eliminate the user's need to be knowledgeable in the function of + the 'configuration bits' to configure the system oscillators. +*/ + +void SYS_CLK_Initialize( const SYS_CLK_INIT const * clkInit ) +{ + SYS_DEVCON_SystemUnlock ( ); + + PLIB_OSC_FRCDivisorSelect( OSC_ID_0, OSC_FRC_DIV_1); + + /* Enable Peripheral Bus 1 */ + PLIB_OSC_PBClockDivisorSet (OSC_ID_0, 0, 2 ); + PLIB_OSC_PBOutputClockEnable (OSC_ID_0, 0 ); + /* Disable Peripheral Bus 2 */ + PLIB_OSC_PBOutputClockDisable (OSC_ID_0, 1 ); + + /* Enable Peripheral Bus 3 */ + PLIB_OSC_PBClockDivisorSet (OSC_ID_0, 2, 2 ); + PLIB_OSC_PBOutputClockEnable (OSC_ID_0, 2 ); + /* Enable Peripheral Bus 4 */ + PLIB_OSC_PBClockDivisorSet (OSC_ID_0, 3, 2 ); + PLIB_OSC_PBOutputClockEnable (OSC_ID_0, 3 ); + /* Disable Peripheral Bus 5 */ + PLIB_OSC_PBOutputClockDisable (OSC_ID_0, 4 ); + + /* Enable Peripheral Bus 7 */ + PLIB_OSC_PBClockDivisorSet (OSC_ID_0, 6, 1 ); + PLIB_OSC_PBOutputClockEnable (OSC_ID_0, 6 ); + /* Disable Peripheral Bus 8 */ + PLIB_OSC_PBOutputClockDisable (OSC_ID_0, 7 ); + + /* Disable REFCLKO1*/ + PLIB_OSC_ReferenceOscDisable ( OSC_ID_0, OSC_REFERENCE_1 ); + /* Disable REFCLK1_OE*/ + PLIB_OSC_ReferenceOutputDisable ( OSC_ID_0, OSC_REFERENCE_1 ); + /* Disable REFCLKO2*/ + PLIB_OSC_ReferenceOscDisable ( OSC_ID_0, OSC_REFERENCE_2 ); + /* Disable REFCLK2_OE*/ + PLIB_OSC_ReferenceOutputDisable ( OSC_ID_0, OSC_REFERENCE_2 ); + /* Disable REFCLKO3*/ + PLIB_OSC_ReferenceOscDisable ( OSC_ID_0, OSC_REFERENCE_3 ); + /* Disable REFCLK3_OE*/ + PLIB_OSC_ReferenceOutputDisable ( OSC_ID_0, OSC_REFERENCE_3 ); + /* Disable REFCLKO4*/ + PLIB_OSC_ReferenceOscDisable ( OSC_ID_0, OSC_REFERENCE_4 ); + /* Disable REFCLK4_OE*/ + PLIB_OSC_ReferenceOutputDisable ( OSC_ID_0, OSC_REFERENCE_4 ); + + SYS_DEVCON_SystemLock ( ); +} + +//****************************************************************************** +/* Function: + inline uint32_t SYS_CLK_SystemFrequencyGet ( void ) + + Summary: + Gets the system clock frequency in Hertz. + + Description: + This function gets the System clock frequency in Hertz. + + Precondition: + None. + + Parameters: + None. + + Returns: + System clock frequency in Hertz. + + Example: + + uint32_t sysClockHz; + + sysClockHz = SYS_CLK_SystemFrequencyGet ( ); + + + Remarks: + */ + +inline uint32_t SYS_CLK_SystemFrequencyGet ( void ) +{ + return SYS_CLK_FREQ; +} + +//****************************************************************************** +/* Function: + inline uint32_t SYS_CLK_PeripheralFrequencyGet ( CLK_BUSES_PERIPHERAL peripheralBus ) + + Summary: + Gets the selected clock peripheral bus frequency in Hertz. + + Description: + This function gets the selected peripheral bus clock frequency in Hertz. + + Precondition: + None. + + Parameters: + peripheralBus - Reference clock bus selection. One of the possible value from + CLK_BUSES_PERIPHERAL enum. For devices that do not have multiple + clock channels for Reference clock, CLK_BUS_PERIPHERAL_1 should be + the selection. + + Returns: + Clock frequency in Hertz. + + Example: + + unsigned long peripheralClockHz; + + peripheralClockHz = SYS_CLK_PeripheralFrequencyGet ( CLK_BUS_PERIPHERAL_5 ); + + + Remarks: + Most of the devices doesn't have multiple Peripheral clock buses. In that case, + pass CLK_USB_PERIPHERAL_1 as the bus number. + */ + +inline uint32_t SYS_CLK_PeripheralFrequencyGet ( CLK_BUSES_PERIPHERAL peripheralBus ) +{ + uint32_t freq = 0; + + switch (peripheralBus) + { + case CLK_BUS_PERIPHERAL_1: + freq = SYS_CLK_BUS_PERIPHERAL_1; + break; + case CLK_BUS_PERIPHERAL_2: + break; + case CLK_BUS_PERIPHERAL_3: + freq = SYS_CLK_BUS_PERIPHERAL_3; + break; + case CLK_BUS_PERIPHERAL_4: + freq = SYS_CLK_BUS_PERIPHERAL_4; + break; + case CLK_BUS_PERIPHERAL_5: + break; + case CLK_BUS_PERIPHERAL_7: + freq = SYS_CLK_BUS_PERIPHERAL_7; + break; + case CLK_BUS_PERIPHERAL_8: + break; + } + + return freq; +} + + +//****************************************************************************** +/* Function: + inline uint32_t SYS_CLK_ReferenceClockFrequencyGet ( CLK_BUSES_REFERENCE referenceBus ) + + Summary: + Gets the selected Reference clock bus frequency in Hertz. + + Description: + This function gets frequency of the selected Reference clock bus in Hertz. + + Precondition: + None. + + Parameters: + peripheralBus - Reference clock bus selection. One of the possible value from + CLK_BUSES_REFERENCE enum. For devices that do not have multiple + clock channels for Reference clock, CLK_BUS_REFERENCE_1 should be + the selection. + + Returns: + Clock frequency in Hz. + + Example: + + unsigned long sysClockOutputHz; + + sysClockOutputHz = SYS_CLK_ReferenceClockFrequencyGet ( CLK_BUS_REFERENCE_3 ); + + + Remarks: + */ + +inline uint32_t SYS_CLK_ReferenceClockFrequencyGet ( CLK_BUSES_REFERENCE referenceBus ) +{ + uint32_t freq = 0; + + switch (referenceBus) + { + case CLK_BUS_REFERENCE_1: + break; + case CLK_BUS_REFERENCE_2: + break; + case CLK_BUS_REFERENCE_3: + break; + case CLK_BUS_REFERENCE_4: + break; + } + + return freq; +} \ No newline at end of file diff --git a/firmware/src/system_config/default/framework/system/clk/sys_clk_static.h b/firmware/src/system_config/default/framework/system/clk/sys_clk_static.h new file mode 100644 index 0000000..23a0cf5 --- /dev/null +++ b/firmware/src/system_config/default/framework/system/clk/sys_clk_static.h @@ -0,0 +1,65 @@ +/******************************************************************************* + SYS CLK Static Interface Declarations for Clock System Service + + Company: + Microchip Technology Inc. + + File Name: + sys_clk_static.h + + Summary: + SYS CLK interface declarations for the static system service. + + Description: + The Clock System Service provides a simple interface to manage the oscillators + on Microchip microcontrollers. This file defines the interface + Declarations for the SYS CLK system service. + + Remarks: + Static interfaces incorporate all system clock configuration settings as + determined by the user via the Microchip Harmony Configurator GUI. It provides + static version of the routines, eliminating the need for an object ID or + object handle. + + Static single-open interfaces also eliminate the need for the open handle. +*******************************************************************************/ + +//DOM-IGNORE-BEGIN +/******************************************************************************* +Copyright (c) 2014 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. +*******************************************************************************/ +//DOM-IGNORE-END + +#ifndef _SYS_CLK_STATIC_H +#define _SYS_CLK_STATIC_H + +// ***************************************************************************** +// ***************************************************************************** +// Section: SYS CLK Module Initialization Routine (Static Version) +// ***************************************************************************** +// ***************************************************************************** + +#endif // #ifndef _SYS_CLK_STATIC_H + +/******************************************************************************* + End of File +*/ diff --git a/firmware/src/system_config/default/framework/system/ports/src/sys_ports_static.c b/firmware/src/system_config/default/framework/system/ports/src/sys_ports_static.c new file mode 100644 index 0000000..b125472 --- /dev/null +++ b/firmware/src/system_config/default/framework/system/ports/src/sys_ports_static.c @@ -0,0 +1,130 @@ +/******************************************************************************* + SYS PORTS Static Functions for PORTS System Service + + Company: + Microchip Technology Inc. + + File Name: + sys_ports_static.c + + Summary: + SYS PORTS static function implementations for the Ports System Service. + + Description: + The Ports System Service provides a simple interface to manage the ports + on Microchip microcontrollers. This file defines the static implementation for the + Ports System Service. + + Remarks: + Static functions incorporate all system ports configuration settings as + determined by the user via the Microchip Harmony Configurator GUI. It provides + static version of the routines, eliminating the need for an object ID or + object handle. + +*******************************************************************************/ + +//DOM-IGNORE-BEGIN +/******************************************************************************* +Copyright (c) 2013 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. +*******************************************************************************/ +//DOM-IGNORE-END + +#include "system_config.h" +#include "peripheral/ports/plib_ports.h" +#include "peripheral/int/plib_int.h" + + +void SYS_PORTS_Initialize(void) +{ + + /* PORT B Initialization */ + PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_ODC); + PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_LAT); + PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_TRIS ^ 0xFFFF); + PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_B); + PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL); + PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_CNEN); + PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_CNPU); + PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_CNPD); + + /* PORT C Initialization */ + PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_ODC); + PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_LAT); + PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_TRIS ^ 0xFFFF); + PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_C); + PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL); + PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_CNEN); + PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_CNPU); + PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_CNPD); + + /* PORT D Initialization */ + PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_ODC); + PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_LAT); + PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_TRIS ^ 0xFFFF); + PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_D); + PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL); + PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_CNEN); + PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_CNPU); + PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_CNPD); + + /* PORT E Initialization */ + PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_ODC); + PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_LAT); + PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_TRIS ^ 0xFFFF); + PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_E); + PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL); + PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_CNEN); + PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_CNPU); + PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_CNPD); + + /* PORT F Initialization */ + PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_ODC); + PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_LAT); + PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_TRIS ^ 0xFFFF); + PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_F); + PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL); + PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_CNEN); + PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_CNPU); + PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_CNPD); + + /* PORT G Initialization */ + PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_ODC); + PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_LAT); + PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_TRIS ^ 0xFFFF); + PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_G); + PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL); + PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_CNEN); + PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_CNPU); + PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_CNPD); + + + /* PPS Input Remapping */ + + /* PPS Output Remapping */ + + +} + + +/******************************************************************************* + End of File +*/ diff --git a/firmware/src/system_config/default/system_config.h b/firmware/src/system_config/default/system_config.h new file mode 100644 index 0000000..a8faed8 --- /dev/null +++ b/firmware/src/system_config/default/system_config.h @@ -0,0 +1,165 @@ +/******************************************************************************* + MPLAB Harmony System Configuration Header + + File Name: + system_config.h + + Summary: + Build-time configuration header for the system defined by this MPLAB Harmony + project. + + Description: + An MPLAB Project may have multiple configurations. This file defines the + build-time options for a single configuration. + + Remarks: + This configuration header must not define any prototypes or data + definitions (or include any files that do). It only provides macro + definitions for build-time configuration options that are not instantiated + until used by another MPLAB Harmony module or application. + + Created with MPLAB Harmony Version 1.06 +*******************************************************************************/ + +// DOM-IGNORE-BEGIN +/******************************************************************************* +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. +*******************************************************************************/ +// DOM-IGNORE-END + +#ifndef _SYSTEM_CONFIG_H +#define _SYSTEM_CONFIG_H + +/* This is a temporary workaround for an issue with the peripheral library "Exists" + functions that causes superfluous warnings. It "nulls" out the definition of + The PLIB function attribute that causes the warning. Once that issue has been + resolved, this definition should be removed. */ +#define _PLIB_UNSUPPORTED + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Included Files +// ***************************************************************************** +// ***************************************************************************** +/* This section Includes other configuration headers necessary to completely + define this configuration. +*/ + + +// ***************************************************************************** +// ***************************************************************************** +// Section: System Service Configuration +// ***************************************************************************** +// ***************************************************************************** + +// ***************************************************************************** +/* Common System Service Configuration Options +*/ +#define SYS_VERSION_STR "1.06" +#define SYS_VERSION 10600 + +// ***************************************************************************** +/* Clock System Service Configuration Options +*/ +#define SYS_CLK_FREQ 80000000ul +#define SYS_CLK_BUS_PERIPHERAL_1 40000000ul +#define SYS_CLK_BUS_PERIPHERAL_3 40000000ul +#define SYS_CLK_BUS_PERIPHERAL_4 40000000ul +#define SYS_CLK_BUS_PERIPHERAL_7 80000000ul +#define SYS_CLK_CONFIG_PRIMARY_XTAL 24000000ul +#define SYS_CLK_CONFIG_SECONDARY_XTAL 32768ul + +/*** Ports System Service Configuration ***/ + +#define SYS_PORT_B_ANSEL 0x0 +#define SYS_PORT_B_TRIS 0x0 +#define SYS_PORT_B_LAT 0x0 +#define SYS_PORT_B_ODC 0x0 +#define SYS_PORT_B_CNPU 0x0 +#define SYS_PORT_B_CNPD 0x0 +#define SYS_PORT_B_CNEN 0x0 +#define SYS_PORT_C_ANSEL 0x0 +#define SYS_PORT_C_TRIS 0xf000 +#define SYS_PORT_C_LAT 0x0 +#define SYS_PORT_C_ODC 0x0 +#define SYS_PORT_C_CNPU 0x0 +#define SYS_PORT_C_CNPD 0x0 +#define SYS_PORT_C_CNEN 0x0 + +#define SYS_PORT_D_ANSEL 0x0 +#define SYS_PORT_D_TRIS 0xe3f +#define SYS_PORT_D_LAT 0x0 +#define SYS_PORT_D_ODC 0x0 +#define SYS_PORT_D_CNPU 0xe3f +#define SYS_PORT_D_CNPD 0x0 +#define SYS_PORT_D_CNEN 0x0 + +#define SYS_PORT_E_ANSEL 0x0 +#define SYS_PORT_E_TRIS 0xff +#define SYS_PORT_E_LAT 0x0 +#define SYS_PORT_E_ODC 0x0 +#define SYS_PORT_E_CNPU 0xff +#define SYS_PORT_E_CNPD 0x0 +#define SYS_PORT_E_CNEN 0x0 + +#define SYS_PORT_F_ANSEL 0x0 +#define SYS_PORT_F_TRIS 0x3b +#define SYS_PORT_F_LAT 0x0 +#define SYS_PORT_F_ODC 0x0 +#define SYS_PORT_F_CNPU 0x3b +#define SYS_PORT_F_CNPD 0x0 +#define SYS_PORT_F_CNEN 0x0 + +#define SYS_PORT_G_ANSEL 0x0 +#define SYS_PORT_G_TRIS 0x1c0 +#define SYS_PORT_G_LAT 0x0 +#define SYS_PORT_G_ODC 0x0 +#define SYS_PORT_G_CNPU 0x0 +#define SYS_PORT_G_CNPD 0x0 +#define SYS_PORT_G_CNEN 0x0 + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Driver Configuration +// ***************************************************************************** +// ***************************************************************************** + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Middleware & Other Library Configuration +// ***************************************************************************** +// ***************************************************************************** + + + + + + + +#endif // _SYSTEM_CONFIG_H +/******************************************************************************* + End of File +*/ + diff --git a/firmware/src/system_config/default/system_definitions.h b/firmware/src/system_config/default/system_definitions.h new file mode 100644 index 0000000..5bc5468 --- /dev/null +++ b/firmware/src/system_config/default/system_definitions.h @@ -0,0 +1,119 @@ +/******************************************************************************* + System Definitions + + File Name: + system_definitions.h + + Summary: + MPLAB Harmony project system definitions. + + Description: + This file contains the system-wide prototypes and definitions for an MPLAB + Harmony project. + *******************************************************************************/ + +//DOM-IGNORE-BEGIN +/******************************************************************************* +Copyright (c) 2013-2014 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. + *******************************************************************************/ +//DOM-IGNORE-END + +#ifndef _SYS_DEFINITIONS_H +#define _SYS_DEFINITIONS_H + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Included Files +// ***************************************************************************** +// ***************************************************************************** + +#include +#include +#include +#include "system/common/sys_common.h" +#include "system/common/sys_module.h" +#include "system/clk/sys_clk.h" +#include "system/clk/sys_clk_static.h" +#include "system/devcon/sys_devcon.h" +#include "system/ports/sys_ports.h" + + +#include "app.h" + + +// DOM-IGNORE-BEGIN +#ifdef __cplusplus // Provide C++ Compatibility + +extern "C" { + +#endif +// DOM-IGNORE-END + +// ***************************************************************************** +// ***************************************************************************** +// Section: Type Definitions +// ***************************************************************************** +// ***************************************************************************** + +// ***************************************************************************** +/* System Objects + + Summary: + Structure holding the system's object handles + + Description: + This structure contains the object handles for all objects in the + MPLAB Harmony project's system configuration. + + Remarks: + These handles are returned from the "Initialize" functions for each module + and must be passed into the "Tasks" function for each module. +*/ + +typedef struct +{ + SYS_MODULE_OBJ sysDevcon; + +} SYSTEM_OBJECTS; + + +// ***************************************************************************** +// ***************************************************************************** +// Section: extern declarations +// ***************************************************************************** +// ***************************************************************************** + +extern SYSTEM_OBJECTS sysObj; + + +//DOM-IGNORE-BEGIN +#ifdef __cplusplus +} +#endif +//DOM-IGNORE-END + +#endif /* _SYS_DEFINITIONS_H */ +/******************************************************************************* + End of File +*/ + diff --git a/firmware/src/system_config/default/system_exceptions.c b/firmware/src/system_config/default/system_exceptions.c new file mode 100644 index 0000000..73a2380 --- /dev/null +++ b/firmware/src/system_config/default/system_exceptions.c @@ -0,0 +1,143 @@ +/******************************************************************************* + MPLAB Harmony Exceptions Source File + + File Name: + system_exceptions.c + + Summary: + This file contains a function which overrides the deafult _weak_ exception + handler provided by the XC32 compiler. + + Description: + This file redefines the default _weak_ exception handler with a more debug + friendly one. If an unexpected exception occurs the code will stop in a + while(1) loop. The debugger can be halted and two variables _excep_code and + _except_addr can be examined to determine the cause and address where the + exception occured. + *******************************************************************************/ + +// DOM-IGNORE-BEGIN +/******************************************************************************* +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. + *******************************************************************************/ +// DOM-IGNORE-END + + +#include /* Defines special funciton registers, CP0 regs */ +#include "system_config.h" +#include "system_definitions.h" +#include "system/debug/sys_debug.h" + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Global Data Definitions +// ***************************************************************************** +// ***************************************************************************** + +/******************************************************************************* + Exception Reason Data + + + + Remarks: + These global static items are used instead of local variables in the + _general_exception_handler function because the stack may not be available + if an exception has occured. +*/ + +/* Code identifying the cause of the exception (CP0 Cause register). */ +static unsigned int _excep_code; + +/* Address of instruction that caused the exception. */ +static unsigned int _excep_addr; + +/* Pointer to the string describing the cause of the exception. */ +static char *_cause_str; + +/* Array identifying the cause (indexed by _exception_code). */ +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" +}; + +// + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Exception Handling +// ***************************************************************************** +// ***************************************************************************** + +/******************************************************************************* + Function: + void _general_exception_handler ( void ) + + Summary: + Overrides the XC32 _weak_ _generic_exception_handler. + + Description: + This function overrides the XC32 default _weak_ _generic_exception_handler. + + Remarks: + Refer to the XC32 User's Guide for additional information. + */ + +void _general_exception_handler ( void ) +{ + /* Mask off Mask of the ExcCode Field from the Cause Register + Refer to the MIPs Software User's manual */ + _excep_code = (_CP0_GET_CAUSE() & 0x0000007C) >> 2; + _excep_addr = _CP0_GET_EPC(); + _cause_str = cause[_excep_code]; + + SYS_DEBUG_PRINT(SYS_ERROR_ERROR, "\nGeneral Exception %s (cause=%d, addr=%x).\n", + _cause_str, _excep_code, _excep_addr); + + while (1) + { + SYS_DEBUG_BreakPoint(); + } +} + +/******************************************************************************* + End of File +*/ diff --git a/firmware/src/system_config/default/system_init.c b/firmware/src/system_config/default/system_init.c new file mode 100644 index 0000000..9c69c4e --- /dev/null +++ b/firmware/src/system_config/default/system_init.c @@ -0,0 +1,210 @@ +/******************************************************************************* + System Initialization File + + File Name: + system_init.c + + Summary: + This file contains source code necessary to initialize the system. + + Description: + This file contains source code necessary to initialize the system. It + implements the "SYS_Initialize" function, defines the configuration bits, + and allocates any necessary global system resources, such as the + sysObj structure that contains the object handles to all the MPLAB Harmony + module objects in the system. + *******************************************************************************/ + +// DOM-IGNORE-BEGIN +/******************************************************************************* +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. + *******************************************************************************/ +// DOM-IGNORE-END + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Included Files +// ***************************************************************************** +// ***************************************************************************** + +#include "system_config.h" +#include "system_definitions.h" + + +// **************************************************************************** +// **************************************************************************** +// Section: Configuration Bits +// **************************************************************************** +// **************************************************************************** +// + +/*** DEVCFG0 ***/ + +#pragma config DEBUG = OFF +#pragma config JTAGEN = OFF +#pragma config ICESEL = ICS_PGx1 +#pragma config TRCEN = ON +#pragma config BOOTISA = MIPS32 +#pragma config FECCCON = OFF_UNLOCKED +#pragma config FSLEEP = OFF +#pragma config DBGPER = PG_ALL +#pragma config EJTAGBEN = NORMAL +#pragma config CP = OFF + +/*** DEVCFG1 ***/ + +#pragma config FNOSC = SPLL +#pragma config DMTINTV = WIN_127_128 +#pragma config FSOSCEN = OFF +#pragma config IESO = ON +#pragma config POSCMOD = OFF +#pragma config OSCIOFNC = OFF +#pragma config FCKSM = CSECME +#pragma config WDTPS = PS1048576 +#pragma config WDTSPGM = STOP +#pragma config FWDTEN = OFF +#pragma config WINDIS = NORMAL +#pragma config FWDTWINSZ = WINSZ_25 +#pragma config DMTCNT = DMT31 +#pragma config FDMTEN = OFF + +/*** DEVCFG2 ***/ + +#pragma config FPLLIDIV = DIV_1 +#pragma config FPLLRNG = RANGE_5_10_MHZ +#pragma config FPLLICLK = PLL_FRC +#pragma config FPLLMULT = MUL_80 +#pragma config FPLLODIV = DIV_8 +#pragma config UPLLFSEL = FREQ_12MHZ +#pragma config UPLLEN = OFF + +/*** DEVCFG3 ***/ + +#pragma config USERID = 0xffff +#pragma config FMIIEN = ON +#pragma config FETHIO = OFF +#pragma config PGL1WAY = ON +#pragma config PMDL1WAY = ON +#pragma config IOL1WAY = ON +#pragma config FUSBIDIO = OFF + +/*** BF1SEQ0 ***/ + +#pragma config TSEQ = 0xffff +#pragma config CSEQ = 0xffff +// + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Library/Stack Initialization Data +// ***************************************************************************** +// ***************************************************************************** + + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Driver Initialization Data +// ***************************************************************************** +// ***************************************************************************** + + +// ***************************************************************************** +// ***************************************************************************** +// Section: System Data +// ***************************************************************************** +// ***************************************************************************** + +/* Structure to hold the object handles for the modules in the system. */ +SYSTEM_OBJECTS sysObj; + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Module Initialization Data +// ***************************************************************************** +// ***************************************************************************** + +/******************************************************************************* + Device Control System Service Initialization Data + + +*/ + +const SYS_DEVCON_INIT sysDevconInit = +{ + .moduleInit = {0}, +}; + +// + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Static Initialization Functions +// ***************************************************************************** +// ***************************************************************************** + + +// ***************************************************************************** +// ***************************************************************************** +// Section: System Initialization +// ***************************************************************************** +// ***************************************************************************** + +/******************************************************************************* + Function: + void SYS_Initialize ( SYS_INIT_DATA *data ) + + Summary: + Initializes the board, services, drivers, application and other modules. + + Remarks: + See prototype in system/common/sys_module.h. + */ + +void SYS_Initialize ( void* data ) +{ + /* Core Processor Initialization */ + SYS_CLK_Initialize( NULL ); + sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit); + SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet()); + SYS_PORTS_Initialize(); + + /* Initialize Drivers */ + + /* Initialize System Services */ + + /* Initialize Middleware */ + + /* Initialize the Application */ + APP_Initialize(); +} + + +/******************************************************************************* + End of File +*/ + diff --git a/firmware/src/system_config/default/system_interrupt.c b/firmware/src/system_config/default/system_interrupt.c new file mode 100644 index 0000000..a676c11 --- /dev/null +++ b/firmware/src/system_config/default/system_interrupt.c @@ -0,0 +1,77 @@ +/******************************************************************************* + System Interrupts File + + File Name: + system_int.c + + Summary: + Raw ISR definitions. + + Description: + This file contains a definitions of the raw ISRs required to support the + interrupt sub-system. + + Summary: + This file contains source code for the interrupt vector functions in the + system. + + Description: + This file contains source code for the interrupt vector functions in the + system. It implements the system and part specific vector "stub" functions + from which the individual "Tasks" functions are called for any modules + executing interrupt-driven in the MPLAB Harmony system. + + Remarks: + This file requires access to the systemObjects global data structure that + contains the object handles to all MPLAB Harmony module objects executing + interrupt-driven in the system. These handles are passed into the individual + module "Tasks" functions to identify the instance of the module to maintain. + *******************************************************************************/ + +// DOM-IGNORE-BEGIN +/******************************************************************************* +Copyright (c) 2011-2014 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. + *******************************************************************************/ +// DOM-IGNORE-END + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Included Files +// ***************************************************************************** +// ***************************************************************************** + +#include +#include +#include "app.h" +#include "system_definitions.h" + +// ***************************************************************************** +// ***************************************************************************** +// Section: System Interrupt Vector Functions +// ***************************************************************************** +// ***************************************************************************** + +/******************************************************************************* + End of File +*/ + diff --git a/firmware/src/system_config/default/system_tasks.c b/firmware/src/system_config/default/system_tasks.c new file mode 100644 index 0000000..14c834d --- /dev/null +++ b/firmware/src/system_config/default/system_tasks.c @@ -0,0 +1,91 @@ +/******************************************************************************* + System Tasks File + + File Name: + system_tasks.c + + Summary: + This file contains source code necessary to maintain system's polled state + machines. + + Description: + This file contains source code necessary to maintain system's polled state + machines. It implements the "SYS_Tasks" function that calls the individual + "Tasks" functions for all polled MPLAB Harmony modules in the system. + + Remarks: + This file requires access to the systemObjects global data structure that + contains the object handles to all MPLAB Harmony module objects executing + polled in the system. These handles are passed into the individual module + "Tasks" functions to identify the instance of the module to maintain. + *******************************************************************************/ + +// DOM-IGNORE-BEGIN +/******************************************************************************* +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. + *******************************************************************************/ +// DOM-IGNORE-END + + +// ***************************************************************************** +// ***************************************************************************** +// Section: Included Files +// ***************************************************************************** +// ***************************************************************************** + +#include "system_config.h" +#include "system_definitions.h" + + +// ***************************************************************************** +// ***************************************************************************** +// Section: System "Tasks" Routine +// ***************************************************************************** +// ***************************************************************************** + +/******************************************************************************* + Function: + void SYS_Tasks ( void ) + + Remarks: + See prototype in system/common/sys_module.h. +*/ + +void SYS_Tasks ( void ) +{ + /* Maintain system services */ + SYS_DEVCON_Tasks(sysObj.sysDevcon); + + /* Maintain Device Drivers */ + + /* Maintain Middleware & Other Libraries */ + + + /* Maintain the application's state machine. */ + APP_Tasks(); +} + + +/******************************************************************************* + End of File + */ + diff --git a/firmware/src/t6963c_specific.c b/firmware/src/t6963c_specific.c new file mode 100644 index 0000000..6d1b183 --- /dev/null +++ b/firmware/src/t6963c_specific.c @@ -0,0 +1,40 @@ +/** + * C library for interfacing a T6963C display with a PIC microcontroller + * Copyright (C) 2015 Camil Staps + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include "t6963c_specific.h" +#include "system_config.h" + +inline void t6963c_initTimer(void) { +} + +inline void t6963c_startTimer(void) { + T2CON = NULL; + PR2 = 0xffff; + TMR2 = NULL; + T2CONSET = 0xa000; +} + +inline unsigned short t6963c_getTimeNs(void) { + return TMR2 * t6963c_nspertick; +} + +inline void t6963c_stopTimer(void) { + T2CONCLR = 0xa000; +} diff --git a/firmware/src/t6963c_specific.h b/firmware/src/t6963c_specific.h new file mode 100644 index 0000000..12be1f7 --- /dev/null +++ b/firmware/src/t6963c_specific.h @@ -0,0 +1,68 @@ +/** + * C library for interfacing a T6963C display with a PIC microcontroller + * Copyright (C) 2015 Camil Staps + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + ******************************************************************************* + * + * File: t6963c_specific.h + * Author: Camil Staps + * + * Example of what you could put in a t6963c_specific.h. + */ + +#ifndef T6963C_SPECIFIC_H +#define T6963C_SPECIFIC_H + +#include + +#define t6963c_rst LATBbits.LATB12 // RESET line +#define t6963c_cd LATBbits.LATB8 // C/D line +#define t6963c_ce LATBbits.LATB9 // CE line +#define t6963c_rd LATBbits.LATB10 // RD line +#define t6963c_wr LATBbits.LATB11 // WR line +#define t6963c_t_rst TRISBbits.TRISB12 // TRIS bit of RESET pin +#define t6963c_t_cd TRISBbits.TRISB8 // TRIS bit of C/D pin +#define t6963c_t_ce TRISBbits.TRISB9 // TRIS bit of CE pin +#define t6963c_t_rd TRISBbits.TRISB10 // TRIS bit of RD pin +#define t6963c_t_wr TRISBbits.TRISB11 // TRIS bit of WR pin +#define t6963c_data LATB // Data port (the lowest 8 bits are assumed) +#define t6963c_t_data TRISB // TRIS register of data port + +#define t6963c_rows 16 // Number of rows of the LCD +#define t6963c_columns 40 // Number of columns of the LCD + +#ifdef __cplusplus +extern "C" { +#endif + +#define t6963c_nspertick 25 + +/** + * Define the project-specific timer functions here + * @see t6963c.h + */ +inline void t6963c_initTimer(void); +inline void t6963c_startTimer(void); +inline unsigned short t6963c_getTimeNs(void); +inline void t6963c_stopTimer(void); + +#ifdef __cplusplus +} +#endif + +#endif /* T6963C_SPECIFIC_H */ + -- cgit v1.2.3