From 79bb1a9932af7bfcdab67e2a1da9d9edcba87f71 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 22 Aug 2016 22:28:32 +0200 Subject: old wip --- .../framework/system/clk/src/sys_clk_static.c | 216 +++++++++++++++++++++ .../framework/system/clk/sys_clk_static.h | 65 +++++++ .../framework/system/ports/src/sys_ports_static.c | 81 ++++++++ 3 files changed, 362 insertions(+) create mode 100644 firmware/src/system_config/pic32mx695f512h/framework/system/clk/src/sys_clk_static.c create mode 100644 firmware/src/system_config/pic32mx695f512h/framework/system/clk/sys_clk_static.h create mode 100644 firmware/src/system_config/pic32mx695f512h/framework/system/ports/src/sys_ports_static.c (limited to 'firmware/src/system_config/pic32mx695f512h/framework') diff --git a/firmware/src/system_config/pic32mx695f512h/framework/system/clk/src/sys_clk_static.c b/firmware/src/system_config/pic32mx695f512h/framework/system/clk/src/sys_clk_static.c new file mode 100644 index 0000000..837a4fb --- /dev/null +++ b/firmware/src/system_config/pic32mx695f512h/framework/system/clk/src/sys_clk_static.c @@ -0,0 +1,216 @@ +/******************************************************************************* + 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_2); + + /* Enable Peripheral Bus 1 */ + PLIB_OSC_PBClockDivisorSet (OSC_ID_0, 0, 1 ); + + + + + + + + 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 ) +{ + return SYS_CLK_BUS_PERIPHERAL_1; +} + + +//****************************************************************************** +/* 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 ) +{ + return 0; +} \ No newline at end of file diff --git a/firmware/src/system_config/pic32mx695f512h/framework/system/clk/sys_clk_static.h b/firmware/src/system_config/pic32mx695f512h/framework/system/clk/sys_clk_static.h new file mode 100644 index 0000000..23a0cf5 --- /dev/null +++ b/firmware/src/system_config/pic32mx695f512h/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/pic32mx695f512h/framework/system/ports/src/sys_ports_static.c b/firmware/src/system_config/pic32mx695f512h/framework/system/ports/src/sys_ports_static.c new file mode 100644 index 0000000..d84b837 --- /dev/null +++ b/firmware/src/system_config/pic32mx695f512h/framework/system/ports/src/sys_ports_static.c @@ -0,0 +1,81 @@ +/******************************************************************************* + 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) +{ + /* AN and CN Pins Initialization */ + PLIB_PORTS_AnPinsModeSelect(PORTS_ID_0, SYS_PORT_AD1PCFG, PORTS_PIN_MODE_DIGITAL); + PLIB_PORTS_CnPinsPullUpEnable(PORTS_ID_0, SYS_PORT_CNPUE); + PLIB_PORTS_CnPinsEnable(PORTS_ID_0, SYS_PORT_CNEN); + PLIB_PORTS_ChangeNoticeEnable(PORTS_ID_0); + + + + /* 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); + + /* 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); + +} + + +/******************************************************************************* + End of File +*/ -- cgit v1.2.3