parent
11ccc7496e
commit
d0048dcfb2
@ -1,4 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project version="4"> |
|
||||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" /> |
|
||||||
</project> |
|
@ -1,8 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project version="4"> |
|
||||||
<component name="ProjectModuleManager"> |
|
||||||
<modules> |
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/proj.iml" filepath="$PROJECT_DIR$/.idea/proj.iml" /> |
|
||||||
</modules> |
|
||||||
</component> |
|
||||||
</project> |
|
@ -1,2 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<module classpath="CMake" type="CPP_MODULE" version="4" /> |
|
@ -1,239 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project version="4"> |
|
||||||
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true" buildAllGenerated="true"> |
|
||||||
<generated> |
|
||||||
<config projectName="proj" targetName="proj" /> |
|
||||||
</generated> |
|
||||||
</component> |
|
||||||
<component name="CMakeSettings"> |
|
||||||
<configurations> |
|
||||||
<configuration CONFIG_NAME="Debug" /> |
|
||||||
</configurations> |
|
||||||
</component> |
|
||||||
<component name="ChangeListManager"> |
|
||||||
<list default="true" id="38654d8d-41ef-479b-814f-5f05e90ab5b0" name="Default" comment=""> |
|
||||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> |
|
||||||
</list> |
|
||||||
<ignored path="$PROJECT_DIR$/cmake-build-debug/" /> |
|
||||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> |
|
||||||
<option name="TRACKING_ENABLED" value="true" /> |
|
||||||
<option name="SHOW_DIALOG" value="false" /> |
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" /> |
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> |
|
||||||
<option name="LAST_RESOLUTION" value="IGNORE" /> |
|
||||||
</component> |
|
||||||
<component name="FileEditorManager"> |
|
||||||
<leaf> |
|
||||||
<file leaf-file-name="CMakeLists.txt" pinned="false" current-in-tab="false"> |
|
||||||
<entry file="file://$PROJECT_DIR$/CMakeLists.txt"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="-1173"> |
|
||||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
</file> |
|
||||||
<file leaf-file-name="main.c" pinned="false" current-in-tab="true"> |
|
||||||
<entry file="file://$PROJECT_DIR$/Src/main.c"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="-1003"> |
|
||||||
<caret line="37" column="0" lean-forward="false" selection-start-line="37" selection-start-column="0" selection-end-line="37" selection-end-column="0" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
</file> |
|
||||||
</leaf> |
|
||||||
</component> |
|
||||||
<component name="Git.Settings"> |
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> |
|
||||||
</component> |
|
||||||
<component name="IdeDocumentHistory"> |
|
||||||
<option name="CHANGED_PATHS"> |
|
||||||
<list> |
|
||||||
<option value="$PROJECT_DIR$/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_hal_def.h" /> |
|
||||||
<option value="$PROJECT_DIR$/Src/main.c" /> |
|
||||||
<option value="$PROJECT_DIR$/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_hal.h" /> |
|
||||||
</list> |
|
||||||
</option> |
|
||||||
</component> |
|
||||||
<component name="ProjectFrameBounds" extendedState="6"> |
|
||||||
<option name="x" value="329" /> |
|
||||||
<option name="y" value="246" /> |
|
||||||
<option name="width" value="1280" /> |
|
||||||
<option name="height" value="798" /> |
|
||||||
</component> |
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> |
|
||||||
<component name="ProjectView"> |
|
||||||
<navigator currentView="ProjectPane" proportions="" version="1"> |
|
||||||
<flattenPackages /> |
|
||||||
<showMembers /> |
|
||||||
<showModules /> |
|
||||||
<showLibraryContents /> |
|
||||||
<hideEmptyPackages /> |
|
||||||
<abbreviatePackageNames /> |
|
||||||
<autoscrollToSource /> |
|
||||||
<autoscrollFromSource /> |
|
||||||
<sortByType /> |
|
||||||
<manualOrder /> |
|
||||||
<foldersAlwaysOnTop value="true" /> |
|
||||||
</navigator> |
|
||||||
<panes> |
|
||||||
<pane id="ProjectPane"> |
|
||||||
<subPane> |
|
||||||
<expand> |
|
||||||
<path> |
|
||||||
<item name="proj" type="dad4c3:CidrFilesViewHelper$MyProjectTreeStructure$1" /> |
|
||||||
<item name="proj" type="462c0819:PsiDirectoryNode" /> |
|
||||||
</path> |
|
||||||
<path> |
|
||||||
<item name="proj" type="dad4c3:CidrFilesViewHelper$MyProjectTreeStructure$1" /> |
|
||||||
<item name="proj" type="462c0819:PsiDirectoryNode" /> |
|
||||||
<item name="Drivers" type="462c0819:PsiDirectoryNode" /> |
|
||||||
</path> |
|
||||||
<path> |
|
||||||
<item name="proj" type="dad4c3:CidrFilesViewHelper$MyProjectTreeStructure$1" /> |
|
||||||
<item name="proj" type="462c0819:PsiDirectoryNode" /> |
|
||||||
<item name="Src" type="462c0819:PsiDirectoryNode" /> |
|
||||||
</path> |
|
||||||
</expand> |
|
||||||
<select /> |
|
||||||
</subPane> |
|
||||||
</pane> |
|
||||||
</panes> |
|
||||||
</component> |
|
||||||
<component name="PropertiesComponent"> |
|
||||||
<property name="WebServerToolWindowFactoryState" value="false" /> |
|
||||||
</component> |
|
||||||
<component name="RunDashboard"> |
|
||||||
<option name="ruleStates"> |
|
||||||
<list> |
|
||||||
<RuleState> |
|
||||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" /> |
|
||||||
</RuleState> |
|
||||||
<RuleState> |
|
||||||
<option name="name" value="StatusDashboardGroupingRule" /> |
|
||||||
</RuleState> |
|
||||||
</list> |
|
||||||
</option> |
|
||||||
</component> |
|
||||||
<component name="RunManager" selected="Application.proj"> |
|
||||||
<configuration name="Build All" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" CONFIG_NAME="Debug" EXPLICIT_BUILD_TARGET_NAME="all"> |
|
||||||
<envs /> |
|
||||||
</configuration> |
|
||||||
<configuration name="proj" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="proj" TARGET_NAME="proj" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="proj" RUN_TARGET_NAME="proj"> |
|
||||||
<envs /> |
|
||||||
</configuration> |
|
||||||
<list size="2"> |
|
||||||
<item index="0" class="java.lang.String" itemvalue="Application.Build All" /> |
|
||||||
<item index="1" class="java.lang.String" itemvalue="Application.proj" /> |
|
||||||
</list> |
|
||||||
</component> |
|
||||||
<component name="ShelveChangesManager" show_recycled="false"> |
|
||||||
<option name="remove_strategy" value="false" /> |
|
||||||
</component> |
|
||||||
<component name="TaskManager"> |
|
||||||
<task active="true" id="Default" summary="Default task"> |
|
||||||
<changelist id="38654d8d-41ef-479b-814f-5f05e90ab5b0" name="Default" comment="" /> |
|
||||||
<created>1509630149534</created> |
|
||||||
<option name="number" value="Default" /> |
|
||||||
<option name="presentableId" value="Default" /> |
|
||||||
<updated>1509630149534</updated> |
|
||||||
<workItem from="1509630151155" duration="770000" /> |
|
||||||
</task> |
|
||||||
<servers /> |
|
||||||
</component> |
|
||||||
<component name="TimeTrackingManager"> |
|
||||||
<option name="totallyTimeSpent" value="770000" /> |
|
||||||
</component> |
|
||||||
<component name="ToolWindowManager"> |
|
||||||
<frame x="329" y="246" width="1366" height="738" extended-state="6" /> |
|
||||||
<editor active="true" /> |
|
||||||
<layout> |
|
||||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> |
|
||||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" /> |
|
||||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" /> |
|
||||||
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> |
|
||||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> |
|
||||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> |
|
||||||
</layout> |
|
||||||
</component> |
|
||||||
<component name="VcsContentAnnotationSettings"> |
|
||||||
<option name="myLimit" value="2678400000" /> |
|
||||||
</component> |
|
||||||
<component name="XDebuggerManager"> |
|
||||||
<breakpoint-manager /> |
|
||||||
<watches-manager /> |
|
||||||
</component> |
|
||||||
<component name="editorHistoryManager"> |
|
||||||
<entry file="file://$PROJECT_DIR$/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_hal_def.h"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="425"> |
|
||||||
<caret line="49" column="20" lean-forward="true" selection-start-line="49" selection-start-column="20" selection-end-line="49" selection-end-column="20" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
<entry file="file://$PROJECT_DIR$/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_hal_pwr.h"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="442"> |
|
||||||
<caret line="44" column="15" lean-forward="true" selection-start-line="44" selection-start-column="15" selection-end-line="44" selection-end-column="15" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
<entry file="file://$PROJECT_DIR$/Inc/stm32l0xx_hal_conf.h"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="-2448"> |
|
||||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
<entry file="file://$PROJECT_DIR$/Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l073xx.h"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="-1836"> |
|
||||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
<entry file="file://$PROJECT_DIR$/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_hal.h"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="401"> |
|
||||||
<caret line="46" column="8" lean-forward="false" selection-start-line="46" selection-start-column="8" selection-end-line="46" selection-end-column="8" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
<entry file="file://$PROJECT_DIR$/CMakeLists.txt"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="-1173"> |
|
||||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
<entry file="file://$PROJECT_DIR$/Src/main.c"> |
|
||||||
<provider selected="true" editor-type-id="text-editor"> |
|
||||||
<state relative-caret-position="-1003"> |
|
||||||
<caret line="37" column="0" lean-forward="false" selection-start-line="37" selection-start-column="0" selection-end-line="37" selection-end-column="0" /> |
|
||||||
<folding /> |
|
||||||
</state> |
|
||||||
</provider> |
|
||||||
</entry> |
|
||||||
</component> |
|
||||||
</project> |
|
@ -0,0 +1,147 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2015 Semtech |
||||||
|
|
||||||
|
Description: End device commissioning parameters |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file commissioning.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief End device commissioning parameters |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __LORA_COMMISSIONING_H__ |
||||||
|
#define __LORA_COMMISSIONING_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
/* Exported macros -----------------------------------------------------------*/ |
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
/*!
|
||||||
|
* When set to 1 the application uses the Over-the-Air activation procedure |
||||||
|
* When set to 0 the application uses the Personalization activation procedure |
||||||
|
*/ |
||||||
|
#define OVER_THE_AIR_ACTIVATION 1 |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Indicates if the end-device is to be connected to a private or public network |
||||||
|
*/ |
||||||
|
#define LORAWAN_PUBLIC_NETWORK true |
||||||
|
|
||||||
|
/*!
|
||||||
|
* When set to 1 DevEui is LORAWAN_DEVICE_EUI |
||||||
|
* When set to 0 DevEui is automatically generated by calling |
||||||
|
* BoardGetUniqueId function |
||||||
|
*/ |
||||||
|
#define STATIC_DEVICE_EUI 0 |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Mote device IEEE EUI (big endian) |
||||||
|
* |
||||||
|
* \remark see STATIC_DEVICE_EUI comments |
||||||
|
*/ |
||||||
|
#define LORAWAN_DEVICE_EUI { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Application IEEE EUI (big endian) |
||||||
|
*/ |
||||||
|
#define LORAWAN_APPLICATION_EUI { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } |
||||||
|
|
||||||
|
/*!
|
||||||
|
* AES encryption/decryption cipher application key |
||||||
|
*/ |
||||||
|
#define LORAWAN_APPLICATION_KEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } |
||||||
|
|
||||||
|
#if( OVER_THE_AIR_ACTIVATION == 0 ) |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Current network ID |
||||||
|
*/ |
||||||
|
#define LORAWAN_NETWORK_ID ( uint32_t )0 |
||||||
|
|
||||||
|
/*!
|
||||||
|
* When set to 1 DevAdd is LORAWAN_DEVICE_ADDRESS |
||||||
|
* When set to 0 DevAdd is automatically generated using |
||||||
|
* a pseudo random generator seeded with a value derived from |
||||||
|
* BoardUniqueId value |
||||||
|
*/ |
||||||
|
#define STATIC_DEVICE_ADDRESS 0 |
||||||
|
/*!
|
||||||
|
* Device address on the network (big endian) |
||||||
|
* |
||||||
|
* \remark see STATIC_DEVICE_ADDRESS comments |
||||||
|
*/ |
||||||
|
#define LORAWAN_DEVICE_ADDRESS ( uint32_t )0x0100000a |
||||||
|
|
||||||
|
/*!
|
||||||
|
* AES encryption/decryption cipher network session key |
||||||
|
*/ |
||||||
|
#define LORAWAN_NWKSKEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } |
||||||
|
|
||||||
|
/*!
|
||||||
|
* AES encryption/decryption cipher application session key |
||||||
|
*/ |
||||||
|
#define LORAWAN_APPSKEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } |
||||||
|
|
||||||
|
#endif /* OVER_THE_AIR_ACTIVATION == 0 */ |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __LORA_COMMISSIONING_H__ */ |
@ -0,0 +1,125 @@ |
|||||||
|
/******************************************************************************
|
||||||
|
* @file debug.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief Header for driver debug.c module |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __DEBUG_H__ |
||||||
|
#define __DEBUG_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <string.h> |
||||||
|
#include <stdio.h> |
||||||
|
#include "hw_conf.h" |
||||||
|
#include "vcom.h" |
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
/* Exported macros -----------------------------------------------------------*/ |
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
void DBG_Init( void ); |
||||||
|
|
||||||
|
void Error_Handler( void ); |
||||||
|
|
||||||
|
#ifdef DEBUG |
||||||
|
|
||||||
|
#define DBG_GPIO_WRITE( gpio, n, x ) HAL_GPIO_WritePin( gpio, n, (GPIO_PinState)(x) ) |
||||||
|
|
||||||
|
#define DBG_GPIO_SET( gpio, n ) gpio->BSRR = n |
||||||
|
|
||||||
|
#define DBG_GPIO_RST( gpio, n ) gpio->BRR = n |
||||||
|
|
||||||
|
#define DBG_RTC_OUTPUT RTC_OUTPUT_DISABLE; /* RTC_OUTPUT_ALARMA on PC13 */ |
||||||
|
|
||||||
|
#define DBG( x ) do{ x } while(0) |
||||||
|
|
||||||
|
#ifdef TRACE |
||||||
|
|
||||||
|
#define DBG_PRINTF(...) vcom_Send(__VA_ARGS__) |
||||||
|
|
||||||
|
#define DBG_PRINTF_CRITICAL(...) vcom_Send_Lp(__VA_ARGS__) |
||||||
|
|
||||||
|
#else /*TRACE*/ |
||||||
|
|
||||||
|
#define DBG_PRINTF(...) |
||||||
|
|
||||||
|
#define DBG_PRINTF_CRITICAL(...) |
||||||
|
|
||||||
|
#endif /*TRACE*/ |
||||||
|
|
||||||
|
|
||||||
|
#else /* DEBUG */ |
||||||
|
|
||||||
|
#define DBG_GPIO_WRITE( gpio, n, x ) |
||||||
|
|
||||||
|
#define DBG_GPIO_SET( gpio, n ) |
||||||
|
|
||||||
|
#define DBG_GPIO_RST( gpio, n ) |
||||||
|
|
||||||
|
#define DBG( x ) do{ } while(0) |
||||||
|
|
||||||
|
#define DBG_PRINTF(...) |
||||||
|
|
||||||
|
#define DBG_PRINTF_CRITICAL(...) |
||||||
|
|
||||||
|
#define DBG_RTC_OUTPUT RTC_OUTPUT_DISABLE; |
||||||
|
|
||||||
|
#endif /* DEBUG */ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __DEBUG_H__*/ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,88 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: contains all hardware driver |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file hw.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief contains all hardware driver |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __HW_H__ |
||||||
|
#define __HW_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include <math.h> |
||||||
|
#include <stdbool.h> |
||||||
|
#include <stdint.h> |
||||||
|
#include "stm32l0xx.h" |
||||||
|
#include "stm32l0xx_hal.h" |
||||||
|
#include "stm32l0xx_hw_conf.h" |
||||||
|
#include "hw_conf.h" |
||||||
|
#include "hw_gpio.h" |
||||||
|
#include "hw_spi.h" |
||||||
|
#include "hw_rtc.h" |
||||||
|
#include "hw_msp.h" |
||||||
|
#include "debug.h" |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __HW_H__ */ |
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
|
@ -0,0 +1,148 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: contains hardaware configuration Macros and Constants |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file hw_conf.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief contains hardware configuration Macros and Constants |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __HW_CONF_H__ |
||||||
|
#define __HW_CONF_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
|
||||||
|
#ifdef USE_STM32F0XX_NUCLEO |
||||||
|
#include "stm32f0xx_hal.h" |
||||||
|
#include "stm32f0xx_nucleo.h" |
||||||
|
#include "stm32f0xx_hal_conf.h" |
||||||
|
#error "create stm32f0xx_hw_conf.h " |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef USE_STM32F1XX_NUCLEO |
||||||
|
#include "stm32f1xx_hal.h" |
||||||
|
#include "stm32f1xx_nucleo.h" |
||||||
|
#include "stm32f1xx_hal_conf.h" |
||||||
|
#error "create stm32f1xx_hw_conf.h " |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef USE_STM32F3XX_NUCLEO |
||||||
|
#include "stm32f3xx_hal.h" |
||||||
|
#include "stm32f3xx_nucleo.h" |
||||||
|
#include "stm32f3xx_hal_conf.h" |
||||||
|
#error "create stm32f3xx_hw_conf.h " |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef USE_STM32F4XX_NUCLEO |
||||||
|
#include "stm32f4xx_hal.h" |
||||||
|
#include "stm32f4xx_nucleo.h" |
||||||
|
#include "stm32f4xx_hal_conf.h" |
||||||
|
#error "create stm32f4xx_hw_conf.h " |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef USE_STM32L0XX_NUCLEO |
||||||
|
#include "stm32l0xx_hal.h" |
||||||
|
#include "stm32l0xx_nucleo.h" |
||||||
|
#include "stm32l0xx_hal_conf.h" |
||||||
|
#include "stm32l0xx_hw_conf.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef USE_STM32L1XX_NUCLEO |
||||||
|
#include "stm32l1xx_hal.h" |
||||||
|
#include "stm32l1xx_nucleo.h" |
||||||
|
#include "stm32l1xx_hal_conf.h" |
||||||
|
#include "stm32l1xx_hw_conf.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef USE_STM32L4XX_NUCLEO |
||||||
|
#include "stm32l4xx_hal.h" |
||||||
|
#include "stm32l4xx_nucleo.h" |
||||||
|
#include "stm32l4xx_hal_conf.h" |
||||||
|
#include "stm32l4xx_hw_conf.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef USE_B_L072Z_LRWAN1 |
||||||
|
#include "stm32l0xx_hal.h" |
||||||
|
#include "b-l072z-lrwan1.h" |
||||||
|
#include "stm32l0xx_hal_conf.h" |
||||||
|
#include "mlm32l0xx_hw_conf.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
/* --------Preprocessor compile swicth------------ */ |
||||||
|
/* debug swicthes in debug.h */ |
||||||
|
//#define DEBUG
|
||||||
|
//#define TRACE
|
||||||
|
|
||||||
|
/* uncomment below line to never enter lowpower modes in main.c*/ |
||||||
|
//#define LOW_POWER_DISABLE
|
||||||
|
|
||||||
|
/* debug swicthes in bsp.c */ |
||||||
|
//#define SENSOR_ENABLED
|
||||||
|
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __HW_CONF_H__ */ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,154 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Bleeper board GPIO driver implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file hw_gpio.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief Header for driver hw_rtc.c module |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __HW_GPIO_H__ |
||||||
|
#define __HW_GPIO_H__ |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
|
||||||
|
typedef void( GpioIrqHandler )( void ); |
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
/* Exported macros -----------------------------------------------------------*/ |
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* GPIO IRQ handler function prototype |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
IRQn_Type MSP_GetIRQn( uint16_t gpioPin); |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Initializes the given GPIO object |
||||||
|
* |
||||||
|
* @param GPIOx: where x can be (A..E and H) |
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @param [IN] initStruct GPIO_InitTypeDef intit structure |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_Init( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_InitTypeDef* initStruct); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Records the interrupt handler for the GPIO object |
||||||
|
* |
||||||
|
* @param GPIOx: where x can be (A..E and H)
|
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @param [IN] prio NVIC priority (0 is highest) |
||||||
|
* @param [IN] irqHandler points to the function to execute |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_SetIrq( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t prio, GpioIrqHandler *irqHandler ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Execute the interrupt from the object |
||||||
|
* |
||||||
|
* @param GPIOx: where x can be (A..E and H)
|
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_IrqHandler( uint16_t GPIO_Pin ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Writes the given value to the GPIO output |
||||||
|
* |
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @param [IN] value New GPIO output value |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_Write( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t value ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Reads the current GPIO input value |
||||||
|
* |
||||||
|
* @param GPIOx: where x can be (A..E and H)
|
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @retval value Current GPIO input value |
||||||
|
*/ |
||||||
|
uint32_t HW_GPIO_Read( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin ); |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __HW_GPIO_H__ */ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
|
@ -0,0 +1,221 @@ |
|||||||
|
|
||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Header for driver hw msp module |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file hw_msp.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief Header for driver hw msp module |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
|
||||||
|
#ifndef __HW_MSP_H__ |
||||||
|
#define __HW_MSP_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
|
||||||
|
#define VDDA_VREFINT_CAL ((uint32_t) 3000) |
||||||
|
#define BAT_CR2032 ((uint32_t) 3000) |
||||||
|
#define VDD_BAT BAT_CR2032 |
||||||
|
#define VDD_MIN 1800 |
||||||
|
|
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
/* Exported macros -----------------------------------------------------------*/ |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief GPIOs Macro |
||||||
|
*/ |
||||||
|
|
||||||
|
#define RCC_GPIO_CLK_ENABLE( __GPIO_PORT__ ) \ |
||||||
|
do { \
|
||||||
|
switch( __GPIO_PORT__) \
|
||||||
|
{ \
|
||||||
|
case GPIOA_BASE: __HAL_RCC_GPIOA_CLK_ENABLE(); break; \
|
||||||
|
case GPIOB_BASE: __HAL_RCC_GPIOB_CLK_ENABLE(); break; \
|
||||||
|
case GPIOC_BASE: __HAL_RCC_GPIOC_CLK_ENABLE(); break; \
|
||||||
|
case GPIOD_BASE: __HAL_RCC_GPIOD_CLK_ENABLE(); break; \
|
||||||
|
case GPIOH_BASE: default: __HAL_RCC_GPIOH_CLK_ENABLE(); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define RCC_GPIO_CLK_DISABLE( __GPIO_PORT__ ) \ |
||||||
|
do { \
|
||||||
|
switch( __GPIO_PORT__) \
|
||||||
|
{ \
|
||||||
|
case GPIOA_BASE: __HAL_RCC_GPIOA_CLK_DISABLE(); break; \
|
||||||
|
case GPIOB_BASE: __HAL_RCC_GPIOB_CLK_DISABLE(); break; \
|
||||||
|
case GPIOC_BASE: __HAL_RCC_GPIOC_CLK_DISABLE(); break; \
|
||||||
|
case GPIOD_BASE: __HAL_RCC_GPIOD_CLK_DISABLE(); break; \
|
||||||
|
case GPIOH_BASE: default: __HAL_RCC_GPIOH_CLK_ENABLE(); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Get the current temperature |
||||||
|
* |
||||||
|
* \retval value temperature in degreeCelcius( q7.8 ) |
||||||
|
*/ |
||||||
|
uint16_t HW_GetTemperatureLevel( void ); |
||||||
|
/*!
|
||||||
|
* \brief Get the current battery level |
||||||
|
* |
||||||
|
* \retval value battery level ( 0: very low, 254: fully charged ) |
||||||
|
*/ |
||||||
|
uint8_t HW_GetBatteryLevel( void ); |
||||||
|
/*!
|
||||||
|
* \brief Initializes the boards peripherals. |
||||||
|
*/ |
||||||
|
void HW_Init( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief De-initializes the target board peripherals to decrease power |
||||||
|
* consumption. |
||||||
|
*/ |
||||||
|
|
||||||
|
void HW_DeInit( void ); |
||||||
|
/*!
|
||||||
|
* Returns a pseudo random seed generated using the MCU Unique ID |
||||||
|
* |
||||||
|
* \retval seed Generated pseudo random seed |
||||||
|
*/ |
||||||
|
uint32_t HW_GetRandomSeed( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the board 64 bits unique ID
|
||||||
|
* |
||||||
|
* \param [IN] id Pointer to an array that will contain the Unique ID |
||||||
|
*/ |
||||||
|
void HW_GetUniqueId( uint8_t *id ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Initializes the HW and enters stope mode |
||||||
|
*/ |
||||||
|
void HW_EnterStopMode( void); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Exits stop mode and Initializes the HW |
||||||
|
*/ |
||||||
|
void HW_ExitStopMode( void); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enters Low Power Sleep Mode |
||||||
|
* @note ARM exists the function when waking up |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_EnterSleepMode( void); |
||||||
|
|
||||||
|
typedef enum |
||||||
|
{ |
||||||
|
e_LOW_POWER_RTC = (1<<0), |
||||||
|
e_LOW_POWER_GPS = (1<<1), |
||||||
|
e_LOW_POWER_UART = (1<<2), /* can be used to forbid stop mode in case of uart Xfer*/ |
||||||
|
} e_LOW_POWER_State_Id_t; |
||||||
|
|
||||||
|
/* ADC */ |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Initializes the ADC input |
||||||
|
* |
||||||
|
* \param [IN] scl ADC input pin name to be used |
||||||
|
*/ |
||||||
|
void HW_AdcInit( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief DeInitializes the ADC
|
||||||
|
* |
||||||
|
* \param [IN] none |
||||||
|
*/ |
||||||
|
void HW_AdcDeInit( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Read the analogue voltage value |
||||||
|
* |
||||||
|
* \param [IN] Channel to read |
||||||
|
* \retval value Analogue pin value |
||||||
|
*/ |
||||||
|
uint16_t HW_AdcReadChannel( uint32_t Channel); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Configures the sytem Clock at start-up |
||||||
|
* |
||||||
|
* \param none |
||||||
|
* \retval none |
||||||
|
*/ |
||||||
|
void SystemClock_Config( void ); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure all GPIO's to Analog input to reduce the power consumption |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HW_GpioInit(void); |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __HW_MSP_H__ */ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,179 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Bleeper board GPIO driver implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file hw_rtc.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief Header for driver hw_rtc.c module |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef __HW_RTC_H__ |
||||||
|
#define __HW_RTC_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "utilities.h" |
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
/* Exported macros -----------------------------------------------------------*/ |
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Initializes the RTC timer |
||||||
|
* @note The timer is based on the RTC |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_Init( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Stop the Alarm |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_StopAlarm( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Return the minimum timeout the RTC is able to handle |
||||||
|
* @param none |
||||||
|
* @retval minimum value for a timeout |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetMinimumTimeout( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Set the alarm |
||||||
|
* @note The alarm is set at Reference + timeout |
||||||
|
* @param timeout Duration of the Timer in ticks |
||||||
|
*/ |
||||||
|
void HW_RTC_SetAlarm( uint32_t timeout ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get the RTC timer elapsed time since the last Reference was set |
||||||
|
* @retval RTC Elapsed time in ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetTimerElapsedTime( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get the RTC timer value |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetTimerValue( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Set the RTC timer Reference |
||||||
|
* @retval Timer Reference Value in Ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_SetTimerContext( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get the RTC timer Reference |
||||||
|
* @retval Timer Value in Ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetTimerContext( void ); |
||||||
|
/*!
|
||||||
|
* @brief RTC IRQ Handler on the RTC Alarm |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_IrqHandler ( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief a delay of delay ms by polling RTC |
||||||
|
* @param delay in ms |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_DelayMs( uint32_t delay ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief calculates the wake up time between wake up and mcu start |
||||||
|
* @note resolution in RTC_ALARM_TIME_BASE |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_setMcuWakeUpTime( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief returns the wake up time in us |
||||||
|
* @param none |
||||||
|
* @retval wake up time in ticks |
||||||
|
*/ |
||||||
|
int16_t HW_RTC_getMcuWakeUpTime( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief converts time in ms to time in ticks |
||||||
|
* @param [IN] time in milliseconds |
||||||
|
* @retval returns time in timer ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_ms2Tick( TimerTime_t timeMicroSec ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief converts time in ticks to time in ms |
||||||
|
* @param [IN] time in timer ticks |
||||||
|
* @retval returns time in timer milliseconds |
||||||
|
*/ |
||||||
|
TimerTime_t HW_RTC_Tick2ms( uint32_t tick ); |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __HW_RTC_H__ */ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,126 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Header for driver hw spi module |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file hw_spi.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief Header for driver hw_spi.c module |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __HW_SPI_H__ |
||||||
|
#define __HW_SPI_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
/* Exported macros -----------------------------------------------------------*/ |
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Initializes the SPI object and MCU peripheral |
||||||
|
* |
||||||
|
* @param [IN] none |
||||||
|
*/ |
||||||
|
void HW_SPI_Init( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief De-initializes the SPI object and MCU peripheral |
||||||
|
* |
||||||
|
* @param [IN] none |
||||||
|
*/ |
||||||
|
void HW_SPI_DeInit( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Initializes the SPI IOs |
||||||
|
* |
||||||
|
* @param [IN] none |
||||||
|
*/ |
||||||
|
void HW_SPI_IoInit( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief De-initializes the SPI IOs |
||||||
|
* |
||||||
|
* @param [IN] none |
||||||
|
*/ |
||||||
|
void HW_SPI_IoDeInit( void ); |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Sends outData and receives inData |
||||||
|
* |
||||||
|
* @param [IN] outData Byte to be sent |
||||||
|
* @retval inData Received byte. |
||||||
|
*/ |
||||||
|
uint16_t HW_SPI_InOut( uint16_t outData ); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __HW_SPI_H__ */ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,176 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: contains hardaware configuration Macros and Constants |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file stm32l0xx_hw_conf.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief contains hardaware configuration Macros and Constants |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __HW_CONF_L0_H__ |
||||||
|
#define __HW_CONF_L0_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "hw.h" |
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
|
||||||
|
//#define RADIO_DIO_4
|
||||||
|
//#define RADIO_DIO_5
|
||||||
|
|
||||||
|
/* LORA I/O definition */ |
||||||
|
|
||||||
|
|
||||||
|
#define RADIO_RESET_PORT GPIOA |
||||||
|
#define RADIO_RESET_PIN GPIO_PIN_0 |
||||||
|
|
||||||
|
#define RADIO_MOSI_PORT GPIOA |
||||||
|
#define RADIO_MOSI_PIN GPIO_PIN_7 |
||||||
|
|
||||||
|
#define RADIO_MISO_PORT GPIOA |
||||||
|
#define RADIO_MISO_PIN GPIO_PIN_6 |
||||||
|
|
||||||
|
#define RADIO_SCLK_PORT GPIOA |
||||||
|
#define RADIO_SCLK_PIN GPIO_PIN_5 |
||||||
|
|
||||||
|
#define RADIO_NSS_PORT GPIOB |
||||||
|
#define RADIO_NSS_PIN GPIO_PIN_6 |
||||||
|
|
||||||
|
#define RADIO_DIO_0_PORT GPIOA |
||||||
|
#define RADIO_DIO_0_PIN GPIO_PIN_10 |
||||||
|
|
||||||
|
#define RADIO_DIO_1_PORT GPIOB |
||||||
|
#define RADIO_DIO_1_PIN GPIO_PIN_3 |
||||||
|
|
||||||
|
#define RADIO_DIO_2_PORT GPIOB |
||||||
|
#define RADIO_DIO_2_PIN GPIO_PIN_5 |
||||||
|
|
||||||
|
#define RADIO_DIO_3_PORT GPIOB |
||||||
|
#define RADIO_DIO_3_PIN GPIO_PIN_4 |
||||||
|
|
||||||
|
#ifdef RADIO_DIO_4 |
||||||
|
#define RADIO_DIO_4_PORT GPIOA |
||||||
|
#define RADIO_DIO_4_PIN GPIO_PIN_9 |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef RADIO_DIO_5 |
||||||
|
#define RADIO_DIO_5_PORT GPIOC |
||||||
|
#define RADIO_DIO_5_PIN GPIO_PIN_7 |
||||||
|
#endif |
||||||
|
|
||||||
|
#define RADIO_ANT_SWITCH_PORT GPIOC |
||||||
|
#define RADIO_ANT_SWITCH_PIN GPIO_PIN_1 |
||||||
|
|
||||||
|
#define BAT_LEVEL_PORT GPIOA |
||||||
|
#define BAT_LEVEL_PIN GPIO_PIN_4 |
||||||
|
/* SPI MACRO redefinition */ |
||||||
|
|
||||||
|
#define SPI_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE() |
||||||
|
|
||||||
|
#define SPI1_AF GPIO_AF0_SPI1 |
||||||
|
|
||||||
|
/* ADC MACRO redefinition */ |
||||||
|
|
||||||
|
#ifdef USE_STM32L0XX_NUCLEO |
||||||
|
#define ADC_READ_CHANNEL ADC_CHANNEL_4 |
||||||
|
#define ADCCLK_ENABLE() __HAL_RCC_ADC1_CLK_ENABLE() ; |
||||||
|
#define ADCCLK_DISABLE() __HAL_RCC_ADC1_CLK_DISABLE() ; |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
/* --------------------------- RTC HW definition -------------------------------- */ |
||||||
|
|
||||||
|
#define RTC_OUTPUT DBG_RTC_OUTPUT |
||||||
|
|
||||||
|
#define RTC_Alarm_IRQn RTC_IRQn |
||||||
|
/* --------------------------- USART HW definition -------------------------------*/ |
||||||
|
|
||||||
|
|
||||||
|
#define USARTX USART2 |
||||||
|
#define USARTX_CLK_ENABLE() __USART2_CLK_ENABLE(); |
||||||
|
#define USARTX_RX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() |
||||||
|
#define USARTX_TX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() |
||||||
|
|
||||||
|
#define USARTX_FORCE_RESET() __USART2_FORCE_RESET() |
||||||
|
#define USARTX_RELEASE_RESET() __USART2_RELEASE_RESET() |
||||||
|
|
||||||
|
|
||||||
|
#define USARTX_TX_PIN GPIO_PIN_2 |
||||||
|
#define USARTX_TX_GPIO_PORT GPIOA |
||||||
|
#define USARTX_TX_AF GPIO_AF4_USART2 |
||||||
|
#define USARTX_RX_PIN GPIO_PIN_3 |
||||||
|
#define USARTX_RX_GPIO_PORT GPIOA |
||||||
|
#define USARTX_RX_AF GPIO_AF4_USART2 |
||||||
|
|
||||||
|
/* Definition for USARTx's NVIC */ |
||||||
|
#define USARTX_IRQn USART2_IRQn |
||||||
|
#define USARTX_IRQHandler USART2_IRQHandler |
||||||
|
|
||||||
|
|
||||||
|
#define LED_Toggle( x ) |
||||||
|
#define LED_On( x ) |
||||||
|
#define LED_Off( x ) |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __HW_CONF_L0_H__ */ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,60 +1,93 @@ |
|||||||
/**
|
/*
|
||||||
****************************************************************************** |
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Bleeper board GPIO driver implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
* @file stm32l0xx_it.h |
* @file stm32l0xx_it.h |
||||||
* @brief This file contains the headers of the interrupt handlers. |
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief manages interupt |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
* |
* |
||||||
* COPYRIGHT(c) 2017 STMicroelectronics |
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
* |
* |
||||||
* Redistribution and use in source and binary forms, with or without modification, |
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
* are permitted provided that the following conditions are met: |
* this list of conditions and the following disclaimer. |
||||||
* 1. Redistributions of source code must retain the above copyright notice, |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
* this list of conditions and the following disclaimer. |
* this list of conditions and the following disclaimer in the documentation |
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
* and/or other materials provided with the distribution. |
||||||
* this list of conditions and the following disclaimer in the documentation |
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
* and/or other materials provided with the distribution. |
* contributors to this software may be used to endorse or promote products
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
* derived from this software without specific written permission. |
||||||
* may be used to endorse or promote products derived from this software |
* 4. This software, including modifications and/or derivative works of this
|
||||||
* without specific prior written permission. |
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
* |
* |
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
* |
* |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
*/ |
*/ |
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
#ifndef __STM32L0xx_IT_H |
#ifndef __STM32L0xx_IT_H__ |
||||||
#define __STM32L0xx_IT_H |
#define __STM32L0xx_IT_H__ |
||||||
|
|
||||||
#ifdef __cplusplus |
#ifdef __cplusplus |
||||||
extern "C" { |
extern "C" { |
||||||
#endif |
#endif |
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/ |
/* Includes ------------------------------------------------------------------*/ |
||||||
#include "stm32l0xx_hal.h" |
|
||||||
#include "main.h" |
|
||||||
/* Exported types ------------------------------------------------------------*/ |
/* Exported types ------------------------------------------------------------*/ |
||||||
/* Exported constants --------------------------------------------------------*/ |
/* Exported constants --------------------------------------------------------*/ |
||||||
/* Exported macro ------------------------------------------------------------*/ |
/* Exported macro ------------------------------------------------------------*/ |
||||||
/* Exported functions ------------------------------------------------------- */ |
/* Exported functions ------------------------------------------------------- */ |
||||||
|
|
||||||
|
void NMI_Handler(void); |
||||||
|
void HardFault_Handler(void); |
||||||
|
void MemManage_Handler(void); |
||||||
|
void BusFault_Handler(void); |
||||||
|
void UsageFault_Handler(void); |
||||||
void SVC_Handler(void); |
void SVC_Handler(void); |
||||||
|
void DebugMon_Handler(void); |
||||||
void PendSV_Handler(void); |
void PendSV_Handler(void); |
||||||
void SysTick_Handler(void); |
void SysTick_Handler(void); |
||||||
|
void EXTI4_15_IRQHandler(void); |
||||||
|
void TIM21_IRQHandler(void); |
||||||
|
|
||||||
#ifdef __cplusplus |
#ifdef __cplusplus |
||||||
} |
} |
||||||
#endif |
#endif |
||||||
|
|
||||||
#endif /* __STM32L0xx_IT_H */ |
#endif /* __STM32L0xx_IT_H__ */ |
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
@ -0,0 +1,142 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: virtual com port driver |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file vcom.h |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief Header for vcom.c module |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __VCOM_H__ |
||||||
|
#define __VCOM_H__ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Init the VCOM. |
||||||
|
* @param None |
||||||
|
* @return None |
||||||
|
*/ |
||||||
|
void vcom_Init(void); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DeInit the VCOM. |
||||||
|
* @param None |
||||||
|
* @return None |
||||||
|
*/ |
||||||
|
void vcom_DeInit(void); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Init the VCOM IOs. |
||||||
|
* @param None |
||||||
|
* @return None |
||||||
|
*/ |
||||||
|
void vcom_IoInit(void); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DeInit the VCOM IOs. |
||||||
|
* @param None |
||||||
|
* @return None |
||||||
|
*/ |
||||||
|
void vcom_IoDeInit(void); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Records string on circular Buffer and set SW interrupt |
||||||
|
* @note Set NVIC to call vcom_Send |
||||||
|
* @param string |
||||||
|
* @return None |
||||||
|
*/ |
||||||
|
void vcom_Send( char *format, ... ); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sends circular Buffer on com port in IT mode |
||||||
|
* @note called from low Priority interrupt |
||||||
|
* @param None |
||||||
|
* @return None |
||||||
|
*/ |
||||||
|
void vcom_Print( void); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Records string on circular Buffer |
||||||
|
* @note To be called only from critical section from low power section |
||||||
|
* Other wise use vcom_Send |
||||||
|
* @param string |
||||||
|
* @return None |
||||||
|
*/ |
||||||
|
void vcom_Send_Lp( char *format, ... ); |
||||||
|
|
||||||
|
/* Exported macros -----------------------------------------------------------*/ |
||||||
|
#if 1 |
||||||
|
#define PRINTF(...) vcom_Send(__VA_ARGS__) |
||||||
|
#else |
||||||
|
#define PRINTF(...) |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __VCOM_H__*/ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,119 @@ |
|||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* @file debug.c |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief debug API |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "hw.h" |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initializes the debug |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void DBG_Init( void ) |
||||||
|
{ |
||||||
|
#ifdef DEBUG |
||||||
|
GPIO_InitTypeDef gpioinitstruct = {0}; |
||||||
|
|
||||||
|
/* Enable the GPIO_B Clock */ |
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE(); |
||||||
|
|
||||||
|
/* Configure the GPIO pin */
|
||||||
|
gpioinitstruct.Mode = GPIO_MODE_OUTPUT_PP; |
||||||
|
gpioinitstruct.Pull = GPIO_PULLUP; |
||||||
|
gpioinitstruct.Speed = GPIO_SPEED_HIGH; |
||||||
|
|
||||||
|
gpioinitstruct.Pin = (GPIO_PIN_12 | GPIO_PIN_13| GPIO_PIN_14 | GPIO_PIN_15); |
||||||
|
HAL_GPIO_Init(GPIOB, &gpioinitstruct); |
||||||
|
|
||||||
|
/* Reset debug Pins */ |
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); |
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_RESET); |
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); |
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_RESET); |
||||||
|
#if 0 |
||||||
|
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1);
|
||||||
|
#endif |
||||||
|
|
||||||
|
__HAL_RCC_DBGMCU_CLK_ENABLE( ); |
||||||
|
|
||||||
|
HAL_DBGMCU_EnableDBGSleepMode( ); |
||||||
|
HAL_DBGMCU_EnableDBGStopMode( ); |
||||||
|
HAL_DBGMCU_EnableDBGStandbyMode( ); |
||||||
|
|
||||||
|
#else /* DEBUG */ |
||||||
|
/* sw interface off*/ |
||||||
|
GPIO_InitTypeDef GPIO_InitStructure ={0}; |
||||||
|
|
||||||
|
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; |
||||||
|
GPIO_InitStructure.Pull = GPIO_NOPULL; |
||||||
|
GPIO_InitStructure.Pin = (GPIO_PIN_13 | GPIO_PIN_14); |
||||||
|
__GPIOA_CLK_ENABLE() ;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); |
||||||
|
__GPIOA_CLK_DISABLE() ; |
||||||
|
|
||||||
|
__HAL_RCC_DBGMCU_CLK_ENABLE( ); |
||||||
|
HAL_DBGMCU_DisableDBGSleepMode( ); |
||||||
|
HAL_DBGMCU_DisableDBGStopMode( ); |
||||||
|
HAL_DBGMCU_DisableDBGStandbyMode( ); |
||||||
|
__HAL_RCC_DBGMCU_CLK_DISABLE( ); |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Error_Handler |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void Error_Handler(void) |
||||||
|
{ |
||||||
|
DBG_PRINTF("Error_Handler\n\r"); |
||||||
|
while(1); |
||||||
|
} |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
|
||||||
|
|
@ -0,0 +1,191 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Bleeper board GPIO driver implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file hw_gpio.c |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief driver for GPIO |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "hw.h" |
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/ |
||||||
|
/* Private define ------------------------------------------------------------*/ |
||||||
|
/* Private macro -------------------------------------------------------------*/ |
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
static GpioIrqHandler *GpioIrq[16] = { NULL }; |
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
|
||||||
|
static uint8_t HW_GPIO_GetBitPos(uint16_t GPIO_Pin); |
||||||
|
|
||||||
|
/* Exported functions ---------------------------------------------------------*/ |
||||||
|
/*!
|
||||||
|
* @brief Initializes the given GPIO object |
||||||
|
* |
||||||
|
* @param GPIOx: where x can be (A..E and H) |
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @param [IN] initStruct GPIO_InitTypeDef intit structure |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_Init( GPIO_TypeDef* port, uint16_t GPIO_Pin, GPIO_InitTypeDef* initStruct) |
||||||
|
{ |
||||||
|
|
||||||
|
RCC_GPIO_CLK_ENABLE( (uint32_t) port); |
||||||
|
|
||||||
|
initStruct->Pin = GPIO_Pin ; |
||||||
|
|
||||||
|
HAL_GPIO_Init( port, initStruct ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Records the interrupt handler for the GPIO object |
||||||
|
* |
||||||
|
* @param GPIOx: where x can be (A..E and H)
|
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @param [IN] prio NVIC priority (0 is highest) |
||||||
|
* @param [IN] irqHandler points to the function to execute |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_SetIrq( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t prio, GpioIrqHandler *irqHandler ) |
||||||
|
{ |
||||||
|
IRQn_Type IRQnb; |
||||||
|
|
||||||
|
uint32_t BitPos = HW_GPIO_GetBitPos( GPIO_Pin ) ; |
||||||
|
|
||||||
|
if ( irqHandler != NULL) |
||||||
|
{ |
||||||
|
GpioIrq[ BitPos ] = irqHandler; |
||||||
|
|
||||||
|
IRQnb = MSP_GetIRQn( GPIO_Pin ); |
||||||
|
|
||||||
|
HAL_NVIC_SetPriority( IRQnb , prio, 0); |
||||||
|
|
||||||
|
HAL_NVIC_EnableIRQ( IRQnb ); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Execute the interrupt from the object |
||||||
|
* |
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_IrqHandler( uint16_t GPIO_Pin ) |
||||||
|
{ |
||||||
|
uint32_t BitPos = HW_GPIO_GetBitPos( GPIO_Pin ); |
||||||
|
|
||||||
|
if ( GpioIrq[ BitPos ] != NULL) |
||||||
|
{ |
||||||
|
GpioIrq[ BitPos ] ( ); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Writes the given value to the GPIO output |
||||||
|
* |
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @param [IN] value New GPIO output value |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GPIO_Write( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t value ) |
||||||
|
{ |
||||||
|
HAL_GPIO_WritePin( GPIOx, GPIO_Pin , (GPIO_PinState) value ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Reads the current GPIO input value |
||||||
|
* |
||||||
|
* @param GPIOx: where x can be (A..E and H)
|
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @retval value Current GPIO input value |
||||||
|
*/ |
||||||
|
uint32_t HW_GPIO_Read( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin ) |
||||||
|
{ |
||||||
|
return HAL_GPIO_ReadPin( GPIOx, GPIO_Pin); |
||||||
|
} |
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get the position of the bit set in the GPIO_Pin |
||||||
|
* @param GPIO_Pin: specifies the port bit to be written. |
||||||
|
* This parameter can be one of GPIO_PIN_x where x can be (0..15). |
||||||
|
* All port bits are not necessarily available on all GPIOs. |
||||||
|
* @retval the position of the bit |
||||||
|
*/ |
||||||
|
static uint8_t HW_GPIO_GetBitPos(uint16_t GPIO_Pin) |
||||||
|
{ |
||||||
|
uint8_t PinPos=0; |
||||||
|
|
||||||
|
if ( ( GPIO_Pin & 0xFF00 ) != 0) { PinPos |= 0x8; } |
||||||
|
if ( ( GPIO_Pin & 0xF0F0 ) != 0) { PinPos |= 0x4; } |
||||||
|
if ( ( GPIO_Pin & 0xCCCC ) != 0) { PinPos |= 0x2; } |
||||||
|
if ( ( GPIO_Pin & 0xAAAA ) != 0) { PinPos |= 0x1; } |
||||||
|
|
||||||
|
return PinPos; |
||||||
|
} |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,632 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: MCU RTC timer |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/*******************************************************************************
|
||||||
|
* @file hw_rtc.c |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief driver for RTC |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "hw.h" |
||||||
|
#include "low_power.h" |
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/ |
||||||
|
typedef struct |
||||||
|
{ |
||||||
|
TimerTime_t Rtc_Time; /* Reference time */ |
||||||
|
|
||||||
|
RTC_TimeTypeDef RTC_Calndr_Time; /* Reference time in calendar format */ |
||||||
|
|
||||||
|
RTC_DateTypeDef RTC_Calndr_Date; /* Reference date in calendar format */ |
||||||
|
|
||||||
|
} RtcTimerContext_t; |
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/ |
||||||
|
|
||||||
|
/* MCU Wake Up Time */ |
||||||
|
#define MIN_ALARM_DELAY 3 /* in ticks */ |
||||||
|
|
||||||
|
/* subsecond number of bits */ |
||||||
|
#define N_PREDIV_S 10 |
||||||
|
|
||||||
|
/* Synchonuous prediv */ |
||||||
|
#define PREDIV_S ((1<<N_PREDIV_S)-1) |
||||||
|
|
||||||
|
/* Asynchonuous prediv */ |
||||||
|
#define PREDIV_A (1<<(15-N_PREDIV_S))-1 |
||||||
|
|
||||||
|
/* Sub-second mask definition */ |
||||||
|
#if (N_PREDIV_S == 10) |
||||||
|
#define HW_RTC_ALARMSUBSECONDMASK RTC_ALARMSUBSECONDMASK_SS14_10 |
||||||
|
#else |
||||||
|
#error "Please define HW_RTC_ALARMSUBSECONDMASK" |
||||||
|
#endif |
||||||
|
|
||||||
|
/* RTC Time base in us */ |
||||||
|
#define USEC_NUMBER 1000000 |
||||||
|
#define MSEC_NUMBER (USEC_NUMBER/1000) |
||||||
|
#define RTC_ALARM_TIME_BASE (USEC_NUMBER>>N_PREDIV_S) |
||||||
|
|
||||||
|
#define COMMON_FACTOR 3 |
||||||
|
#define CONV_NUMER (MSEC_NUMBER>>COMMON_FACTOR) |
||||||
|
#define CONV_DENOM (1<<(N_PREDIV_S-COMMON_FACTOR)) |
||||||
|
|
||||||
|
#define DAYS_IN_LEAP_YEAR (uint32_t) 366 |
||||||
|
|
||||||
|
#define DAYS_IN_YEAR (uint32_t) 365 |
||||||
|
|
||||||
|
#define SECONDS_IN_1DAY (uint32_t) 86400 |
||||||
|
|
||||||
|
#define SECONDS_IN_1HOUR (uint32_t) 3600 |
||||||
|
|
||||||
|
#define SECONDS_IN_1MINUTE (uint32_t) 60 |
||||||
|
|
||||||
|
#define MINUTES_IN_1HOUR (uint32_t) 60 |
||||||
|
|
||||||
|
#define HOURS_IN_1DAY (uint32_t) 24 |
||||||
|
|
||||||
|
#define DAYS_IN_MONTH_CORRECTION_NORM ((uint32_t) 0x99AAA0 ) |
||||||
|
#define DAYS_IN_MONTH_CORRECTION_LEAP ((uint32_t) 0x445550 ) |
||||||
|
|
||||||
|
|
||||||
|
/* Calculates ceiling(X/N) */ |
||||||
|
#define DIVC(X,N) ( ( (X) + (N) -1 ) / (N) ) |
||||||
|
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/ |
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
/*!
|
||||||
|
* \brief Indicates if the RTC is already Initalized or not |
||||||
|
*/ |
||||||
|
static bool HW_RTC_Initalized = false; |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief compensates MCU wakeup time |
||||||
|
*/ |
||||||
|
|
||||||
|
static bool McuWakeUpTimeInitialized = false; |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief compensates MCU wakeup time |
||||||
|
*/ |
||||||
|
|
||||||
|
static int16_t McuWakeUpTimeCal = 0; |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Number of days in each month on a normal year |
||||||
|
*/ |
||||||
|
static const uint8_t DaysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Number of days in each month on a leap year |
||||||
|
*/ |
||||||
|
static const uint8_t DaysInMonthLeapYear[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
||||||
|
|
||||||
|
static RTC_HandleTypeDef RtcHandle={0}; |
||||||
|
|
||||||
|
static RTC_AlarmTypeDef RTC_AlarmStructure; |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Keep the value of the RTC timer when the RTC alarm is set |
||||||
|
* Set with the HW_RTC_SetTimerContext function |
||||||
|
* Value is kept as a Reference to calculate alarm |
||||||
|
*/ |
||||||
|
static RtcTimerContext_t RtcTimerContext; |
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
|
||||||
|
static void HW_RTC_SetConfig( void ); |
||||||
|
|
||||||
|
static void HW_RTC_SetAlarmConfig( void ); |
||||||
|
|
||||||
|
static void HW_RTC_StartWakeUpAlarm( uint32_t timeoutValue ); |
||||||
|
|
||||||
|
static TimerTime_t HW_RTC_GetCalendarValue( RTC_DateTypeDef* RTC_DateStruct, RTC_TimeTypeDef* RTC_TimeStruct ); |
||||||
|
|
||||||
|
/* Exported functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Initializes the RTC timer |
||||||
|
* @note The timer is based on the RTC |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_Init( void ) |
||||||
|
{ |
||||||
|
if( HW_RTC_Initalized == false ) |
||||||
|
{ |
||||||
|
HW_RTC_SetConfig( ); |
||||||
|
HW_RTC_SetAlarmConfig( ); |
||||||
|
HW_RTC_SetTimerContext( ); |
||||||
|
HW_RTC_Initalized = true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Configures the RTC timer |
||||||
|
* @note The timer is based on the RTC |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
static void HW_RTC_SetConfig( void ) |
||||||
|
{ |
||||||
|
RTC_TimeTypeDef RTC_TimeStruct; |
||||||
|
RTC_DateTypeDef RTC_DateStruct; |
||||||
|
|
||||||
|
RtcHandle.Instance = RTC; |
||||||
|
|
||||||
|
RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24; |
||||||
|
RtcHandle.Init.AsynchPrediv = PREDIV_A; /* RTC_ASYNCH_PREDIV; */ |
||||||
|
RtcHandle.Init.SynchPrediv = PREDIV_S; /* RTC_SYNCH_PREDIV; */ |
||||||
|
RtcHandle.Init.OutPut = RTC_OUTPUT; |
||||||
|
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; |
||||||
|
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; |
||||||
|
|
||||||
|
HAL_RTC_Init( &RtcHandle ); |
||||||
|
|
||||||
|
/*Monday 1st January 2016*/ |
||||||
|
RTC_DateStruct.Year = 0; |
||||||
|
RTC_DateStruct.Month = RTC_MONTH_JANUARY; |
||||||
|
RTC_DateStruct.Date = 1; |
||||||
|
RTC_DateStruct.WeekDay = RTC_WEEKDAY_MONDAY; |
||||||
|
HAL_RTC_SetDate(&RtcHandle , &RTC_DateStruct, RTC_FORMAT_BIN); |
||||||
|
|
||||||
|
/*at 0:0:0*/ |
||||||
|
RTC_TimeStruct.Hours = 0; |
||||||
|
RTC_TimeStruct.Minutes = 0; |
||||||
|
|
||||||
|
RTC_TimeStruct.Seconds = 0; |
||||||
|
RTC_TimeStruct.TimeFormat = 0; |
||||||
|
RTC_TimeStruct.SubSeconds = 0; |
||||||
|
RTC_TimeStruct.StoreOperation = RTC_DAYLIGHTSAVING_NONE; |
||||||
|
RTC_TimeStruct.DayLightSaving = RTC_STOREOPERATION_RESET; |
||||||
|
|
||||||
|
HAL_RTC_SetTime(&RtcHandle , &RTC_TimeStruct, RTC_FORMAT_BIN); |
||||||
|
|
||||||
|
/*Enable Direct Read of the calendar registers (not through Shadow) */ |
||||||
|
HAL_RTCEx_EnableBypassShadow(&RtcHandle); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief calculates the wake up time between wake up and mcu start |
||||||
|
* @note resulotion in RTC_ALARM_TIME_BASE in timer ticks |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_setMcuWakeUpTime( void ) |
||||||
|
{ |
||||||
|
RTC_TimeTypeDef RTC_TimeStruct; |
||||||
|
RTC_DateTypeDef RTC_DateStruct; |
||||||
|
|
||||||
|
TimerTime_t now, hit; |
||||||
|
int16_t McuWakeUpTime; |
||||||
|
|
||||||
|
if ((McuWakeUpTimeInitialized == false) && |
||||||
|
( HAL_NVIC_GetPendingIRQ( RTC_Alarm_IRQn ) == 1)) |
||||||
|
{ /* warning: works ok if now is below 30 days
|
||||||
|
it is ok since it's done once at first alarm wake-up*/ |
||||||
|
McuWakeUpTimeInitialized = true; |
||||||
|
now = HW_RTC_GetCalendarValue( &RTC_DateStruct, &RTC_TimeStruct ); |
||||||
|
|
||||||
|
DBG_GPIO_SET(GPIOB, GPIO_PIN_13); |
||||||
|
DBG_GPIO_RST(GPIOB, GPIO_PIN_13); |
||||||
|
HAL_RTC_GetAlarm(&RtcHandle, &RTC_AlarmStructure, RTC_ALARM_A, RTC_FORMAT_BIN ); |
||||||
|
hit = RTC_AlarmStructure.AlarmTime.Seconds+ |
||||||
|
60*(RTC_AlarmStructure.AlarmTime.Minutes+ |
||||||
|
60*(RTC_AlarmStructure.AlarmTime.Hours+ |
||||||
|
24*(RTC_AlarmStructure.AlarmDateWeekDay))); |
||||||
|
hit = ( hit << N_PREDIV_S ) + (PREDIV_S - RTC_AlarmStructure.AlarmTime.SubSeconds); |
||||||
|
|
||||||
|
McuWakeUpTime = (int16_t) ((now-hit)); |
||||||
|
McuWakeUpTimeCal += McuWakeUpTime; |
||||||
|
DBG_PRINTF("Cal=%d, %d\n\r",McuWakeUpTimeCal, McuWakeUpTime); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
int16_t HW_RTC_getMcuWakeUpTime( void ) |
||||||
|
{ |
||||||
|
return McuWakeUpTimeCal; |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief returns the wake up time in ticks |
||||||
|
* @param none |
||||||
|
* @retval wake up time in ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetMinimumTimeout( void ) |
||||||
|
{ |
||||||
|
return( MIN_ALARM_DELAY ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief converts time in ms to time in ticks |
||||||
|
* @param [IN] time in milliseconds |
||||||
|
* @retval returns time in timer ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_ms2Tick( TimerTime_t timeMicroSec ) |
||||||
|
{ |
||||||
|
/*return( ( timeMicroSec / RTC_ALARM_TIME_BASE ) ); */ |
||||||
|
return ( uint32_t) ( ( ((uint64_t)timeMicroSec) * CONV_DENOM ) / CONV_NUMER ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief converts time in ticks to time in ms |
||||||
|
* @param [IN] time in timer ticks |
||||||
|
* @retval returns time in milliseconds |
||||||
|
*/ |
||||||
|
TimerTime_t HW_RTC_Tick2ms( uint32_t tick ) |
||||||
|
{ |
||||||
|
/*return( ( timeMicroSec * RTC_ALARM_TIME_BASE ) ); */ |
||||||
|
return ( ( (uint64_t)( tick )* CONV_NUMER ) / CONV_DENOM ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Set the alarm |
||||||
|
* @note The alarm is set at now (read in this funtion) + timeout |
||||||
|
* @param timeout Duration of the Timer ticks |
||||||
|
*/ |
||||||
|
void HW_RTC_SetAlarm( uint32_t timeout ) |
||||||
|
{ |
||||||
|
/* we don't go in Low Power mode for timeout below MIN_ALARM_DELAY */ |
||||||
|
if ( (MIN_ALARM_DELAY + McuWakeUpTimeCal ) < ((timeout - HW_RTC_GetTimerElapsedTime( ) )) ) |
||||||
|
{ |
||||||
|
LowPower_Enable( e_LOW_POWER_RTC ); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
LowPower_Disable( e_LOW_POWER_RTC ); |
||||||
|
} |
||||||
|
|
||||||
|
if( LowPower_GetState() == 0 ) |
||||||
|
{ |
||||||
|
LowPower_Enable( e_LOW_POWER_RTC ); |
||||||
|
timeout = timeout - McuWakeUpTimeCal; |
||||||
|
} |
||||||
|
|
||||||
|
HW_RTC_StartWakeUpAlarm( timeout ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get the RTC timer elapsed time since the last Alarm was set |
||||||
|
* @param none |
||||||
|
* @retval RTC Elapsed time in ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetTimerElapsedTime( void ) |
||||||
|
{ |
||||||
|
RTC_TimeTypeDef RTC_TimeStruct; |
||||||
|
RTC_DateTypeDef RTC_DateStruct; |
||||||
|
|
||||||
|
TimerTime_t CalendarValue = HW_RTC_GetCalendarValue(&RTC_DateStruct, &RTC_TimeStruct ); |
||||||
|
|
||||||
|
return( ( uint32_t )( CalendarValue - RtcTimerContext.Rtc_Time )); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get the RTC timer value |
||||||
|
* @param none |
||||||
|
* @retval RTC Timer value in ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetTimerValue( void ) |
||||||
|
{ |
||||||
|
RTC_TimeTypeDef RTC_TimeStruct; |
||||||
|
RTC_DateTypeDef RTC_DateStruct; |
||||||
|
|
||||||
|
uint32_t CalendarValue = (uint32_t) HW_RTC_GetCalendarValue(&RTC_DateStruct, &RTC_TimeStruct ); |
||||||
|
|
||||||
|
return( CalendarValue ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Stop the Alarm |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_StopAlarm( void ) |
||||||
|
{ |
||||||
|
|
||||||
|
/* Clear RTC Alarm Flag */ |
||||||
|
__HAL_RTC_ALARM_CLEAR_FLAG( &RtcHandle, RTC_FLAG_ALRAF); |
||||||
|
|
||||||
|
/* Disable the Alarm A interrupt */ |
||||||
|
|
||||||
|
HAL_RTC_DeactivateAlarm(&RtcHandle, RTC_ALARM_A ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief RTC IRQ Handler on the RTC Alarm |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_IrqHandler ( void ) |
||||||
|
{ |
||||||
|
RTC_HandleTypeDef* hrtc=&RtcHandle; |
||||||
|
/* enable low power at irq*/ |
||||||
|
LowPower_Enable( e_LOW_POWER_RTC ); |
||||||
|
|
||||||
|
/* Get the AlarmA interrupt source enable status */ |
||||||
|
if(__HAL_RTC_ALARM_GET_IT_SOURCE(hrtc, RTC_IT_ALRA) != RESET) |
||||||
|
{ |
||||||
|
/* Get the pending status of the AlarmA Interrupt */ |
||||||
|
if(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAF) != RESET) |
||||||
|
{ |
||||||
|
/* Clear the AlarmA interrupt pending bit */ |
||||||
|
__HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF);
|
||||||
|
/* Clear the EXTI's line Flag for RTC Alarm */ |
||||||
|
__HAL_RTC_ALARM_EXTI_CLEAR_FLAG(); |
||||||
|
/* AlarmA callback */ |
||||||
|
HAL_RTC_AlarmAEventCallback(hrtc); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief a delay of delay ms by polling RTC |
||||||
|
* @param delay in ms |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_RTC_DelayMs( uint32_t delay ) |
||||||
|
{ |
||||||
|
TimerTime_t delayValue = 0; |
||||||
|
TimerTime_t timeout = 0; |
||||||
|
|
||||||
|
delayValue = HW_RTC_ms2Tick( delay ); |
||||||
|
|
||||||
|
/* Wait delay ms */ |
||||||
|
timeout = HW_RTC_GetTimerValue( ); |
||||||
|
while( ( ( HW_RTC_GetTimerValue( ) - timeout ) ) < delayValue ) |
||||||
|
{ |
||||||
|
__NOP( ); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief set Time Reference set also the RTC_DateStruct and RTC_TimeStruct |
||||||
|
* @param none |
||||||
|
* @retval Timer Value |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_SetTimerContext( void ) |
||||||
|
{ |
||||||
|
RtcTimerContext.Rtc_Time = HW_RTC_GetCalendarValue( &RtcTimerContext.RTC_Calndr_Date, &RtcTimerContext.RTC_Calndr_Time ); |
||||||
|
return ( uint32_t ) RtcTimerContext.Rtc_Time; |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get the RTC timer Reference |
||||||
|
* @param none |
||||||
|
* @retval Timer Value in Ticks |
||||||
|
*/ |
||||||
|
uint32_t HW_RTC_GetTimerContext( void ) |
||||||
|
{ |
||||||
|
return (uint32_t) RtcTimerContext.Rtc_Time; |
||||||
|
} |
||||||
|
/* Private functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief configure alarm at init |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
static void HW_RTC_SetAlarmConfig( void ) |
||||||
|
{ |
||||||
|
HAL_RTC_DeactivateAlarm(&RtcHandle, RTC_ALARM_A); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief start wake up alarm |
||||||
|
* @note alarm in RtcTimerContext.Rtc_Time + timeoutValue |
||||||
|
* @param timeoutValue in ticks |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
static void HW_RTC_StartWakeUpAlarm( uint32_t timeoutValue ) |
||||||
|
{ |
||||||
|
uint16_t rtcAlarmSubSeconds = 0; |
||||||
|
uint16_t rtcAlarmSeconds = 0; |
||||||
|
uint16_t rtcAlarmMinutes = 0; |
||||||
|
uint16_t rtcAlarmHours = 0; |
||||||
|
uint16_t rtcAlarmDays = 0; |
||||||
|
RTC_TimeTypeDef RTC_TimeStruct = RtcTimerContext.RTC_Calndr_Time; |
||||||
|
RTC_DateTypeDef RTC_DateStruct = RtcTimerContext.RTC_Calndr_Date; |
||||||
|
|
||||||
|
HW_RTC_StopAlarm( ); |
||||||
|
DBG_GPIO_SET(GPIOB, GPIO_PIN_13); |
||||||
|
|
||||||
|
/*reverse counter */ |
||||||
|
rtcAlarmSubSeconds = PREDIV_S - RTC_TimeStruct.SubSeconds; |
||||||
|
rtcAlarmSubSeconds += ( timeoutValue & PREDIV_S); |
||||||
|
/* convert timeout to seconds */ |
||||||
|
timeoutValue >>= N_PREDIV_S; /* convert timeout in seconds */ |
||||||
|
|
||||||
|
/*convert microsecs to RTC format and add to 'Now' */ |
||||||
|
rtcAlarmDays = RTC_DateStruct.Date; |
||||||
|
while (timeoutValue >= SECONDS_IN_1DAY) |
||||||
|
{ |
||||||
|
timeoutValue -= SECONDS_IN_1DAY; |
||||||
|
rtcAlarmDays++; |
||||||
|
} |
||||||
|
|
||||||
|
/* calc hours */ |
||||||
|
rtcAlarmHours = RTC_TimeStruct.Hours; |
||||||
|
while (timeoutValue >= SECONDS_IN_1HOUR) |
||||||
|
{ |
||||||
|
timeoutValue -= SECONDS_IN_1HOUR; |
||||||
|
rtcAlarmHours++; |
||||||
|
} |
||||||
|
|
||||||
|
/* calc minutes */ |
||||||
|
rtcAlarmMinutes = RTC_TimeStruct.Minutes; |
||||||
|
while (timeoutValue >= SECONDS_IN_1MINUTE) |
||||||
|
{ |
||||||
|
timeoutValue -= SECONDS_IN_1MINUTE; |
||||||
|
rtcAlarmMinutes++; |
||||||
|
} |
||||||
|
|
||||||
|
/* calc seconds */ |
||||||
|
rtcAlarmSeconds = RTC_TimeStruct.Seconds + timeoutValue; |
||||||
|
|
||||||
|
/***** correct for modulo********/ |
||||||
|
while (rtcAlarmSubSeconds >= (PREDIV_S+1)) |
||||||
|
{ |
||||||
|
rtcAlarmSubSeconds -= (PREDIV_S+1); |
||||||
|
rtcAlarmSeconds++; |
||||||
|
} |
||||||
|
|
||||||
|
while (rtcAlarmSeconds >= SECONDS_IN_1MINUTE) |
||||||
|
{
|
||||||
|
rtcAlarmSeconds -= SECONDS_IN_1MINUTE; |
||||||
|
rtcAlarmMinutes++; |
||||||
|
} |
||||||
|
|
||||||
|
while (rtcAlarmMinutes >= MINUTES_IN_1HOUR) |
||||||
|
{ |
||||||
|
rtcAlarmMinutes -= MINUTES_IN_1HOUR; |
||||||
|
rtcAlarmHours++; |
||||||
|
} |
||||||
|
|
||||||
|
while (rtcAlarmHours >= HOURS_IN_1DAY) |
||||||
|
{ |
||||||
|
rtcAlarmHours -= HOURS_IN_1DAY; |
||||||
|
rtcAlarmDays++; |
||||||
|
} |
||||||
|
|
||||||
|
if( RTC_DateStruct.Year % 4 == 0 )
|
||||||
|
{ |
||||||
|
if( rtcAlarmDays > DaysInMonthLeapYear[ RTC_DateStruct.Month - 1 ] )
|
||||||
|
{ |
||||||
|
rtcAlarmDays = rtcAlarmDays % DaysInMonthLeapYear[ RTC_DateStruct.Month - 1 ]; |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
if( rtcAlarmDays > DaysInMonth[ RTC_DateStruct.Month - 1 ] )
|
||||||
|
{
|
||||||
|
rtcAlarmDays = rtcAlarmDays % DaysInMonth[ RTC_DateStruct.Month - 1 ]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* Set RTC_AlarmStructure with calculated values*/ |
||||||
|
RTC_AlarmStructure.AlarmTime.SubSeconds = PREDIV_S-rtcAlarmSubSeconds; |
||||||
|
RTC_AlarmStructure.AlarmSubSecondMask = HW_RTC_ALARMSUBSECONDMASK;
|
||||||
|
RTC_AlarmStructure.AlarmTime.Seconds = rtcAlarmSeconds; |
||||||
|
RTC_AlarmStructure.AlarmTime.Minutes = rtcAlarmMinutes; |
||||||
|
RTC_AlarmStructure.AlarmTime.Hours = rtcAlarmHours; |
||||||
|
RTC_AlarmStructure.AlarmDateWeekDay = ( uint8_t )rtcAlarmDays; |
||||||
|
RTC_AlarmStructure.AlarmTime.TimeFormat = RTC_TimeStruct.TimeFormat; |
||||||
|
RTC_AlarmStructure.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
|
||||||
|
RTC_AlarmStructure.AlarmMask = RTC_ALARMMASK_NONE; |
||||||
|
RTC_AlarmStructure.Alarm = RTC_ALARM_A; |
||||||
|
RTC_AlarmStructure.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; |
||||||
|
RTC_AlarmStructure.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET; |
||||||
|
|
||||||
|
/* Set RTC_Alarm */ |
||||||
|
HAL_RTC_SetAlarm_IT( &RtcHandle, &RTC_AlarmStructure, RTC_FORMAT_BIN ); |
||||||
|
|
||||||
|
/* Debug Printf*/ |
||||||
|
DBG( HW_RTC_GetCalendarValue( &RTC_DateStruct, &RTC_TimeStruct ); ); |
||||||
|
DBG_PRINTF("it's %d:%d:%d:%d ", RTC_TimeStruct.Hours, RTC_TimeStruct.Minutes, RTC_TimeStruct.Seconds, ((PREDIV_S - RTC_TimeStruct.SubSeconds)*1000)>>N_PREDIV_S); |
||||||
|
DBG_PRINTF("WU@ %d:%d:%d:%d\n\r", rtcAlarmHours, rtcAlarmMinutes, rtcAlarmSeconds, (rtcAlarmSubSeconds*1000)>>N_PREDIV_S ); |
||||||
|
|
||||||
|
DBG_GPIO_RST(GPIOB, GPIO_PIN_13); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief get current time from calendar in ticks |
||||||
|
* @param pointer to RTC_DateStruct |
||||||
|
* @param pointer to RTC_TimeStruct |
||||||
|
* @retval time in ticks |
||||||
|
*/ |
||||||
|
static TimerTime_t HW_RTC_GetCalendarValue( RTC_DateTypeDef* RTC_DateStruct, RTC_TimeTypeDef* RTC_TimeStruct ) |
||||||
|
{ |
||||||
|
TimerTime_t calendarValue = 0; |
||||||
|
uint32_t first_read; |
||||||
|
uint32_t correction; |
||||||
|
|
||||||
|
/* Get Time and Date*/ |
||||||
|
HAL_RTC_GetTime( &RtcHandle, RTC_TimeStruct, RTC_FORMAT_BIN ); |
||||||
|
|
||||||
|
/* make sure it is correct due to asynchronus nature of RTC*/ |
||||||
|
do { |
||||||
|
first_read = RTC_TimeStruct->SubSeconds; |
||||||
|
HAL_RTC_GetDate( &RtcHandle, RTC_DateStruct, RTC_FORMAT_BIN ); |
||||||
|
HAL_RTC_GetTime( &RtcHandle, RTC_TimeStruct, RTC_FORMAT_BIN ); |
||||||
|
} while (first_read != RTC_TimeStruct->SubSeconds); |
||||||
|
|
||||||
|
/* calculte amount of elapsed days since 01/01/2000 */ |
||||||
|
calendarValue= DIVC( (DAYS_IN_YEAR*3 + DAYS_IN_LEAP_YEAR)* RTC_DateStruct->Year , 4); |
||||||
|
|
||||||
|
correction = ( (RTC_DateStruct->Year % 4) == 0 ) ? DAYS_IN_MONTH_CORRECTION_LEAP : DAYS_IN_MONTH_CORRECTION_NORM ; |
||||||
|
|
||||||
|
calendarValue +=( DIVC( (RTC_DateStruct->Month-1)*(30+31) ,2 ) - (((correction>> ((RTC_DateStruct->Month-1)*2) )&0x3))); |
||||||
|
|
||||||
|
calendarValue += (RTC_DateStruct->Date -1); |
||||||
|
|
||||||
|
/* convert from days to seconds */ |
||||||
|
calendarValue *= SECONDS_IN_1DAY;
|
||||||
|
|
||||||
|
calendarValue += ( ( uint32_t )RTC_TimeStruct->Seconds +
|
||||||
|
( ( uint32_t )RTC_TimeStruct->Minutes * SECONDS_IN_1MINUTE ) + |
||||||
|
( ( uint32_t )RTC_TimeStruct->Hours * SECONDS_IN_1HOUR ) ) ; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
calendarValue = (calendarValue<<N_PREDIV_S) + ( PREDIV_S - RTC_TimeStruct->SubSeconds); |
||||||
|
|
||||||
|
return( calendarValue ); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
|
@ -0,0 +1,223 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Bleeper board SPI driver implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/*******************************************************************************
|
||||||
|
* @file hw_spi.c |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief manages the SPI interface |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "hw.h" |
||||||
|
#include "utilities.h" |
||||||
|
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/ |
||||||
|
/* Private define ------------------------------------------------------------*/ |
||||||
|
/* Private macro -------------------------------------------------------------*/ |
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
static SPI_HandleTypeDef hspi; |
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Calculates Spi Divisor based on Spi Frequency and Mcu Frequency |
||||||
|
* |
||||||
|
* @param [IN] Spi Frequency |
||||||
|
* @retval Spi divisor |
||||||
|
*/ |
||||||
|
static uint32_t SpiFrequency( uint32_t hz ); |
||||||
|
|
||||||
|
/* Exported functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Initializes the SPI object and MCU peripheral |
||||||
|
* |
||||||
|
* @param [IN] none |
||||||
|
*/ |
||||||
|
void HW_SPI_Init( void ) |
||||||
|
{ |
||||||
|
|
||||||
|
/*##-1- Configure the SPI peripheral */ |
||||||
|
/* Set the SPI parameters */ |
||||||
|
|
||||||
|
hspi.Instance = SPI1; |
||||||
|
|
||||||
|
hspi.Init.BaudRatePrescaler = SpiFrequency( 10000000 ); |
||||||
|
hspi.Init.Direction = SPI_DIRECTION_2LINES; |
||||||
|
hspi.Init.Mode = SPI_MODE_MASTER; |
||||||
|
hspi.Init.CLKPolarity = SPI_POLARITY_LOW; |
||||||
|
hspi.Init.CLKPhase = SPI_PHASE_1EDGE; |
||||||
|
hspi.Init.DataSize = SPI_DATASIZE_8BIT; |
||||||
|
hspi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||||
|
hspi.Init.FirstBit = SPI_FIRSTBIT_MSB; |
||||||
|
hspi.Init.NSS = SPI_NSS_SOFT; |
||||||
|
hspi.Init.TIMode = SPI_TIMODE_DISABLE; |
||||||
|
|
||||||
|
|
||||||
|
SPI_CLK_ENABLE();
|
||||||
|
|
||||||
|
|
||||||
|
if(HAL_SPI_Init( &hspi) != HAL_OK) |
||||||
|
{ |
||||||
|
/* Initialization Error */ |
||||||
|
Error_Handler(); |
||||||
|
} |
||||||
|
|
||||||
|
/*##-2- Configure the SPI GPIOs */ |
||||||
|
HW_SPI_IoInit( ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief De-initializes the SPI object and MCU peripheral |
||||||
|
* |
||||||
|
* @param [IN] none |
||||||
|
*/ |
||||||
|
void HW_SPI_DeInit( void ) |
||||||
|
{ |
||||||
|
|
||||||
|
HAL_SPI_DeInit( &hspi); |
||||||
|
|
||||||
|
/*##-1- Reset peripherals ####*/ |
||||||
|
__HAL_RCC_SPI1_FORCE_RESET(); |
||||||
|
__HAL_RCC_SPI1_RELEASE_RESET(); |
||||||
|
/*##-2- Configure the SPI GPIOs */ |
||||||
|
HW_SPI_IoDeInit( ); |
||||||
|
} |
||||||
|
|
||||||
|
void HW_SPI_IoInit( void ) |
||||||
|
{ |
||||||
|
GPIO_InitTypeDef initStruct={0}; |
||||||
|
|
||||||
|
|
||||||
|
initStruct.Mode =GPIO_MODE_AF_PP; |
||||||
|
initStruct.Pull = GPIO_PULLDOWN; |
||||||
|
initStruct.Speed = GPIO_SPEED_HIGH; |
||||||
|
initStruct.Alternate= SPI1_AF ; |
||||||
|
|
||||||
|
HW_GPIO_Init( RADIO_SCLK_PORT, RADIO_SCLK_PIN, &initStruct); |
||||||
|
HW_GPIO_Init( RADIO_MISO_PORT, RADIO_MISO_PIN, &initStruct); |
||||||
|
HW_GPIO_Init( RADIO_MOSI_PORT, RADIO_MOSI_PIN, &initStruct); |
||||||
|
|
||||||
|
initStruct.Mode = GPIO_MODE_OUTPUT_PP; |
||||||
|
initStruct.Pull = GPIO_PULLUP; |
||||||
|
|
||||||
|
HW_GPIO_Init( RADIO_NSS_PORT, RADIO_NSS_PIN, &initStruct ); |
||||||
|
|
||||||
|
HW_GPIO_Write ( RADIO_NSS_PORT, RADIO_NSS_PIN, 1 ); |
||||||
|
} |
||||||
|
|
||||||
|
void HW_SPI_IoDeInit( void ) |
||||||
|
{ |
||||||
|
GPIO_InitTypeDef initStruct={0}; |
||||||
|
|
||||||
|
initStruct.Mode =GPIO_MODE_OUTPUT_PP; |
||||||
|
|
||||||
|
initStruct.Pull =GPIO_PULLDOWN ; |
||||||
|
HW_GPIO_Init ( RADIO_MOSI_PORT, RADIO_MOSI_PIN, &initStruct );
|
||||||
|
HW_GPIO_Write( RADIO_MOSI_PORT, RADIO_MOSI_PIN, 0 ); |
||||||
|
|
||||||
|
initStruct.Pull =GPIO_PULLDOWN;
|
||||||
|
HW_GPIO_Init ( RADIO_MISO_PORT, RADIO_MISO_PIN, &initStruct );
|
||||||
|
HW_GPIO_Write( RADIO_MISO_PORT, RADIO_MISO_PIN, 0 ); |
||||||
|
|
||||||
|
initStruct.Pull =GPIO_PULLDOWN ;
|
||||||
|
HW_GPIO_Init ( RADIO_SCLK_PORT, RADIO_SCLK_PIN, &initStruct );
|
||||||
|
HW_GPIO_Write( RADIO_SCLK_PORT, RADIO_SCLK_PIN, 0 ); |
||||||
|
|
||||||
|
initStruct.Pull = GPIO_PULLUP; |
||||||
|
HW_GPIO_Init ( RADIO_NSS_PORT, RADIO_NSS_PIN , &initStruct );
|
||||||
|
HW_GPIO_Write( RADIO_NSS_PORT, RADIO_NSS_PIN , 1 ); |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Sends outData and receives inData |
||||||
|
* |
||||||
|
* @param [IN] outData Byte to be sent |
||||||
|
* @retval inData Received byte. |
||||||
|
*/ |
||||||
|
uint16_t HW_SPI_InOut( uint16_t txData ) |
||||||
|
{ |
||||||
|
uint16_t rxData ; |
||||||
|
|
||||||
|
HAL_SPI_TransmitReceive( &hspi, ( uint8_t * ) &txData, ( uint8_t* ) &rxData, 1, HAL_MAX_DELAY);
|
||||||
|
|
||||||
|
return rxData; |
||||||
|
} |
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
static uint32_t SpiFrequency( uint32_t hz ) |
||||||
|
{ |
||||||
|
uint32_t divisor = 0; |
||||||
|
uint32_t SysClkTmp = SystemCoreClock; |
||||||
|
uint32_t baudRate; |
||||||
|
|
||||||
|
while( SysClkTmp > hz) |
||||||
|
{ |
||||||
|
divisor++; |
||||||
|
SysClkTmp= ( SysClkTmp >> 1); |
||||||
|
|
||||||
|
if (divisor >= 7) |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
baudRate =((( divisor & 0x4 ) == 0 )? 0x0 : SPI_CR1_BR_2 )|
|
||||||
|
((( divisor & 0x2 ) == 0 )? 0x0 : SPI_CR1_BR_1 )|
|
||||||
|
((( divisor & 0x1 ) == 0 )? 0x0 : SPI_CR1_BR_0 ); |
||||||
|
|
||||||
|
return baudRate; |
||||||
|
} |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
|
@ -1,231 +1,228 @@ |
|||||||
/**
|
/*
|
||||||
****************************************************************************** |
/ _____) _ | | |
||||||
* File Name : main.c |
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
* Description : Main program body |
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Generic lora driver implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis, Gregory Cristian and Wael Guibene |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
|
* @file main.c |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief this is the main! |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
** This notice applies to any and all portions of this file |
* @attention |
||||||
* that are not between comment pairs USER CODE BEGIN and |
* |
||||||
* USER CODE END. Other portions of this file, whether
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
* inserted by the user or by software development tools |
* All rights reserved.</center></h2> |
||||||
* are owned by their respective copyright owners. |
|
||||||
* |
* |
||||||
* COPYRIGHT(c) 2017 STMicroelectronics |
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
* |
* |
||||||
* Redistribution and use in source and binary forms, with or without modification, |
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
* are permitted provided that the following conditions are met: |
* this list of conditions and the following disclaimer. |
||||||
* 1. Redistributions of source code must retain the above copyright notice, |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
* this list of conditions and the following disclaimer. |
* this list of conditions and the following disclaimer in the documentation |
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
* and/or other materials provided with the distribution. |
||||||
* this list of conditions and the following disclaimer in the documentation |
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
* and/or other materials provided with the distribution. |
* contributors to this software may be used to endorse or promote products
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
* derived from this software without specific written permission. |
||||||
* may be used to endorse or promote products derived from this software |
* 4. This software, including modifications and/or derivative works of this
|
||||||
* without specific prior written permission. |
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
* |
* |
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
* |
* |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
*/ |
*/ |
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/ |
/* Includes ------------------------------------------------------------------*/ |
||||||
#include "main.h" |
#include "hw.h" |
||||||
#include "stm32l0xx_hal.h" |
#include "low_power.h" |
||||||
#include "i2c.h" |
#include "lora.h" |
||||||
#include "rtc.h" |
//#include "bsp.h"
|
||||||
#include "spi.h" |
#include "timeServer.h" |
||||||
#include "usart.h" |
#include "vcom.h" |
||||||
#include "gpio.h" |
|
||||||
|
/* Private typedef -----------------------------------------------------------*/ |
||||||
/* USER CODE BEGIN Includes */ |
/* Private define ------------------------------------------------------------*/ |
||||||
|
/*!
|
||||||
/* USER CODE END Includes */ |
* CAYENNE_LPP is myDevices Application server. |
||||||
|
*/ |
||||||
/* Private variables ---------------------------------------------------------*/ |
//#define CAYENNE_LPP
|
||||||
|
#define LPP_DATATYPE_DIGITAL_INPUT 0x0 |
||||||
/* USER CODE BEGIN PV */ |
#define LPP_DATATYPE_DIGITAL_OUTPUT 0x1 |
||||||
/* Private variables ---------------------------------------------------------*/ |
#define LPP_DATATYPE_HUMIDITY 0x68 |
||||||
|
#define LPP_DATATYPE_TEMPERATURE 0x67 |
||||||
/* USER CODE END PV */ |
#define LPP_DATATYPE_BAROMETER 0x73 |
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/ |
#define LPP_APP_PORT 99 |
||||||
void SystemClock_Config(void); |
|
||||||
|
/*!
|
||||||
/* USER CODE BEGIN PFP */ |
* Defines the application data transmission duty cycle. 5s, value in [ms]. |
||||||
|
*/ |
||||||
|
#define APP_TX_DUTYCYCLE 10000 |
||||||
|
/*!
|
||||||
|
* LoRaWAN Adaptive Data Rate |
||||||
|
* @note Please note that when ADR is enabled the end-device should be static |
||||||
|
*/ |
||||||
|
#define LORAWAN_ADR_ON 1 |
||||||
|
/*!
|
||||||
|
* LoRaWAN confirmed messages |
||||||
|
*/ |
||||||
|
#define LORAWAN_CONFIRMED_MSG DISABLE |
||||||
|
/*!
|
||||||
|
* LoRaWAN application port |
||||||
|
* @note do not use 224. It is reserved for certification |
||||||
|
*/ |
||||||
|
#define LORAWAN_APP_PORT 2 |
||||||
|
/*!
|
||||||
|
* Number of trials for the join request. |
||||||
|
*/ |
||||||
|
#define JOINREQ_NBTRIALS 3 |
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/ |
||||||
/* Private function prototypes -----------------------------------------------*/ |
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
|
||||||
/* USER CODE END PFP */ |
/* call back when LoRa will transmit a frame*/ |
||||||
|
static void LoraTxData(lora_AppData_t *AppData, FunctionalState *IsTxConfirmed); |
||||||
|
|
||||||
/* USER CODE BEGIN 0 */ |
/* call back when LoRa has received a frame*/ |
||||||
|
static void LoraRxData(lora_AppData_t *AppData); |
||||||
|
|
||||||
/* USER CODE END 0 */ |
/* Private variables ---------------------------------------------------------*/ |
||||||
|
/* load call backs*/ |
||||||
|
static LoRaMainCallback_t LoRaMainCallbacks = {HW_GetBatteryLevel, |
||||||
|
HW_GetUniqueId, |
||||||
|
HW_GetRandomSeed, |
||||||
|
LoraTxData, |
||||||
|
LoraRxData}; |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Specifies the state of the application LED |
||||||
|
*/ |
||||||
|
static uint8_t AppLedStateOn = RESET; |
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_B_L072Z_LRWAN1 |
||||||
|
/*!
|
||||||
|
* Timer to handle the application Tx Led to toggle |
||||||
|
*/ |
||||||
|
static TimerEvent_t TxLedTimer; |
||||||
|
static void OnTimerLedEvent( void ); |
||||||
|
#endif |
||||||
|
/* !
|
||||||
|
*Initialises the Lora Parameters |
||||||
|
*/ |
||||||
|
static LoRaParam_t LoRaParamInit = {TX_ON_TIMER, |
||||||
|
APP_TX_DUTYCYCLE, |
||||||
|
CLASS_A, |
||||||
|
LORAWAN_ADR_ON, |
||||||
|
DR_0, |
||||||
|
LORAWAN_PUBLIC_NETWORK, |
||||||
|
JOINREQ_NBTRIALS}; |
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main program |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
int main(void) |
int main(void) |
||||||
{ |
{ |
||||||
|
/* STM32 HAL library initialization*/ |
||||||
|
HAL_Init(); |
||||||
|
|
||||||
/* USER CODE BEGIN 1 */ |
/* Configure the system clock*/ |
||||||
|
SystemClock_Config(); |
||||||
/* USER CODE END 1 */ |
|
||||||
|
|
||||||
/* MCU Configuration----------------------------------------------------------*/ |
|
||||||
|
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
/* Configure the debug mode*/ |
||||||
HAL_Init(); |
DBG_Init(); |
||||||
|
|
||||||
/* USER CODE BEGIN Init */ |
/* Configure the hardware*/ |
||||||
|
HW_Init(); |
||||||
|
|
||||||
/* USER CODE END Init */ |
/* USER CODE BEGIN 1 */ |
||||||
|
/* USER CODE END 1 */ |
||||||
|
|
||||||
/* Configure the system clock */ |
/* Configure the Lora Stack*/ |
||||||
SystemClock_Config(); |
lora_Init(&LoRaMainCallbacks, &LoRaParamInit); |
||||||
|
|
||||||
/* USER CODE BEGIN SysInit */ |
PRINTF("starting!!!\n\r"); |
||||||
|
|
||||||
/* USER CODE END SysInit */ |
/* main loop*/ |
||||||
|
while (1) { |
||||||
|
/* run the LoRa class A state machine*/ |
||||||
|
lora_fsm(); |
||||||
|
|
||||||
/* Initialize all configured peripherals */ |
DISABLE_IRQ(); |
||||||
MX_GPIO_Init(); |
/* if an interrupt has occurred after DISABLE_IRQ, it is kept pending
|
||||||
MX_I2C1_Init(); |
* and cortex will not enter low power anyway */ |
||||||
MX_SPI1_Init(); |
if (lora_getDeviceState() == DEVICE_STATE_SLEEP) { |
||||||
MX_USART1_UART_Init(); |
#ifndef LOW_POWER_DISABLE |
||||||
MX_USART2_UART_Init(); |
LowPower_Handler(); |
||||||
MX_RTC_Init(); |
#endif |
||||||
|
} |
||||||
/* USER CODE BEGIN 2 */ |
ENABLE_IRQ(); |
||||||
|
|
||||||
/* USER CODE END 2 */ |
|
||||||
|
|
||||||
/* Infinite loop */ |
|
||||||
/* USER CODE BEGIN WHILE */ |
|
||||||
while (1) |
|
||||||
{ |
|
||||||
/* USER CODE END WHILE */ |
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */ |
|
||||||
|
|
||||||
} |
|
||||||
/* USER CODE END 3 */ |
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 2 */ |
||||||
|
/* USER CODE END 2 */ |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
/** System Clock Configuration
|
static void LoraTxData(lora_AppData_t *AppData, FunctionalState *IsTxConfirmed) |
||||||
*/ |
|
||||||
void SystemClock_Config(void) |
|
||||||
{ |
{ |
||||||
|
/* USER CODE BEGIN 3 */ |
||||||
|
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct; |
AppData->Port = LORAWAN_APP_PORT; |
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct; |
|
||||||
RCC_PeriphCLKInitTypeDef PeriphClkInit; |
|
||||||
|
|
||||||
/**Configure the main internal regulator output voltage
|
|
||||||
*/ |
|
||||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
|
||||||
|
|
||||||
/**Initializes the CPU, AHB and APB busses clocks
|
|
||||||
*/ |
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI; |
|
||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
|
||||||
RCC_OscInitStruct.HSICalibrationValue = 16; |
|
||||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON; |
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
|
||||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_3; |
|
||||||
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2; |
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
|
||||||
{ |
|
||||||
_Error_Handler(__FILE__, __LINE__); |
|
||||||
} |
|
||||||
|
|
||||||
/**Initializes the CPU, AHB and APB busses clocks
|
|
||||||
*/ |
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
|
||||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
|
||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) |
|
||||||
{ |
|
||||||
_Error_Handler(__FILE__, __LINE__); |
|
||||||
} |
|
||||||
|
|
||||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART2 |
|
||||||
|RCC_PERIPHCLK_I2C1|RCC_PERIPHCLK_RTC; |
|
||||||
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; |
|
||||||
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1; |
|
||||||
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; |
|
||||||
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; |
|
||||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) |
|
||||||
{ |
|
||||||
_Error_Handler(__FILE__, __LINE__); |
|
||||||
} |
|
||||||
|
|
||||||
/**Configure the Systick interrupt time
|
|
||||||
*/ |
|
||||||
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); |
|
||||||
|
|
||||||
/**Configure the Systick
|
|
||||||
*/ |
|
||||||
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); |
|
||||||
|
|
||||||
/* SysTick_IRQn interrupt configuration */ |
|
||||||
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); |
|
||||||
} |
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */ |
//TODO
|
||||||
|
|
||||||
/* USER CODE END 4 */ |
*IsTxConfirmed = LORAWAN_CONFIRMED_MSG; |
||||||
|
|
||||||
/**
|
AppData->BuffSize = 0; |
||||||
* @brief This function is executed in case of error occurrence. |
|
||||||
* @param None |
|
||||||
* @retval None |
|
||||||
*/ |
|
||||||
void _Error_Handler(char * file, int line) |
|
||||||
{ |
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */ |
|
||||||
/* User can add his own implementation to report the HAL error return state */ |
|
||||||
while(1)
|
|
||||||
{ |
|
||||||
} |
|
||||||
/* USER CODE END Error_Handler_Debug */
|
|
||||||
} |
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT |
/* USER CODE END 3 */ |
||||||
|
} |
||||||
|
|
||||||
/**
|
static void LoraRxData(lora_AppData_t *AppData) |
||||||
* @brief Reports the name of the source file and the source line number |
|
||||||
* where the assert_param error has occurred. |
|
||||||
* @param file: pointer to the source file name |
|
||||||
* @param line: assert_param error line source number |
|
||||||
* @retval None |
|
||||||
*/ |
|
||||||
void assert_failed(uint8_t* file, uint32_t line) |
|
||||||
{ |
{ |
||||||
/* USER CODE BEGIN 6 */ |
/* USER CODE BEGIN 4 */ |
||||||
/* User can add his own implementation to report the file name and line number,
|
switch (AppData->Port) { |
||||||
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
case LORAWAN_APP_PORT: |
||||||
/* USER CODE END 6 */ |
|
||||||
|
break; |
||||||
|
case LPP_APP_PORT: { |
||||||
|
|
||||||
|
break; |
||||||
|
} |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
/* USER CODE END 4 */ |
||||||
} |
} |
||||||
|
|
||||||
#endif |
|
||||||
|
|
||||||
/**
|
|
||||||
* @} |
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @} |
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
@ -1,83 +1,224 @@ |
|||||||
/**
|
|
||||||
****************************************************************************** |
/******************************************************************************
|
||||||
* File Name : stm32l0xx_hal_msp.c |
* @file stm32l0xx_hal_msp.c |
||||||
* Description : This file provides code for the MSP Initialization
|
* @author MCD Application Team |
||||||
* and de-Initialization codes. |
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief msp file for HAL |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
** This notice applies to any and all portions of this file |
* @attention |
||||||
* that are not between comment pairs USER CODE BEGIN and |
|
||||||
* USER CODE END. Other portions of this file, whether
|
|
||||||
* inserted by the user or by software development tools |
|
||||||
* are owned by their respective copyright owners. |
|
||||||
* |
* |
||||||
* COPYRIGHT(c) 2017 STMicroelectronics |
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
* |
* |
||||||
* Redistribution and use in source and binary forms, with or without modification, |
* Redistribution and use in source and binary forms, with or without
|
||||||
* are permitted provided that the following conditions are met: |
* modification, are permitted, provided that the following conditions are met: |
||||||
* 1. Redistributions of source code must retain the above copyright notice, |
|
||||||
* this list of conditions and the following disclaimer. |
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
||||||
* this list of conditions and the following disclaimer in the documentation |
|
||||||
* and/or other materials provided with the distribution. |
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
|
||||||
* may be used to endorse or promote products derived from this software |
|
||||||
* without specific prior written permission. |
|
||||||
* |
* |
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* this list of conditions and the following disclaimer. |
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
* this list of conditions and the following disclaimer in the documentation |
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* and/or other materials provided with the distribution. |
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
* contributors to this software may be used to endorse or promote products
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
* derived from this software without specific written permission. |
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* 4. This software, including modifications and/or derivative works of this
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
* |
* |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
*/ |
*/ |
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/ |
/* Includes ------------------------------------------------------------------*/ |
||||||
#include "stm32l0xx_hal.h" |
#include "hw.h" |
||||||
|
#include "low_power.h" |
||||||
|
#include "delay.h" |
||||||
|
#include "timeServer.h" |
||||||
|
/* when fast wake up is enabled, the mcu wakes up in ~20us * and
|
||||||
|
* does not wait for the VREFINT to be settled. THis is ok for
|
||||||
|
* most of the case except when adc must be used in this case before
|
||||||
|
*starting the adc, you must make sure VREFINT is settled*/ |
||||||
|
#define ENABLE_FAST_WAKEUP |
||||||
|
|
||||||
extern void _Error_Handler(char *, int); |
/* Private typedef -----------------------------------------------------------*/ |
||||||
/* USER CODE BEGIN 0 */ |
/* Private define ------------------------------------------------------------*/ |
||||||
|
/* Private macro -------------------------------------------------------------*/ |
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
/* Private functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
/* USER CODE END 0 */ |
|
||||||
/**
|
/**
|
||||||
* Initializes the Global MSP. |
* @brief This function configures the source of the time base. |
||||||
|
* @brief don't enable systick |
||||||
|
* @param TickPriority: Tick interrupt priority. |
||||||
|
* @retval HAL status |
||||||
*/ |
*/ |
||||||
void HAL_MspInit(void) |
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) |
||||||
{ |
{ |
||||||
/* USER CODE BEGIN MspInit 0 */ |
/* Return function status */ |
||||||
|
return HAL_OK; |
||||||
|
} |
||||||
|
|
||||||
/* USER CODE END MspInit 0 */ |
/**
|
||||||
|
* @brief This function provides delay (in ms) |
||||||
|
* @param Delay: specifies the delay time length, in milliseconds. |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HAL_Delay(__IO uint32_t Delay) |
||||||
|
{ |
||||||
|
DelayMs( Delay ); /* based on RTC */ |
||||||
|
} |
||||||
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE(); |
/**
|
||||||
|
* @brief Initializes the MSP. |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HAL_MspInit(void) |
||||||
|
{ |
||||||
__HAL_RCC_PWR_CLK_ENABLE(); |
__HAL_RCC_PWR_CLK_ENABLE(); |
||||||
|
|
||||||
/* System interrupt init*/ |
/* Disable the Power Voltage Detector */ |
||||||
/* SVC_IRQn interrupt configuration */ |
HAL_PWR_DisablePVD( );
|
||||||
HAL_NVIC_SetPriority(SVC_IRQn, 0, 0); |
|
||||||
/* PendSV_IRQn interrupt configuration */ |
|
||||||
HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); |
|
||||||
/* SysTick_IRQn interrupt configuration */ |
|
||||||
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); |
|
||||||
|
|
||||||
/* USER CODE BEGIN MspInit 1 */ |
/* Enables the Ultra Low Power mode */ |
||||||
|
HAL_PWREx_EnableUltraLowPower( ); |
||||||
|
|
||||||
/* USER CODE END MspInit 1 */ |
__HAL_FLASH_SLEEP_POWERDOWN_ENABLE(); |
||||||
|
|
||||||
|
/*In debug mode, e.g. when DBGMCU is activated, Arm core has always clocks
|
||||||
|
* And will not wait that the FLACH is ready to be read. It can miss in this
|
||||||
|
* case the first instruction. To overcome this issue, the flash remain clcoked during sleep mode |
||||||
|
*/ |
||||||
|
DBG( __HAL_FLASH_SLEEP_POWERDOWN_DISABLE(); ); |
||||||
|
|
||||||
|
#ifdef ENABLE_FAST_WAKEUP |
||||||
|
/*Enable fast wakeUp*/
|
||||||
|
HAL_PWREx_EnableFastWakeUp( ); |
||||||
|
#else |
||||||
|
HAL_PWREx_DisableFastWakeUp( ); |
||||||
|
#endif |
||||||
} |
} |
||||||
|
|
||||||
/* USER CODE BEGIN 1 */ |
/**
|
||||||
|
* @brief RTC MSP Initialization |
||||||
|
* This function configures the hardware resources used in this example: |
||||||
|
* - Peripheral's clock enable |
||||||
|
* @param hrtc: RTC handle pointer |
||||||
|
* @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
|
||||||
|
* the RTC clock source; in this case the Backup domain will be reset in
|
||||||
|
* order to modify the RTC Clock source, as consequence RTC registers (including
|
||||||
|
* the backup registers) and RCC_CSR register are set to their reset values.
|
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) |
||||||
|
{ |
||||||
|
RCC_OscInitTypeDef RCC_OscInitStruct; |
||||||
|
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; |
||||||
|
|
||||||
/* USER CODE END 1 */ |
/*##-1- Configue the RTC clock soucre ######################################*/ |
||||||
|
/* -a- Enable LSE Oscillator */ |
||||||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; |
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; |
||||||
|
RCC_OscInitStruct.LSEState = RCC_LSE_ON; |
||||||
|
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
||||||
|
{ |
||||||
|
Error_Handler(); |
||||||
|
} |
||||||
|
|
||||||
|
/* -b- Select LSI as RTC clock source */ |
||||||
|
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; |
||||||
|
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; |
||||||
|
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) |
||||||
|
{
|
||||||
|
Error_Handler(); |
||||||
|
} |
||||||
|
|
||||||
|
/*##-2- Enable the RTC peripheral Clock ####################################*/ |
||||||
|
/* Enable RTC Clock */ |
||||||
|
__HAL_RCC_RTC_ENABLE(); |
||||||
|
|
||||||
|
/*##-3- Configure the NVIC for RTC Alarm ###################################*/ |
||||||
|
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0x0, 0); |
||||||
|
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn); |
||||||
|
} |
||||||
|
|
||||||
/**
|
/**
|
||||||
* @} |
* @brief RTC MSP De-Initialization
|
||||||
|
* This function freeze the hardware resources used in this example: |
||||||
|
* - Disable the Peripheral's clock |
||||||
|
* @param hrtc: RTC handle pointer |
||||||
|
* @retval None |
||||||
*/ |
*/ |
||||||
|
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc) |
||||||
|
{ |
||||||
|
/* Reset peripherals */ |
||||||
|
__HAL_RCC_RTC_DISABLE(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @} |
* @brief Alarm A callback. |
||||||
|
* @param hrtc: RTC handle |
||||||
|
* @retval None |
||||||
*/ |
*/ |
||||||
|
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc) |
||||||
|
{ |
||||||
|
TimerIrqHandler( ); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EXTI line detection callbacks. |
||||||
|
* @param GPIO_Pin: Specifies the pins connected to the EXTI line. |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) |
||||||
|
{ |
||||||
|
HW_GPIO_IrqHandler( GPIO_Pin ); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets IRQ number as a function of the GPIO_Pin. |
||||||
|
* @param GPIO_Pin: Specifies the pins connected to the EXTI line. |
||||||
|
* @retval IRQ number |
||||||
|
*/ |
||||||
|
IRQn_Type MSP_GetIRQn( uint16_t GPIO_Pin) |
||||||
|
{ |
||||||
|
switch( GPIO_Pin ) |
||||||
|
{ |
||||||
|
case GPIO_PIN_0:
|
||||||
|
case GPIO_PIN_1: return EXTI0_1_IRQn; |
||||||
|
case GPIO_PIN_2:
|
||||||
|
case GPIO_PIN_3: return EXTI2_3_IRQn; |
||||||
|
case GPIO_PIN_4:
|
||||||
|
case GPIO_PIN_5:
|
||||||
|
case GPIO_PIN_6: |
||||||
|
case GPIO_PIN_7: |
||||||
|
case GPIO_PIN_8: |
||||||
|
case GPIO_PIN_9:
|
||||||
|
case GPIO_PIN_10: |
||||||
|
case GPIO_PIN_11: |
||||||
|
case GPIO_PIN_12: |
||||||
|
case GPIO_PIN_13: |
||||||
|
case GPIO_PIN_14: |
||||||
|
case GPIO_PIN_15:
|
||||||
|
default: return EXTI4_15_IRQn; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
@ -0,0 +1,335 @@ |
|||||||
|
/*
|
||||||
|
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Target board general functions implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/*******************************************************************************
|
||||||
|
* @file stm32l0xx_hw.c |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief system hardware driver |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
#include "hw.h" |
||||||
|
#include "radio.h" |
||||||
|
#include "debug.h" |
||||||
|
#include "vcom.h" |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Unique Devices IDs register set ( STM32L0xxx ) |
||||||
|
*/ |
||||||
|
#define ID1 ( 0x1FF80050 ) |
||||||
|
#define ID2 ( 0x1FF80054 ) |
||||||
|
#define ID3 ( 0x1FF80064 ) |
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ADC Vbat measurement constants |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Internal voltage reference, parameter VREFINT_CAL*/ |
||||||
|
#define VREFINT_CAL ((uint16_t*) ((uint32_t) 0x1FF80078)) |
||||||
|
#define LORAWAN_MAX_BAT 254 |
||||||
|
|
||||||
|
|
||||||
|
/* Internal temperature sensor: constants data used for indicative values in */ |
||||||
|
/* this example. Refer to device datasheet for min/typ/max values. */ |
||||||
|
|
||||||
|
/* Internal temperature sensor, parameter TS_CAL1: TS ADC raw data acquired at
|
||||||
|
*a temperature of 110 DegC (+-5 DegC), VDDA = 3.3 V (+-10 mV). */ |
||||||
|
#define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FF8007A)) |
||||||
|
|
||||||
|
/* Internal temperature sensor, parameter TS_CAL2: TS ADC raw data acquired at
|
||||||
|
*a temperature of 30 DegC (+-5 DegC), VDDA = 3.3 V (+-10 mV). */ |
||||||
|
#define TEMP110_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FF8007E)) |
||||||
|
|
||||||
|
/* Vdda value with which temperature sensor has been calibrated in production
|
||||||
|
(+-10 mV). */ |
||||||
|
#define VDDA_TEMP_CAL ((uint32_t) 3000) |
||||||
|
|
||||||
|
/*!
|
||||||
|
* Flag to indicate if the MCU is Initialized |
||||||
|
*/ |
||||||
|
static bool McuInitialized = false; |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function initializes the hardware |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HW_Init( void ) |
||||||
|
{ |
||||||
|
if( McuInitialized == false ) |
||||||
|
{ |
||||||
|
#if defined( USE_BOOTLOADER ) |
||||||
|
/* Set the Vector Table base location at 0x3000 */ |
||||||
|
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x3000 ); |
||||||
|
#endif |
||||||
|
|
||||||
|
HW_AdcInit( ); |
||||||
|
|
||||||
|
Radio.IoInit( ); |
||||||
|
|
||||||
|
HW_SPI_Init( ); |
||||||
|
|
||||||
|
HW_RTC_Init( ); |
||||||
|
|
||||||
|
vcom_Init( ); |
||||||
|
|
||||||
|
McuInitialized = true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function Deinitializes the hardware |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HW_DeInit( void ) |
||||||
|
{ |
||||||
|
HW_SPI_DeInit( ); |
||||||
|
|
||||||
|
Radio.IoDeInit( ); |
||||||
|
|
||||||
|
vcom_DeInit( ); |
||||||
|
|
||||||
|
McuInitialized = false; |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function Initializes the hardware Ios |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
static void HW_IoInit( void ) |
||||||
|
{ |
||||||
|
HW_SPI_IoInit( ); |
||||||
|
|
||||||
|
Radio.IoInit( ); |
||||||
|
|
||||||
|
vcom_IoInit( ); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function Deinitializes the hardware Ios |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
static void HW_IoDeInit( void ) |
||||||
|
{ |
||||||
|
HW_SPI_IoDeInit( ); |
||||||
|
|
||||||
|
Radio.IoDeInit( ); |
||||||
|
|
||||||
|
vcom_IoDeInit( ); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void HW_GpioInit(void) |
||||||
|
{ |
||||||
|
/* STM32L0 Gpios are all already configured in analog input at nReset*/ |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System Clock Configuration |
||||||
|
* The system Clock is configured as follow : |
||||||
|
* System Clock source = PLL (HSI) |
||||||
|
* SYSCLK(Hz) = 32000000 |
||||||
|
* HCLK(Hz) = 32000000 |
||||||
|
* AHB Prescaler = 1 |
||||||
|
* APB1 Prescaler = 1 |
||||||
|
* APB2 Prescaler = 1 |
||||||
|
* HSI Frequency(Hz) = 16000000 |
||||||
|
* PLLMUL = 6 |
||||||
|
* PLLDIV = 3 |
||||||
|
* Flash Latency(WS) = 1 |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
|
||||||
|
void SystemClock_Config( void ) |
||||||
|
{ |
||||||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
||||||
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
||||||
|
|
||||||
|
/* Enable HSE Oscillator and Activate PLL with HSE as source */ |
||||||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; |
||||||
|
RCC_OscInitStruct.HSEState = RCC_HSE_OFF; |
||||||
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
||||||
|
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; |
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
||||||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
||||||
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_6; |
||||||
|
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_3; |
||||||
|
|
||||||
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
||||||
|
{ |
||||||
|
Error_Handler(); |
||||||
|
} |
||||||
|
|
||||||
|
/* Set Voltage scale1 as MCU will run at 32MHz */ |
||||||
|
__HAL_RCC_PWR_CLK_ENABLE(); |
||||||
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
||||||
|
|
||||||
|
/* Poll VOSF bit of in PWR_CSR. Wait until it is reset to 0 */ |
||||||
|
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {}; |
||||||
|
|
||||||
|
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
|
||||||
|
clocks dividers */ |
||||||
|
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); |
||||||
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
||||||
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
||||||
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
||||||
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
||||||
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) |
||||||
|
{ |
||||||
|
Error_Handler(); |
||||||
|
} |
||||||
|
} |
||||||
|
/**
|
||||||
|
* @brief This function return a random seed |
||||||
|
* @note based on the device unique ID |
||||||
|
* @param None |
||||||
|
* @retval see |
||||||
|
*/ |
||||||
|
uint32_t HW_GetRandomSeed( void ) |
||||||
|
{ |
||||||
|
return ( ( *( uint32_t* )ID1 ) ^ ( *( uint32_t* )ID2 ) ^ ( *( uint32_t* )ID3 ) ); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function return a unique ID |
||||||
|
* @param unique ID |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_GetUniqueId( uint8_t *id ) |
||||||
|
{ |
||||||
|
id[7] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 24; |
||||||
|
id[6] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 16; |
||||||
|
id[5] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 8; |
||||||
|
id[4] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ); |
||||||
|
id[3] = ( ( *( uint32_t* )ID2 ) ) >> 24; |
||||||
|
id[2] = ( ( *( uint32_t* )ID2 ) ) >> 16; |
||||||
|
id[1] = ( ( *( uint32_t* )ID2 ) ) >> 8; |
||||||
|
id[0] = ( ( *( uint32_t* )ID2 ) ); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enters Low Power Stop Mode |
||||||
|
* @note ARM exists the function when waking up |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_EnterStopMode( void) |
||||||
|
{ |
||||||
|
BACKUP_PRIMASK(); |
||||||
|
|
||||||
|
DISABLE_IRQ( ); |
||||||
|
|
||||||
|
HW_IoDeInit( ); |
||||||
|
|
||||||
|
/*clear wake up flag*/ |
||||||
|
SET_BIT(PWR->CR, PWR_CR_CWUF); |
||||||
|
|
||||||
|
RESTORE_PRIMASK( ); |
||||||
|
|
||||||
|
/* Enter Stop Mode */ |
||||||
|
HAL_PWR_EnterSTOPMode ( PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI ); |
||||||
|
} |
||||||
|
/**
|
||||||
|
* @brief Exists Low Power Stop Mode |
||||||
|
* @note Enable the pll at 32MHz |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_ExitStopMode( void) |
||||||
|
{ |
||||||
|
/* Disable IRQ while the MCU is not running on HSI */ |
||||||
|
|
||||||
|
BACKUP_PRIMASK(); |
||||||
|
|
||||||
|
DISABLE_IRQ( ); |
||||||
|
|
||||||
|
/* After wake-up from STOP reconfigure the system clock */ |
||||||
|
/* Enable HSI */ |
||||||
|
__HAL_RCC_HSI_ENABLE(); |
||||||
|
|
||||||
|
/* Wait till HSI is ready */ |
||||||
|
while( __HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET ) {} |
||||||
|
|
||||||
|
/* Enable PLL */ |
||||||
|
__HAL_RCC_PLL_ENABLE(); |
||||||
|
/* Wait till PLL is ready */ |
||||||
|
while( __HAL_RCC_GET_FLAG( RCC_FLAG_PLLRDY ) == RESET ) {} |
||||||
|
|
||||||
|
/* Select PLL as system clock source */ |
||||||
|
__HAL_RCC_SYSCLK_CONFIG ( RCC_SYSCLKSOURCE_PLLCLK ); |
||||||
|
|
||||||
|
/* Wait till PLL is used as system clock source */
|
||||||
|
while( __HAL_RCC_GET_SYSCLK_SOURCE( ) != RCC_SYSCLKSOURCE_STATUS_PLLCLK ) {} |
||||||
|
|
||||||
|
/*initilizes the peripherals*/ |
||||||
|
HW_IoInit( ); |
||||||
|
|
||||||
|
RESTORE_PRIMASK( ); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enters Low Power Sleep Mode |
||||||
|
* @note ARM exits the function when waking up |
||||||
|
* @param none |
||||||
|
* @retval none |
||||||
|
*/ |
||||||
|
void HW_EnterSleepMode( void) |
||||||
|
{ |
||||||
|
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); |
||||||
|
} |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
|
@ -1,99 +1,257 @@ |
|||||||
/**
|
/*
|
||||||
****************************************************************************** |
/ _____) _ | | |
||||||
|
( (____ _____ ____ _| |_ _____ ____| |__ |
||||||
|
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||||
|
_____) ) ____| | | || |_| ____( (___| | | | |
||||||
|
(______/|_____)_|_|_| \__)_____)\____)_| |_| |
||||||
|
(C)2013 Semtech |
||||||
|
|
||||||
|
Description: Bleeper board GPIO driver implementation |
||||||
|
|
||||||
|
License: Revised BSD License, see LICENSE.TXT file include in the project |
||||||
|
|
||||||
|
Maintainer: Miguel Luis and Gregory Cristian |
||||||
|
*/ |
||||||
|
/******************************************************************************
|
||||||
* @file stm32l0xx_it.c |
* @file stm32l0xx_it.c |
||||||
* @brief Interrupt Service Routines. |
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief manages interupt |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
|
* @attention |
||||||
* |
* |
||||||
* COPYRIGHT(c) 2017 STMicroelectronics |
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
* |
* |
||||||
* Redistribution and use in source and binary forms, with or without modification, |
* Redistribution and use in source and binary forms, with or without
|
||||||
* are permitted provided that the following conditions are met: |
* modification, are permitted, provided that the following conditions are met: |
||||||
* 1. Redistributions of source code must retain the above copyright notice, |
|
||||||
* this list of conditions and the following disclaimer. |
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
||||||
* this list of conditions and the following disclaimer in the documentation |
|
||||||
* and/or other materials provided with the distribution. |
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
|
||||||
* may be used to endorse or promote products derived from this software |
|
||||||
* without specific prior written permission. |
|
||||||
* |
* |
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* this list of conditions and the following disclaimer. |
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
* this list of conditions and the following disclaimer in the documentation |
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* and/or other materials provided with the distribution. |
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
* contributors to this software may be used to endorse or promote products
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
* derived from this software without specific written permission. |
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* 4. This software, including modifications and/or derivative works of this
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
* |
* |
||||||
****************************************************************************** |
****************************************************************************** |
||||||
*/ |
*/ |
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/ |
/* Includes ------------------------------------------------------------------*/ |
||||||
#include "stm32l0xx_hal.h" |
#include "hw.h" |
||||||
#include "stm32l0xx.h" |
|
||||||
#include "stm32l0xx_it.h" |
#include "stm32l0xx_it.h" |
||||||
|
#include "low_power.h" |
||||||
|
|
||||||
/* USER CODE BEGIN 0 */ |
/** @addtogroup STM32L1xx_HAL_Examples
|
||||||
|
* @{ |
||||||
|
*/ |
||||||
|
|
||||||
/* USER CODE END 0 */ |
/** @addtogroup SPI_FullDuplex_ComPolling
|
||||||
|
* @{ |
||||||
|
*/ |
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/ |
/* Private typedef -----------------------------------------------------------*/ |
||||||
|
/* Private define ------------------------------------------------------------*/ |
||||||
|
/* Private macro -------------------------------------------------------------*/ |
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
/* Private functions ---------------------------------------------------------*/ |
||||||
|
|
||||||
/******************************************************************************/ |
/******************************************************************************/ |
||||||
/* Cortex-M0+ Processor Interruption and Exception Handlers */
|
/* Cortex-M3 Processor Exceptions Handlers */ |
||||||
/******************************************************************************/ |
/******************************************************************************/ |
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System service call via SWI instruction. |
* @brief This function handles NMI exception. |
||||||
*/ |
* @param None |
||||||
void SVC_Handler(void) |
* @retval None |
||||||
|
*/ |
||||||
|
|
||||||
|
void NMI_Handler(void) |
||||||
{ |
{ |
||||||
/* USER CODE BEGIN SVC_IRQn 0 */ |
} |
||||||
|
|
||||||
/* USER CODE END SVC_IRQn 0 */ |
|
||||||
/* USER CODE BEGIN SVC_IRQn 1 */ |
|
||||||
|
|
||||||
/* USER CODE END SVC_IRQn 1 */ |
/**
|
||||||
|
* @brief This function handles Hard Fault exception. |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
void HardFault_Handler(void) |
||||||
|
{ |
||||||
|
while(1) |
||||||
|
{ |
||||||
|
__NOP(); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Pendable request for system service. |
* @brief This function handles Memory Manage exception. |
||||||
*/ |
* @param None |
||||||
void PendSV_Handler(void) |
* @retval None |
||||||
|
*/ |
||||||
|
void MemManage_Handler(void) |
||||||
{ |
{ |
||||||
/* USER CODE BEGIN PendSV_IRQn 0 */ |
/* Go to infinite loop when Memory Manage exception occurs */ |
||||||
|
while (1) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
/* USER CODE END PendSV_IRQn 0 */ |
/**
|
||||||
/* USER CODE BEGIN PendSV_IRQn 1 */ |
* @brief This function handles Bus Fault exception. |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void BusFault_Handler(void) |
||||||
|
{ |
||||||
|
/* Go to infinite loop when Bus Fault exception occurs */ |
||||||
|
while (1) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
/* USER CODE END PendSV_IRQn 1 */ |
/**
|
||||||
|
* @brief This function handles Usage Fault exception. |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void UsageFault_Handler(void) |
||||||
|
{ |
||||||
|
/* Go to infinite loop when Usage Fault exception occurs */ |
||||||
|
while (1) |
||||||
|
{ |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System tick timer. |
* @brief This function handles SVCall exception. |
||||||
*/ |
* @param None |
||||||
void SysTick_Handler(void) |
* @retval None |
||||||
|
*/ |
||||||
|
void SVC_Handler(void) |
||||||
{ |
{ |
||||||
/* USER CODE BEGIN SysTick_IRQn 0 */ |
} |
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 0 */ |
/**
|
||||||
HAL_IncTick(); |
* @brief This function handles Debug Monitor exception. |
||||||
HAL_SYSTICK_IRQHandler(); |
* @param None |
||||||
/* USER CODE BEGIN SysTick_IRQn 1 */ |
* @retval None |
||||||
|
*/ |
||||||
|
void DebugMon_Handler(void) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 1 */ |
/**
|
||||||
|
* @brief This function handles PendSVC exception. |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void PendSV_Handler(void) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles SysTick Handler. |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void SysTick_Handler(void) |
||||||
|
{ |
||||||
|
HAL_IncTick(); |
||||||
} |
} |
||||||
|
|
||||||
/******************************************************************************/ |
/******************************************************************************/ |
||||||
/* STM32L0xx Peripheral Interrupt Handlers */ |
/* STM32L1xx Peripherals Interrupt Handlers */ |
||||||
/* Add here the Interrupt Handlers for the used peripherals. */ |
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ |
||||||
/* For the available peripheral interrupt handler names, */ |
/* available peripheral interrupt handler's name please refer to the startup */ |
||||||
/* please refer to the startup file (startup_stm32l0xx.s). */ |
/* file (startup_stm32l1xx.s). */ |
||||||
/******************************************************************************/ |
/******************************************************************************/ |
||||||
|
|
||||||
/* USER CODE BEGIN 1 */ |
/**
|
||||||
|
* @brief This function handles PPP interrupt request. |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
/*void PPP_IRQHandler(void)
|
||||||
|
{ |
||||||
|
}*/ |
||||||
|
|
||||||
|
void USART2_IRQHandler( void ) |
||||||
|
{ |
||||||
|
vcom_Print( ); |
||||||
|
} |
||||||
|
|
||||||
|
void RTC_IRQHandler( void ) |
||||||
|
{ |
||||||
|
HW_RTC_IrqHandler ( ); |
||||||
|
} |
||||||
|
|
||||||
|
void EXTI0_1_IRQHandler( void ) |
||||||
|
{ |
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_0 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_1 ); |
||||||
|
} |
||||||
|
|
||||||
|
void EXTI2_3_IRQHandler( void ) |
||||||
|
{ |
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_2 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_3 ); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void EXTI4_15_IRQHandler( void ) |
||||||
|
{ |
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_4 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_5 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_6 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_7 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_8 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_9 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_10 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_11 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_12 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_13 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_14 ); |
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_15 ); |
||||||
|
} |
||||||
|
|
||||||
/* USER CODE END 1 */ |
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||||||
|
@ -1,13 +0,0 @@ |
|||||||
#n |
|
||||||
#t__HAL_RCC_SYSCFG_CLK_ENABLE(); |
|
||||||
#t__HAL_RCC_PWR_CLK_ENABLE(); |
|
||||||
#n |
|
||||||
#t/* System interrupt init*/ |
|
||||||
#t/* SVC_IRQn interrupt configuration */ |
|
||||||
#tNVIC_SetPriority(SVC_IRQn, 0); |
|
||||||
#t/* PendSV_IRQn interrupt configuration */ |
|
||||||
#tNVIC_SetPriority(PendSV_IRQn, 0); |
|
||||||
#t/* SysTick_IRQn interrupt configuration */ |
|
||||||
#tNVIC_SetPriority(SysTick_IRQn, 0); |
|
||||||
#n |
|
||||||
#n |
|
@ -0,0 +1,262 @@ |
|||||||
|
/******************************************************************************
|
||||||
|
* @file vcom.c |
||||||
|
* @author MCD Application Team |
||||||
|
* @version V1.1.2 |
||||||
|
* @date 08-September-2017 |
||||||
|
* @brief manages virtual com port |
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
|
||||||
|
* All rights reserved.</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted, provided that the following conditions are met: |
||||||
|
* |
||||||
|
* 1. Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||||
|
* contributors to this software may be used to endorse or promote products
|
||||||
|
* derived from this software without specific written permission. |
||||||
|
* 4. This software, including modifications and/or derivative works of this
|
||||||
|
* software, must execute solely and exclusively on microcontroller or |
||||||
|
* microprocessor devices manufactured by or for STMicroelectronics. |
||||||
|
* 5. Redistribution and use of this software other than as permitted under
|
||||||
|
* this license is void and will automatically terminate your rights under
|
||||||
|
* this license.
|
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
||||||
|
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||||
|
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "hw.h" |
||||||
|
#include "vcom.h" |
||||||
|
#include <stdarg.h> |
||||||
|
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/ |
||||||
|
/* Private define ------------------------------------------------------------*/ |
||||||
|
#define BUFSIZE 256 |
||||||
|
#define USARTX_IRQn USART2_IRQn |
||||||
|
/* Private macro -------------------------------------------------------------*/ |
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/* buffer */ |
||||||
|
static char buff[BUFSIZE]; |
||||||
|
/* buffer write index*/ |
||||||
|
__IO uint16_t iw=0; |
||||||
|
/* buffer read index*/ |
||||||
|
static uint16_t ir=0; |
||||||
|
/* Uart Handle */ |
||||||
|
static UART_HandleTypeDef UartHandle; |
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
/* Functions Definition ------------------------------------------------------*/ |
||||||
|
|
||||||
|
void vcom_Init(void) |
||||||
|
{ |
||||||
|
/*## Configure the UART peripheral ######################################*/ |
||||||
|
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */ |
||||||
|
/* UART1 configured as follow:
|
||||||
|
- Word Length = 8 Bits |
||||||
|
- Stop Bit = One Stop bit |
||||||
|
- Parity = ODD parity |
||||||
|
- BaudRate = 921600 baud |
||||||
|
- Hardware flow control disabled (RTS and CTS signals) */ |
||||||
|
UartHandle.Instance = USARTX; |
||||||
|
|
||||||
|
UartHandle.Init.BaudRate = 115200; |
||||||
|
UartHandle.Init.WordLength = UART_WORDLENGTH_8B; |
||||||
|
UartHandle.Init.StopBits = UART_STOPBITS_1; |
||||||
|
UartHandle.Init.Parity = UART_PARITY_NONE; |
||||||
|
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; |
||||||
|
UartHandle.Init.Mode = UART_MODE_TX_RX; |
||||||
|
|
||||||
|
if(HAL_UART_Init(&UartHandle) != HAL_OK) |
||||||
|
{ |
||||||
|
/* Initialization Error */ |
||||||
|
Error_Handler();
|
||||||
|
} |
||||||
|
|
||||||
|
HAL_NVIC_SetPriority(USARTX_IRQn, 0x1, 0); |
||||||
|
HAL_NVIC_EnableIRQ(USARTX_IRQn); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void vcom_DeInit(void) |
||||||
|
{ |
||||||
|
#if 1 |
||||||
|
HAL_UART_DeInit(&UartHandle); |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
void vcom_Send( char *format, ... ) |
||||||
|
{ |
||||||
|
va_list args; |
||||||
|
va_start(args, format); |
||||||
|
uint8_t len; |
||||||
|
uint8_t lenTop; |
||||||
|
char tempBuff[128]; |
||||||
|
|
||||||
|
BACKUP_PRIMASK(); |
||||||
|
DISABLE_IRQ(); |
||||||
|
|
||||||
|
/*convert into string at buff[0] of length iw*/ |
||||||
|
len = vsprintf(&tempBuff[0], format, args); |
||||||
|
|
||||||
|
if (iw+len<BUFSIZE) |
||||||
|
{ |
||||||
|
memcpy( &buff[iw], &tempBuff[0], len); |
||||||
|
iw+=len; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
lenTop=BUFSIZE-iw; |
||||||
|
memcpy( &buff[iw], &tempBuff[0], lenTop); |
||||||
|
len-=lenTop; |
||||||
|
memcpy( &buff[0], &tempBuff[lenTop], len); |
||||||
|
iw = len; |
||||||
|
} |
||||||
|
RESTORE_PRIMASK(); |
||||||
|
|
||||||
|
HAL_NVIC_SetPendingIRQ(USARTX_IRQn); |
||||||
|
|
||||||
|
va_end(args); |
||||||
|
} |
||||||
|
|
||||||
|
/* modifes only ir*/ |
||||||
|
void vcom_Print( void) |
||||||
|
{ |
||||||
|
char* CurChar; |
||||||
|
while( ( (iw+BUFSIZE-ir)%BUFSIZE) >0 ) |
||||||
|
{ |
||||||
|
BACKUP_PRIMASK(); |
||||||
|
DISABLE_IRQ(); |
||||||
|
|
||||||
|
CurChar = &buff[ir]; |
||||||
|
ir= (ir+1) %BUFSIZE; |
||||||
|
|
||||||
|
RESTORE_PRIMASK(); |
||||||
|
|
||||||
|
HAL_UART_Transmit(&UartHandle,(uint8_t *) CurChar, 1, 300);
|
||||||
|
} |
||||||
|
HAL_NVIC_ClearPendingIRQ(USARTX_IRQn); |
||||||
|
} |
||||||
|
|
||||||
|
void vcom_Send_Lp( char *format, ... ) |
||||||
|
{ |
||||||
|
va_list args; |
||||||
|
va_start(args, format); |
||||||
|
uint8_t len; |
||||||
|
uint8_t lenTop; |
||||||
|
char tempBuff[128]; |
||||||
|
|
||||||
|
BACKUP_PRIMASK(); |
||||||
|
DISABLE_IRQ(); |
||||||
|
|
||||||
|
/*convert into string at buff[0] of length iw*/ |
||||||
|
len = vsprintf(&tempBuff[0], format, args); |
||||||
|
|
||||||
|
if (iw+len<BUFSIZE) |
||||||
|
{ |
||||||
|
memcpy( &buff[iw], &tempBuff[0], len); |
||||||
|
iw+=len; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
lenTop=BUFSIZE-iw; |
||||||
|
memcpy( &buff[iw], &tempBuff[0], lenTop); |
||||||
|
len-=lenTop; |
||||||
|
memcpy( &buff[0], &tempBuff[lenTop], len); |
||||||
|
iw = len; |
||||||
|
} |
||||||
|
RESTORE_PRIMASK();
|
||||||
|
|
||||||
|
va_end(args); |
||||||
|
} |
||||||
|
/**
|
||||||
|
* @brief UART MSP Initialization
|
||||||
|
* This function configures the hardware resources used in this example:
|
||||||
|
* - Peripheral's clock enable |
||||||
|
* - Peripheral's GPIO Configuration
|
||||||
|
* - NVIC configuration for UART interrupt request enable |
||||||
|
* @param huart: UART handle pointer |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HAL_UART_MspInit(UART_HandleTypeDef *huart) |
||||||
|
{ |
||||||
|
|
||||||
|
/*##-1- Enable peripherals and GPIO Clocks #################################*/ |
||||||
|
|
||||||
|
/* Enable USART1 clock */ |
||||||
|
USARTX_CLK_ENABLE();
|
||||||
|
|
||||||
|
/*##-2- Configure peripheral GPIO ##########################################*/
|
||||||
|
vcom_IoInit( ); |
||||||
|
} |
||||||
|
|
||||||
|
void vcom_IoInit(void) |
||||||
|
{ |
||||||
|
GPIO_InitTypeDef GPIO_InitStruct={0}; |
||||||
|
/* Enable GPIO TX/RX clock */ |
||||||
|
USARTX_TX_GPIO_CLK_ENABLE(); |
||||||
|
USARTX_RX_GPIO_CLK_ENABLE(); |
||||||
|
/* UART TX GPIO pin configuration */ |
||||||
|
GPIO_InitStruct.Pin = USARTX_TX_PIN; |
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||||||
|
GPIO_InitStruct.Pull = GPIO_PULLUP; |
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; |
||||||
|
GPIO_InitStruct.Alternate = USARTX_TX_AF; |
||||||
|
|
||||||
|
HAL_GPIO_Init(USARTX_TX_GPIO_PORT, &GPIO_InitStruct); |
||||||
|
|
||||||
|
/* UART RX GPIO pin configuration */ |
||||||
|
GPIO_InitStruct.Pin = USARTX_RX_PIN; |
||||||
|
GPIO_InitStruct.Alternate = USARTX_RX_AF; |
||||||
|
|
||||||
|
HAL_GPIO_Init(USARTX_RX_GPIO_PORT, &GPIO_InitStruct); |
||||||
|
} |
||||||
|
|
||||||
|
void vcom_IoDeInit(void) |
||||||
|
{ |
||||||
|
GPIO_InitTypeDef GPIO_InitStructure={0}; |
||||||
|
|
||||||
|
USARTX_TX_GPIO_CLK_ENABLE(); |
||||||
|
USARTX_RX_GPIO_CLK_ENABLE(); |
||||||
|
|
||||||
|
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; |
||||||
|
GPIO_InitStructure.Pull = GPIO_NOPULL; |
||||||
|
|
||||||
|
GPIO_InitStructure.Pin = USARTX_TX_PIN ; |
||||||
|
HAL_GPIO_Init( USARTX_TX_GPIO_PORT, &GPIO_InitStructure ); |
||||||
|
|
||||||
|
GPIO_InitStructure.Pin = USARTX_RX_PIN ; |
||||||
|
HAL_GPIO_Init( USARTX_RX_GPIO_PORT, &GPIO_InitStructure );
|
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief UART MSP DeInit |
||||||
|
* @param huart: uart handle |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) |
||||||
|
{ |
||||||
|
vcom_IoDeInit( ); |
||||||
|
} |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,231 @@ |
|||||||
|
/**
|
||||||
|
****************************************************************************** |
||||||
|
* File Name : main.c |
||||||
|
* Description : Main program body |
||||||
|
****************************************************************************** |
||||||
|
** This notice applies to any and all portions of this file |
||||||
|
* that are not between comment pairs USER CODE BEGIN and |
||||||
|
* USER CODE END. Other portions of this file, whether
|
||||||
|
* inserted by the user or by software development tools |
||||||
|
* are owned by their respective copyright owners. |
||||||
|
* |
||||||
|
* COPYRIGHT(c) 2017 STMicroelectronics |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without modification, |
||||||
|
* are permitted provided that the following conditions are met: |
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||||
|
* may be used to endorse or promote products derived from this software |
||||||
|
* without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "main.h" |
||||||
|
#include "stm32l0xx_hal.h" |
||||||
|
#include "i2c.h" |
||||||
|
#include "rtc.h" |
||||||
|
#include "spi.h" |
||||||
|
#include "usart.h" |
||||||
|
#include "gpio.h" |
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */ |
||||||
|
|
||||||
|
/* USER CODE END Includes */ |
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/* USER CODE BEGIN PV */ |
||||||
|
/* Private variables ---------------------------------------------------------*/ |
||||||
|
|
||||||
|
/* USER CODE END PV */ |
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
void SystemClock_Config(void); |
||||||
|
|
||||||
|
/* USER CODE BEGIN PFP */ |
||||||
|
/* Private function prototypes -----------------------------------------------*/ |
||||||
|
|
||||||
|
/* USER CODE END PFP */ |
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */ |
||||||
|
|
||||||
|
/* USER CODE END 0 */ |
||||||
|
|
||||||
|
int main(void) |
||||||
|
{ |
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */ |
||||||
|
|
||||||
|
/* USER CODE END 1 */ |
||||||
|
|
||||||
|
/* MCU Configuration----------------------------------------------------------*/ |
||||||
|
|
||||||
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
||||||
|
HAL_Init(); |
||||||
|
|
||||||
|
/* USER CODE BEGIN Init */ |
||||||
|
|
||||||
|
/* USER CODE END Init */ |
||||||
|
|
||||||
|
/* Configure the system clock */ |
||||||
|
SystemClock_Config(); |
||||||
|
|
||||||
|
/* USER CODE BEGIN SysInit */ |
||||||
|
|
||||||
|
/* USER CODE END SysInit */ |
||||||
|
|
||||||
|
/* Initialize all configured peripherals */ |
||||||
|
MX_GPIO_Init(); |
||||||
|
MX_I2C1_Init(); |
||||||
|
MX_SPI1_Init(); |
||||||
|
MX_USART1_UART_Init(); |
||||||
|
MX_USART2_UART_Init(); |
||||||
|
MX_RTC_Init(); |
||||||
|
|
||||||
|
/* USER CODE BEGIN 2 */ |
||||||
|
|
||||||
|
/* USER CODE END 2 */ |
||||||
|
|
||||||
|
/* Infinite loop */ |
||||||
|
/* USER CODE BEGIN WHILE */ |
||||||
|
while (1) |
||||||
|
{ |
||||||
|
/* USER CODE END WHILE */ |
||||||
|
|
||||||
|
/* USER CODE BEGIN 3 */ |
||||||
|
|
||||||
|
} |
||||||
|
/* USER CODE END 3 */ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** System Clock Configuration
|
||||||
|
*/ |
||||||
|
void SystemClock_Config(void) |
||||||
|
{ |
||||||
|
|
||||||
|
RCC_OscInitTypeDef RCC_OscInitStruct; |
||||||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct; |
||||||
|
RCC_PeriphCLKInitTypeDef PeriphClkInit; |
||||||
|
|
||||||
|
/**Configure the main internal regulator output voltage
|
||||||
|
*/ |
||||||
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
||||||
|
|
||||||
|
/**Initializes the CPU, AHB and APB busses clocks
|
||||||
|
*/ |
||||||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI; |
||||||
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
||||||
|
RCC_OscInitStruct.HSICalibrationValue = 16; |
||||||
|
RCC_OscInitStruct.LSIState = RCC_LSI_ON; |
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
||||||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
||||||
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_3; |
||||||
|
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2; |
||||||
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
||||||
|
{ |
||||||
|
_Error_Handler(__FILE__, __LINE__); |
||||||
|
} |
||||||
|
|
||||||
|
/**Initializes the CPU, AHB and APB busses clocks
|
||||||
|
*/ |
||||||
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
||||||
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
||||||
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
||||||
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
||||||
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
||||||
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
||||||
|
|
||||||
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) |
||||||
|
{ |
||||||
|
_Error_Handler(__FILE__, __LINE__); |
||||||
|
} |
||||||
|
|
||||||
|
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART2 |
||||||
|
|RCC_PERIPHCLK_I2C1|RCC_PERIPHCLK_RTC; |
||||||
|
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; |
||||||
|
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1; |
||||||
|
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; |
||||||
|
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; |
||||||
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) |
||||||
|
{ |
||||||
|
_Error_Handler(__FILE__, __LINE__); |
||||||
|
} |
||||||
|
|
||||||
|
/**Configure the Systick interrupt time
|
||||||
|
*/ |
||||||
|
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); |
||||||
|
|
||||||
|
/**Configure the Systick
|
||||||
|
*/ |
||||||
|
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); |
||||||
|
|
||||||
|
/* SysTick_IRQn interrupt configuration */ |
||||||
|
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); |
||||||
|
} |
||||||
|
|
||||||
|
/* USER CODE BEGIN 4 */ |
||||||
|
|
||||||
|
/* USER CODE END 4 */ |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function is executed in case of error occurrence. |
||||||
|
* @param None |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void _Error_Handler(char * file, int line) |
||||||
|
{ |
||||||
|
/* USER CODE BEGIN Error_Handler_Debug */ |
||||||
|
/* User can add his own implementation to report the HAL error return state */ |
||||||
|
while(1)
|
||||||
|
{ |
||||||
|
} |
||||||
|
/* USER CODE END Error_Handler_Debug */
|
||||||
|
} |
||||||
|
|
||||||
|
#ifdef USE_FULL_ASSERT |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports the name of the source file and the source line number |
||||||
|
* where the assert_param error has occurred. |
||||||
|
* @param file: pointer to the source file name |
||||||
|
* @param line: assert_param error line source number |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
void assert_failed(uint8_t* file, uint32_t line) |
||||||
|
{ |
||||||
|
/* USER CODE BEGIN 6 */ |
||||||
|
/* User can add his own implementation to report the file name and line number,
|
||||||
|
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
||||||
|
/* USER CODE END 6 */ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
/**
|
||||||
|
* @} |
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} |
||||||
|
*/
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,311 @@ |
|||||||
|
/**
|
||||||
|
****************************************************************************** |
||||||
|
* @file stm32l0xx_hal_conf.h |
||||||
|
* @brief HAL configuration file.
|
||||||
|
****************************************************************************** |
||||||
|
* @attention |
||||||
|
* |
||||||
|
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without modification, |
||||||
|
* are permitted provided that the following conditions are met: |
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||||
|
* may be used to endorse or promote products derived from this software |
||||||
|
* without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __STM32L0xx_HAL_CONF_H |
||||||
|
#define __STM32L0xx_HAL_CONF_H |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "main.h" |
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
|
||||||
|
/* ########################## Module Selection ############################## */ |
||||||
|
/**
|
||||||
|
* @brief This is the list of modules to be used in the HAL driver
|
||||||
|
*/ |
||||||
|
|
||||||
|
#define HAL_MODULE_ENABLED |
||||||
|
/*#define HAL_ADC_MODULE_ENABLED */ |
||||||
|
/*#define HAL_CRYP_MODULE_ENABLED */ |
||||||
|
/*#define HAL_COMP_MODULE_ENABLED */ |
||||||
|
/*#define HAL_CRC_MODULE_ENABLED */ |
||||||
|
/*#define HAL_CRYP_MODULE_ENABLED */ |
||||||
|
/*#define HAL_DAC_MODULE_ENABLED */ |
||||||
|
/*#define HAL_FIREWALL_MODULE_ENABLED */ |
||||||
|
/*#define HAL_I2S_MODULE_ENABLED */ |
||||||
|
/*#define HAL_IWDG_MODULE_ENABLED */ |
||||||
|
/*#define HAL_LCD_MODULE_ENABLED */ |
||||||
|
/*#define HAL_LPTIM_MODULE_ENABLED */ |
||||||
|
/*#define HAL_RNG_MODULE_ENABLED */ |
||||||
|
#define HAL_RTC_MODULE_ENABLED |
||||||
|
#define HAL_SPI_MODULE_ENABLED |
||||||
|
/*#define HAL_TIM_MODULE_ENABLED */ |
||||||
|
/*#define HAL_TSC_MODULE_ENABLED */ |
||||||
|
#define HAL_UART_MODULE_ENABLED |
||||||
|
/*#define HAL_USART_MODULE_ENABLED */ |
||||||
|
/*#define HAL_IRDA_MODULE_ENABLED */ |
||||||
|
/*#define HAL_SMARTCARD_MODULE_ENABLED */ |
||||||
|
/*#define HAL_SMBUS_MODULE_ENABLED */ |
||||||
|
/*#define HAL_WWDG_MODULE_ENABLED */ |
||||||
|
/*#define HAL_PCD_MODULE_ENABLED */ |
||||||
|
#define HAL_GPIO_MODULE_ENABLED |
||||||
|
#define HAL_DMA_MODULE_ENABLED |
||||||
|
#define HAL_I2C_MODULE_ENABLED |
||||||
|
#define HAL_RCC_MODULE_ENABLED |
||||||
|
#define HAL_FLASH_MODULE_ENABLED |
||||||
|
#define HAL_PWR_MODULE_ENABLED |
||||||
|
#define HAL_CORTEX_MODULE_ENABLED |
||||||
|
|
||||||
|
/* ########################## Oscillator Values adaptation ####################*/ |
||||||
|
/**
|
||||||
|
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application. |
||||||
|
* This value is used by the RCC HAL module to compute the system frequency |
||||||
|
* (when HSE is used as system clock source, directly or through the PLL).
|
||||||
|
*/ |
||||||
|
#if !defined (HSE_VALUE) |
||||||
|
#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ |
||||||
|
#endif /* HSE_VALUE */ |
||||||
|
|
||||||
|
#if !defined (HSE_STARTUP_TIMEOUT) |
||||||
|
#define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ |
||||||
|
#endif /* HSE_STARTUP_TIMEOUT */ |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal Multiple Speed oscillator (MSI) default value. |
||||||
|
* This value is the default MSI range value after Reset. |
||||||
|
*/ |
||||||
|
#if !defined (MSI_VALUE) |
||||||
|
#define MSI_VALUE ((uint32_t)2097000U) /*!< Value of the Internal oscillator in Hz*/ |
||||||
|
#endif /* MSI_VALUE */ |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal High Speed oscillator (HSI) value. |
||||||
|
* This value is used by the RCC HAL module to compute the system frequency |
||||||
|
* (when HSI is used as system clock source, directly or through the PLL).
|
||||||
|
*/ |
||||||
|
#if !defined (HSI_VALUE) |
||||||
|
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ |
||||||
|
#endif /* HSI_VALUE */ |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal High Speed oscillator for USB (HSI48) value. |
||||||
|
*/ |
||||||
|
#if !defined (HSI48_VALUE) |
||||||
|
#define HSI48_VALUE ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB in Hz. |
||||||
|
The real value may vary depending on the variations |
||||||
|
in voltage and temperature. */ |
||||||
|
#endif /* HSI48_VALUE */ |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal Low Speed oscillator (LSI) value. |
||||||
|
*/ |
||||||
|
#if !defined (LSI_VALUE) |
||||||
|
#define LSI_VALUE ((uint32_t)37000U) /*!< LSI Typical Value in Hz*/ |
||||||
|
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz |
||||||
|
The real value may vary depending on the variations |
||||||
|
in voltage and temperature.*/
|
||||||
|
/**
|
||||||
|
* @brief External Low Speed oscillator (LSE) value. |
||||||
|
* This value is used by the UART, RTC HAL module to compute the system frequency |
||||||
|
*/ |
||||||
|
#if !defined (LSE_VALUE) |
||||||
|
#define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ |
||||||
|
#endif /* LSE_VALUE */ |
||||||
|
|
||||||
|
#if !defined (LSE_STARTUP_TIMEOUT) |
||||||
|
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ |
||||||
|
#endif /* LSE_STARTUP_TIMEOUT */ |
||||||
|
|
||||||
|
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||||
|
=== you can define the HSE value in your toolchain compiler preprocessor. */ |
||||||
|
|
||||||
|
/* ########################### System Configuration ######################### */ |
||||||
|
/**
|
||||||
|
* @brief This is the HAL system configuration section |
||||||
|
*/
|
||||||
|
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ |
||||||
|
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ |
||||||
|
#define USE_RTOS 0U |
||||||
|
#define PREFETCH_ENABLE 0U |
||||||
|
#define PREREAD_ENABLE 1U |
||||||
|
#define BUFFER_CACHE_DISABLE 0U |
||||||
|
|
||||||
|
/* ########################## Assert Selection ############################## */ |
||||||
|
/**
|
||||||
|
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||||
|
* HAL drivers code |
||||||
|
*/ |
||||||
|
/* #define USE_FULL_ASSERT 1U */ |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
/**
|
||||||
|
* @brief Include module's header file
|
||||||
|
*/ |
||||||
|
|
||||||
|
#ifdef HAL_RCC_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_rcc.h" |
||||||
|
#endif /* HAL_RCC_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_GPIO_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_gpio.h" |
||||||
|
#endif /* HAL_GPIO_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_DMA_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_dma.h" |
||||||
|
#endif /* HAL_DMA_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_CORTEX_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_cortex.h" |
||||||
|
#endif /* HAL_CORTEX_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_ADC_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_adc.h" |
||||||
|
#endif /* HAL_ADC_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_COMP_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_comp.h" |
||||||
|
#endif /* HAL_COMP_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_CRC_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_crc.h" |
||||||
|
#endif /* HAL_CRC_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_CRYP_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_cryp.h" |
||||||
|
#endif /* HAL_CRYP_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_DAC_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_dac.h" |
||||||
|
#endif /* HAL_DAC_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_FIREWALL_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_firewall.h" |
||||||
|
#endif /* HAL_FIREWALL_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_FLASH_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_flash.h" |
||||||
|
#endif /* HAL_FLASH_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_I2C_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_i2c.h" |
||||||
|
#endif /* HAL_I2C_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_I2S_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_i2s.h" |
||||||
|
#endif /* HAL_I2S_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_IWDG_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_iwdg.h" |
||||||
|
#endif /* HAL_IWDG_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_LCD_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_lcd.h" |
||||||
|
#endif /* HAL_LCD_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_LPTIM_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_lptim.h" |
||||||
|
#endif /* HAL_LPTIM_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_PWR_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_pwr.h" |
||||||
|
#endif /* HAL_PWR_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_RNG_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_rng.h" |
||||||
|
#endif /* HAL_RNG_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_RTC_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_rtc.h" |
||||||
|
|
||||||
|
#endif /* HAL_RTC_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_SPI_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_spi.h" |
||||||
|
#endif /* HAL_SPI_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_TIM_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_tim.h" |
||||||
|
#endif /* HAL_TIM_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_TSC_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_tsc.h" |
||||||
|
#endif /* HAL_TSC_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_UART_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_uart.h" |
||||||
|
#endif /* HAL_UART_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_USART_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_usart.h" |
||||||
|
#endif /* HAL_USART_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_IRDA_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_irda.h" |
||||||
|
#endif /* HAL_IRDA_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_SMARTCARD_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_smartcard.h" |
||||||
|
#endif /* HAL_SMARTCARD_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_SMBUS_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_smbus.h" |
||||||
|
#endif /* HAL_SMBUS_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_WWDG_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_wwdg.h" |
||||||
|
#endif /* HAL_WWDG_MODULE_ENABLED */ |
||||||
|
|
||||||
|
#ifdef HAL_PCD_MODULE_ENABLED |
||||||
|
#include "stm32l0xx_hal_pcd.h" |
||||||
|
#endif /* HAL_PCD_MODULE_ENABLED */ |
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/ |
||||||
|
#ifdef USE_FULL_ASSERT |
||||||
|
/**
|
||||||
|
* @brief The assert_param macro is used for function's parameters check. |
||||||
|
* @param expr: If expr is false, it calls assert_failed function |
||||||
|
* which reports the name of the source file and the source |
||||||
|
* line number of the call that failed.
|
||||||
|
* If expr is true, it returns no value. |
||||||
|
* @retval None |
||||||
|
*/ |
||||||
|
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) |
||||||
|
/* Exported functions ------------------------------------------------------- */ |
||||||
|
void assert_failed(uint8_t* file, uint32_t line); |
||||||
|
#else |
||||||
|
#define assert_param(expr) ((void)0U) |
||||||
|
#endif /* USE_FULL_ASSERT */ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __STM32L0xx_HAL_CONF_H */ |
||||||
|
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,99 @@ |
|||||||
|
/** |
||||||
|
****************************************************************************** |
||||||
|
* @file stm32l0xx_it.c |
||||||
|
* @brief Interrupt Service Routines. |
||||||
|
****************************************************************************** |
||||||
|
* |
||||||
|
* COPYRIGHT(c) 2017 STMicroelectronics |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without modification, |
||||||
|
* are permitted provided that the following conditions are met: |
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||||
|
* may be used to endorse or promote products derived from this software |
||||||
|
* without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "stm32l0xx_hal.h" |
||||||
|
#include "stm32l0xx.h" |
||||||
|
#include "stm32l0xx_it.h" |
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */ |
||||||
|
|
||||||
|
/* USER CODE END 0 */ |
||||||
|
|
||||||
|
/* External variables --------------------------------------------------------*/ |
||||||
|
|
||||||
|
/******************************************************************************/ |
||||||
|
/* Cortex-M0+ Processor Interruption and Exception Handlers */ |
||||||
|
/******************************************************************************/ |
||||||
|
|
||||||
|
/** |
||||||
|
* @brief This function handles System service call via SWI instruction. |
||||||
|
*/ |
||||||
|
void SVC_Handler(void) |
||||||
|
{ |
||||||
|
/* USER CODE BEGIN SVC_IRQn 0 */ |
||||||
|
|
||||||
|
/* USER CODE END SVC_IRQn 0 */ |
||||||
|
/* USER CODE BEGIN SVC_IRQn 1 */ |
||||||
|
|
||||||
|
/* USER CODE END SVC_IRQn 1 */ |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @brief This function handles Pendable request for system service. |
||||||
|
*/ |
||||||
|
void PendSV_Handler(void) |
||||||
|
{ |
||||||
|
/* USER CODE BEGIN PendSV_IRQn 0 */ |
||||||
|
|
||||||
|
/* USER CODE END PendSV_IRQn 0 */ |
||||||
|
/* USER CODE BEGIN PendSV_IRQn 1 */ |
||||||
|
|
||||||
|
/* USER CODE END PendSV_IRQn 1 */ |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @brief This function handles System tick timer. |
||||||
|
*/ |
||||||
|
void SysTick_Handler(void) |
||||||
|
{ |
||||||
|
/* USER CODE BEGIN SysTick_IRQn 0 */ |
||||||
|
|
||||||
|
/* USER CODE END SysTick_IRQn 0 */ |
||||||
|
HAL_IncTick(); |
||||||
|
HAL_SYSTICK_IRQHandler(); |
||||||
|
/* USER CODE BEGIN SysTick_IRQn 1 */ |
||||||
|
|
||||||
|
/* USER CODE END SysTick_IRQn 1 */ |
||||||
|
} |
||||||
|
|
||||||
|
/******************************************************************************/ |
||||||
|
/* STM32L0xx Peripheral Interrupt Handlers */ |
||||||
|
/* Add here the Interrupt Handlers for the used peripherals. */ |
||||||
|
/* For the available peripheral interrupt handler names, */ |
||||||
|
/* please refer to the startup file (startup_stm32l0xx.s). */ |
||||||
|
/******************************************************************************/ |
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */ |
||||||
|
|
||||||
|
/* USER CODE END 1 */ |
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,60 @@ |
|||||||
|
/**
|
||||||
|
****************************************************************************** |
||||||
|
* @file stm32l0xx_it.h |
||||||
|
* @brief This file contains the headers of the interrupt handlers. |
||||||
|
****************************************************************************** |
||||||
|
* |
||||||
|
* COPYRIGHT(c) 2017 STMicroelectronics |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without modification, |
||||||
|
* are permitted provided that the following conditions are met: |
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer. |
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||||
|
* this list of conditions and the following disclaimer in the documentation |
||||||
|
* and/or other materials provided with the distribution. |
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||||
|
* may be used to endorse or promote products derived from this software |
||||||
|
* without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
****************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||||
|
#ifndef __STM32L0xx_IT_H |
||||||
|
#define __STM32L0xx_IT_H |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/ |
||||||
|
#include "stm32l0xx_hal.h" |
||||||
|
#include "main.h" |
||||||
|
/* Exported types ------------------------------------------------------------*/ |
||||||
|
/* Exported constants --------------------------------------------------------*/ |
||||||
|
/* Exported macro ------------------------------------------------------------*/ |
||||||
|
/* Exported functions ------------------------------------------------------- */ |
||||||
|
|
||||||
|
void SVC_Handler(void); |
||||||
|
void PendSV_Handler(void); |
||||||
|
void SysTick_Handler(void); |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* __STM32L0xx_IT_H */ |
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Loading…
Reference in new issue