parent
9cae7c38f9
commit
3e8aa6488c
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,71 @@ |
||||
<?php |
||||
|
||||
$json = file_get_contents("msg.json"); |
||||
$arr = json_decode($json); |
||||
|
||||
$table = []; |
||||
foreach($arr as $msg) { |
||||
$msg = (array)$msg; |
||||
if ($msg['port'] == 68 && $msg['dev_id'] == 'ondrej_hruska') { |
||||
$table[] = [ |
||||
'counter' => $msg['counter'], |
||||
'date' => ((array)$msg['metadata'])['time'], |
||||
'payload_raw' => $msg['payload_raw'], |
||||
'payload' => parsePayload($msg['payload_raw']), |
||||
]; |
||||
} |
||||
} |
||||
|
||||
print_r($table); |
||||
|
||||
$fil = "Counter\tDate\tTemperature [°C]\tHumidity [%RH]\tPressure [hPa]\tGas_R [Ohm]\n"; |
||||
foreach($table as $row) { |
||||
$p = $row['payload']; |
||||
$fil .= "$row[counter]\t$row[date]\t$p[temp]\t$p[hum]\t$p[press]\t$p[gas_r]\n"; |
||||
} |
||||
|
||||
file_put_contents("msg.csv", $fil); |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function parsePayload($pl64) { |
||||
$pl = base64_decode($pl64); |
||||
|
||||
/* |
||||
pb_i16(&pb, voc_data.temperature); // Cx100 |
||||
pb_u16(&pb, (uint16_t) (voc_data.humidity / 10)); // discard one place -> %x100 |
||||
pb_u16(&pb, (uint16_t) (voc_data.pressure - 85000)); // send offset from 850 hPa -> Pa |
||||
pb_u32(&pb, (uint16_t) (voc_data.gas_resistance)); // ohms, full size |
||||
*/ |
||||
$res = []; |
||||
$t = (ord($pl[0])<<8 | ord($pl[1])); |
||||
if ($t&0x8000) $t = ~$t - 1; |
||||
$res['temp'] = $t/100; |
||||
|
||||
$t = (ord($pl[2])<<8 | ord($pl[3])); |
||||
$res['hum'] = $t/100; |
||||
|
||||
$t = (ord($pl[4])<<8 | ord($pl[5])); |
||||
$res['press'] = (85000+$t)/100; |
||||
|
||||
$t = (ord($pl[6])<<24 | ord($pl[7])<<16 | ord($pl[8])<<8 | ord($pl[9])); |
||||
$res['gas_r'] = $t; |
||||
|
||||
return $res; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -0,0 +1,116 @@ |
||||
[ |
||||
{ |
||||
"id": "39e98fa5.fea9e8", |
||||
"type": "tab", |
||||
"label": "Flow 1" |
||||
}, |
||||
{ |
||||
"id": "fc3137ff.fc017", |
||||
"type": "mqtt in", |
||||
"z": "39e98fa5.fea9e8", |
||||
"name": "", |
||||
"topic": "students_201710/devices/ondrej_hruska/up", |
||||
"qos": "2", |
||||
"broker": "98e3cc43.3bd1e", |
||||
"x": 210.5, |
||||
"y": 137, |
||||
"wires": [ |
||||
[ |
||||
"5898399d.a1de7", |
||||
"da550cf8.6db248" |
||||
] |
||||
] |
||||
}, |
||||
{ |
||||
"id": "5898399d.a1de7", |
||||
"type": "debug", |
||||
"z": "39e98fa5.fea9e8", |
||||
"name": "", |
||||
"active": true, |
||||
"console": "false", |
||||
"complete": "payload", |
||||
"x": 611.5, |
||||
"y": 96, |
||||
"wires": [] |
||||
}, |
||||
{ |
||||
"id": "da550cf8.6db248", |
||||
"type": "function", |
||||
"z": "39e98fa5.fea9e8", |
||||
"name": "Extract data", |
||||
"func": "const pld = JSON.parse(msg.payload);\n\nconst bytes = Buffer.from(pld.payload_raw, 'base64');\n\n\nlet resp = {\n time_s: pld.metadata.time,\n time: Math.round((+(new Date(pld.metadata.time)))/1000), // convert to unix\n base64: pld.payload_raw\n};\n\nlet i = 0;\nlet du = () => {\n return bytes[i++]\n};\n\nresp.temp = (du()<<8 | du()) / 100;\nresp.hum = (du()<<8 | du()) / 100;\nresp.press = (85000 + (du() << 8 | du())) / 100;\nresp.gas_r = du() << 24 | du() << 16 | du() << 8 | du();\n\nreturn {payload: resp};\n", |
||||
"outputs": 1, |
||||
"noerr": 0, |
||||
"x": 386.5, |
||||
"y": 224, |
||||
"wires": [ |
||||
[ |
||||
"e983b01f.348d78", |
||||
"697a6626.6df8b8" |
||||
] |
||||
] |
||||
}, |
||||
{ |
||||
"id": "e983b01f.348d78", |
||||
"type": "debug", |
||||
"z": "39e98fa5.fea9e8", |
||||
"name": "", |
||||
"active": true, |
||||
"console": "false", |
||||
"complete": "true", |
||||
"x": 573.5, |
||||
"y": 184, |
||||
"wires": [] |
||||
}, |
||||
{ |
||||
"id": "1daeac40.f9df74", |
||||
"type": "file", |
||||
"z": "39e98fa5.fea9e8", |
||||
"name": "", |
||||
"filename": "/home/ondra/NodeRED/bees.csv", |
||||
"appendNewline": false, |
||||
"createDir": true, |
||||
"overwriteFile": "false", |
||||
"x": 776.5, |
||||
"y": 263, |
||||
"wires": [] |
||||
}, |
||||
{ |
||||
"id": "697a6626.6df8b8", |
||||
"type": "csv", |
||||
"z": "39e98fa5.fea9e8", |
||||
"name": "", |
||||
"sep": ",", |
||||
"hdrin": "", |
||||
"hdrout": "", |
||||
"multi": "one", |
||||
"ret": "\\n", |
||||
"temp": "time,temp,hum,press,gas_r", |
||||
"x": 564.5, |
||||
"y": 264, |
||||
"wires": [ |
||||
[ |
||||
"1daeac40.f9df74" |
||||
] |
||||
] |
||||
}, |
||||
{ |
||||
"id": "98e3cc43.3bd1e", |
||||
"type": "mqtt-broker", |
||||
"z": "", |
||||
"broker": "eu.thethings.network", |
||||
"port": "8883", |
||||
"tls": "", |
||||
"clientid": "", |
||||
"usetls": true, |
||||
"compatmode": true, |
||||
"keepalive": "60", |
||||
"cleansession": true, |
||||
"willTopic": "", |
||||
"willQos": "0", |
||||
"willPayload": "", |
||||
"birthTopic": "", |
||||
"birthQos": "0", |
||||
"birthPayload": "" |
||||
} |
||||
] |
File diff suppressed because one or more lines are too long
@ -1,138 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : gpio.c |
||||
* Description : This file provides code for the configuration |
||||
* of all used GPIO pins. |
||||
****************************************************************************** |
||||
** 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 "gpio.h" |
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
|
||||
/*----------------------------------------------------------------------------*/ |
||||
/* Configure GPIO */ |
||||
/*----------------------------------------------------------------------------*/ |
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/** Configure pins as
|
||||
* Analog
|
||||
* Input
|
||||
* Output |
||||
* EVENT_OUT |
||||
* EXTI |
||||
* Free pins are configured automatically as Analog (this feature is enabled through
|
||||
* the Code Generation settings) |
||||
*/ |
||||
void MX_GPIO_Init(void) |
||||
{ |
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct; |
||||
|
||||
/* GPIO Ports Clock Enable */ |
||||
__HAL_RCC_GPIOC_CLK_ENABLE(); |
||||
__HAL_RCC_GPIOH_CLK_ENABLE(); |
||||
__HAL_RCC_GPIOA_CLK_ENABLE(); |
||||
__HAL_RCC_GPIOB_CLK_ENABLE(); |
||||
__HAL_RCC_GPIOD_CLK_ENABLE(); |
||||
|
||||
/*Configure GPIO pin : PtPin */ |
||||
GPIO_InitStruct.Pin = B1_Pin; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); |
||||
|
||||
/*Configure GPIO pin : PH1 */ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_1; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); |
||||
|
||||
/*Configure GPIO pins : PC0 PC1 PC2 PC3
|
||||
PC4 PC5 PC6 PC7
|
||||
PC8 PC9 PC10 PC11
|
||||
PC12 */ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|
||||
|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
|GPIO_PIN_12; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
||||
|
||||
/*Configure GPIO pins : PA0 PA1 PA8 PA11
|
||||
PA12 PA15 */ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_11
|
||||
|GPIO_PIN_12|GPIO_PIN_15; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||||
|
||||
/*Configure GPIO pins : PB0 PB1 PB2 PB10
|
||||
PB11 PB12 PB13 PB14
|
||||
PB15 PB3 PB4 PB5
|
||||
PB6 PB7 */ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
|
||||
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
|GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
|
||||
|GPIO_PIN_6|GPIO_PIN_7; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
||||
|
||||
/*Configure GPIO pin : PD2 */ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_2; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); |
||||
|
||||
} |
||||
|
||||
/* USER CODE BEGIN 2 */ |
||||
|
||||
/* USER CODE END 2 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,78 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : gpio.h |
||||
* Description : This file contains all the functions prototypes for
|
||||
* the gpio
|
||||
****************************************************************************** |
||||
** 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. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __gpio_H |
||||
#define __gpio_H |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* USER CODE BEGIN Includes */ |
||||
|
||||
/* USER CODE END Includes */ |
||||
|
||||
/* USER CODE BEGIN Private defines */ |
||||
|
||||
/* USER CODE END Private defines */ |
||||
|
||||
void MX_GPIO_Init(void); |
||||
|
||||
/* USER CODE BEGIN Prototypes */ |
||||
|
||||
/* USER CODE END Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /*__ pinoutConfig_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,149 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : I2C.c |
||||
* Description : This file provides code for the configuration |
||||
* of the I2C instances. |
||||
****************************************************************************** |
||||
** 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 "i2c.h" |
||||
|
||||
#include "gpio.h" |
||||
|
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
|
||||
I2C_HandleTypeDef hi2c1; |
||||
|
||||
/* I2C1 init function */ |
||||
void MX_I2C1_Init(void) |
||||
{ |
||||
|
||||
hi2c1.Instance = I2C1; |
||||
hi2c1.Init.Timing = 0x00506682; |
||||
hi2c1.Init.OwnAddress1 = 0; |
||||
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; |
||||
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; |
||||
hi2c1.Init.OwnAddress2 = 0; |
||||
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; |
||||
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; |
||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; |
||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
/**Configure Analogue filter
|
||||
*/ |
||||
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
/**Configure Digital filter
|
||||
*/ |
||||
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
} |
||||
|
||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle) |
||||
{ |
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct; |
||||
if(i2cHandle->Instance==I2C1) |
||||
{ |
||||
/* USER CODE BEGIN I2C1_MspInit 0 */ |
||||
|
||||
/* USER CODE END I2C1_MspInit 0 */ |
||||
|
||||
/**I2C1 GPIO Configuration
|
||||
PB8 ------> I2C1_SCL |
||||
PB9 ------> I2C1_SDA
|
||||
*/ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; |
||||
GPIO_InitStruct.Pull = GPIO_PULLUP; |
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||||
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; |
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
||||
|
||||
/* I2C1 clock enable */ |
||||
__HAL_RCC_I2C1_CLK_ENABLE(); |
||||
/* USER CODE BEGIN I2C1_MspInit 1 */ |
||||
|
||||
/* USER CODE END I2C1_MspInit 1 */ |
||||
} |
||||
} |
||||
|
||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle) |
||||
{ |
||||
|
||||
if(i2cHandle->Instance==I2C1) |
||||
{ |
||||
/* USER CODE BEGIN I2C1_MspDeInit 0 */ |
||||
|
||||
/* USER CODE END I2C1_MspDeInit 0 */ |
||||
/* Peripheral clock disable */ |
||||
__HAL_RCC_I2C1_CLK_DISABLE(); |
||||
|
||||
/**I2C1 GPIO Configuration
|
||||
PB8 ------> I2C1_SCL |
||||
PB9 ------> I2C1_SDA
|
||||
*/ |
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9); |
||||
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 1 */ |
||||
|
||||
/* USER CODE END I2C1_MspDeInit 1 */ |
||||
} |
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,81 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : I2C.h |
||||
* Description : This file provides code for the configuration |
||||
* of the I2C instances. |
||||
****************************************************************************** |
||||
** 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. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __i2c_H |
||||
#define __i2c_H |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* USER CODE BEGIN Includes */ |
||||
|
||||
/* USER CODE END Includes */ |
||||
|
||||
extern I2C_HandleTypeDef hi2c1; |
||||
|
||||
/* USER CODE BEGIN Private defines */ |
||||
|
||||
/* USER CODE END Private defines */ |
||||
|
||||
extern void _Error_Handler(char *, int); |
||||
|
||||
void HW_I2C_Init(void); |
||||
|
||||
/* USER CODE BEGIN Prototypes */ |
||||
|
||||
/* USER CODE END Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /*__ i2c_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,231 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* 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****/ |
@ -1,114 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : RTC.c |
||||
* Description : This file provides code for the configuration |
||||
* of the RTC instances. |
||||
****************************************************************************** |
||||
** 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 "rtc.h" |
||||
|
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
|
||||
RTC_HandleTypeDef hrtc; |
||||
|
||||
/* RTC init function */ |
||||
void MX_RTC_Init(void) |
||||
{ |
||||
|
||||
/**Initialize RTC Only
|
||||
*/ |
||||
hrtc.Instance = RTC; |
||||
hrtc.Init.HourFormat = RTC_HOURFORMAT_24; |
||||
hrtc.Init.AsynchPrediv = 127; |
||||
hrtc.Init.SynchPrediv = 255; |
||||
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; |
||||
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; |
||||
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; |
||||
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; |
||||
if (HAL_RTC_Init(&hrtc) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
} |
||||
|
||||
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle) |
||||
{ |
||||
|
||||
if(rtcHandle->Instance==RTC) |
||||
{ |
||||
/* USER CODE BEGIN RTC_MspInit 0 */ |
||||
|
||||
/* USER CODE END RTC_MspInit 0 */ |
||||
/* RTC clock enable */ |
||||
__HAL_RCC_RTC_ENABLE(); |
||||
/* USER CODE BEGIN RTC_MspInit 1 */ |
||||
|
||||
/* USER CODE END RTC_MspInit 1 */ |
||||
} |
||||
} |
||||
|
||||
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle) |
||||
{ |
||||
|
||||
if(rtcHandle->Instance==RTC) |
||||
{ |
||||
/* USER CODE BEGIN RTC_MspDeInit 0 */ |
||||
|
||||
/* USER CODE END RTC_MspDeInit 0 */ |
||||
/* Peripheral clock disable */ |
||||
__HAL_RCC_RTC_DISABLE(); |
||||
/* USER CODE BEGIN RTC_MspDeInit 1 */ |
||||
|
||||
/* USER CODE END RTC_MspDeInit 1 */ |
||||
} |
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,81 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : RTC.h |
||||
* Description : This file provides code for the configuration |
||||
* of the RTC instances. |
||||
****************************************************************************** |
||||
** 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. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __rtc_H |
||||
#define __rtc_H |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* USER CODE BEGIN Includes */ |
||||
|
||||
/* USER CODE END Includes */ |
||||
|
||||
extern RTC_HandleTypeDef hrtc; |
||||
|
||||
/* USER CODE BEGIN Private defines */ |
||||
|
||||
/* USER CODE END Private defines */ |
||||
|
||||
extern void _Error_Handler(char *, int); |
||||
|
||||
void MX_RTC_Init(void); |
||||
|
||||
/* USER CODE BEGIN Prototypes */ |
||||
|
||||
/* USER CODE END Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /*__ rtc_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,142 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : SPI.c |
||||
* Description : This file provides code for the configuration |
||||
* of the SPI instances. |
||||
****************************************************************************** |
||||
** 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 "spi.h" |
||||
|
||||
#include "gpio.h" |
||||
|
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
|
||||
SPI_HandleTypeDef hspi1; |
||||
|
||||
/* SPI1 init function */ |
||||
void MX_SPI1_Init(void) |
||||
{ |
||||
|
||||
hspi1.Instance = SPI1; |
||||
hspi1.Init.Mode = SPI_MODE_MASTER; |
||||
hspi1.Init.Direction = SPI_DIRECTION_2LINES; |
||||
hspi1.Init.DataSize = SPI_DATASIZE_8BIT; |
||||
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; |
||||
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; |
||||
hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT; |
||||
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; |
||||
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; |
||||
hspi1.Init.TIMode = SPI_TIMODE_DISABLE; |
||||
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; |
||||
hspi1.Init.CRCPolynomial = 7; |
||||
if (HAL_SPI_Init(&hspi1) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
} |
||||
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) |
||||
{ |
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct; |
||||
if(spiHandle->Instance==SPI1) |
||||
{ |
||||
/* USER CODE BEGIN SPI1_MspInit 0 */ |
||||
|
||||
/* USER CODE END SPI1_MspInit 0 */ |
||||
/* SPI1 clock enable */ |
||||
__HAL_RCC_SPI1_CLK_ENABLE(); |
||||
|
||||
/**SPI1 GPIO Configuration
|
||||
PA4 ------> SPI1_NSS |
||||
PA5 ------> SPI1_SCK |
||||
PA6 ------> SPI1_MISO |
||||
PA7 ------> SPI1_MOSI
|
||||
*/ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||||
GPIO_InitStruct.Alternate = GPIO_AF0_SPI1; |
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||||
|
||||
/* USER CODE BEGIN SPI1_MspInit 1 */ |
||||
|
||||
/* USER CODE END SPI1_MspInit 1 */ |
||||
} |
||||
} |
||||
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle) |
||||
{ |
||||
|
||||
if(spiHandle->Instance==SPI1) |
||||
{ |
||||
/* USER CODE BEGIN SPI1_MspDeInit 0 */ |
||||
|
||||
/* USER CODE END SPI1_MspDeInit 0 */ |
||||
/* Peripheral clock disable */ |
||||
__HAL_RCC_SPI1_CLK_DISABLE(); |
||||
|
||||
/**SPI1 GPIO Configuration
|
||||
PA4 ------> SPI1_NSS |
||||
PA5 ------> SPI1_SCK |
||||
PA6 ------> SPI1_MISO |
||||
PA7 ------> SPI1_MOSI
|
||||
*/ |
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); |
||||
|
||||
/* USER CODE BEGIN SPI1_MspDeInit 1 */ |
||||
|
||||
/* USER CODE END SPI1_MspDeInit 1 */ |
||||
} |
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,81 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : SPI.h |
||||
* Description : This file provides code for the configuration |
||||
* of the SPI instances. |
||||
****************************************************************************** |
||||
** 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. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __spi_H |
||||
#define __spi_H |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* USER CODE BEGIN Includes */ |
||||
|
||||
/* USER CODE END Includes */ |
||||
|
||||
extern SPI_HandleTypeDef hspi1; |
||||
|
||||
/* USER CODE BEGIN Private defines */ |
||||
|
||||
/* USER CODE END Private defines */ |
||||
|
||||
extern void _Error_Handler(char *, int); |
||||
|
||||
void MX_SPI1_Init(void); |
||||
|
||||
/* USER CODE BEGIN Prototypes */ |
||||
|
||||
/* USER CODE END Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /*__ spi_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,311 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* @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****/ |
@ -1,83 +0,0 @@ |
||||
/** |
||||
****************************************************************************** |
||||
* File Name : stm32l0xx_hal_msp.c |
||||
* Description : This file provides code for the MSP Initialization |
||||
* and de-Initialization codes. |
||||
****************************************************************************** |
||||
** 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 "stm32l0xx_hal.h" |
||||
|
||||
extern void _Error_Handler(char *, int); |
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
/** |
||||
* Initializes the Global MSP. |
||||
*/ |
||||
void HAL_MspInit(void) |
||||
{ |
||||
/* USER CODE BEGIN MspInit 0 */ |
||||
|
||||
/* USER CODE END MspInit 0 */ |
||||
|
||||
__HAL_RCC_SYSCFG_CLK_ENABLE(); |
||||
__HAL_RCC_PWR_CLK_ENABLE(); |
||||
|
||||
/* System interrupt init*/ |
||||
/* SVC_IRQn interrupt configuration */ |
||||
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 */ |
||||
|
||||
/* USER CODE END MspInit 1 */ |
||||
} |
||||
|
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,99 +0,0 @@ |
||||
/** |
||||
****************************************************************************** |
||||
* @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****/ |
@ -1,60 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* @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****/ |
@ -1,285 +0,0 @@ |
||||
/** |
||||
****************************************************************************** |
||||
* @file system_stm32l0xx.c |
||||
* @author MCD Application Team |
||||
* @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Source File. |
||||
* |
||||
* This file provides two functions and one global variable to be called from |
||||
* user application: |
||||
* - SystemInit(): This function is called at startup just after reset and |
||||
* before branch to main program. This call is made inside |
||||
* the "startup_stm32l0xx.s" file. |
||||
* |
||||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used |
||||
* by the user application to setup the SysTick |
||||
* timer or configure other parameters. |
||||
* |
||||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must |
||||
* be called whenever the core clock is changed |
||||
* during program execution. |
||||
* |
||||
* |
||||
****************************************************************************** |
||||
* @attention |
||||
* |
||||
* <h2><center>© COPYRIGHT(c) 2016 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. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
|
||||
/** @addtogroup CMSIS |
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup stm32l0xx_system |
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup STM32L0xx_System_Private_Includes |
||||
* @{ |
||||
*/ |
||||
|
||||
#include "stm32l0xx.h" |
||||
|
||||
#if !defined (HSE_VALUE) |
||||
#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ |
||||
#endif /* HSE_VALUE */ |
||||
|
||||
#if !defined (MSI_VALUE) |
||||
#define MSI_VALUE ((uint32_t)2000000U) /*!< Value of the Internal oscillator in Hz*/ |
||||
#endif /* MSI_VALUE */ |
||||
|
||||
#if !defined (HSI_VALUE) |
||||
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ |
||||
#endif /* HSI_VALUE */ |
||||
|
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** @addtogroup STM32L0xx_System_Private_TypesDefinitions |
||||
* @{ |
||||
*/ |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** @addtogroup STM32L0xx_System_Private_Defines |
||||
* @{ |
||||
*/ |
||||
/************************* Miscellaneous Configuration ************************/ |
||||
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table in |
||||
Internal SRAM. */ |
||||
/* #define VECT_TAB_SRAM */ |
||||
#define VECT_TAB_OFFSET 0x00U /*!< Vector Table base offset field. |
||||
This value must be a multiple of 0x200. */ |
||||
/******************************************************************************/ |
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** @addtogroup STM32L0xx_System_Private_Macros |
||||
* @{ |
||||
*/ |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** @addtogroup STM32L0xx_System_Private_Variables |
||||
* @{ |
||||
*/ |
||||
/* This variable is updated in three ways: |
||||
1) by calling CMSIS function SystemCoreClockUpdate() |
||||
2) by calling HAL API function HAL_RCC_GetHCLKFreq() |
||||
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency |
||||
Note: If you use this function to configure the system clock; then there |
||||
is no need to call the 2 first functions listed above, since SystemCoreClock |
||||
variable is updated automatically. |
||||
*/ |
||||
uint32_t SystemCoreClock = 2000000U; |
||||
const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; |
||||
const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; |
||||
const uint8_t PLLMulTable[9] = {3U, 4U, 6U, 8U, 12U, 16U, 24U, 32U, 48U}; |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** @addtogroup STM32L0xx_System_Private_FunctionPrototypes |
||||
* @{ |
||||
*/ |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** @addtogroup STM32L0xx_System_Private_Functions |
||||
* @{ |
||||
*/ |
||||
|
||||
/** |
||||
* @brief Setup the microcontroller system. |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void SystemInit (void) |
||||
{ |
||||
/*!< Set MSION bit */ |
||||
RCC->CR |= (uint32_t)0x00000100U; |
||||
|
||||
/*!< Reset SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], MCOSEL[2:0] and MCOPRE[2:0] bits */ |
||||
RCC->CFGR &= (uint32_t) 0x88FF400CU; |
||||
|
||||
/*!< Reset HSION, HSIDIVEN, HSEON, CSSON and PLLON bits */ |
||||
RCC->CR &= (uint32_t)0xFEF6FFF6U; |
||||
|
||||
/*!< Reset HSI48ON bit */ |
||||
RCC->CRRCR &= (uint32_t)0xFFFFFFFEU; |
||||
|
||||
/*!< Reset HSEBYP bit */ |
||||
RCC->CR &= (uint32_t)0xFFFBFFFFU; |
||||
|
||||
/*!< Reset PLLSRC, PLLMUL[3:0] and PLLDIV[1:0] bits */ |
||||
RCC->CFGR &= (uint32_t)0xFF02FFFFU; |
||||
|
||||
/*!< Disable all interrupts */ |
||||
RCC->CIER = 0x00000000U; |
||||
|
||||
/* Configure the Vector Table location add offset address ------------------*/ |
||||
#ifdef VECT_TAB_SRAM |
||||
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ |
||||
#else |
||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ |
||||
#endif |
||||
} |
||||
|
||||
/** |
||||
* @brief Update SystemCoreClock according to Clock Register Values |
||||
* The SystemCoreClock variable contains the core clock (HCLK), it can |
||||
* be used by the user application to setup the SysTick timer or configure |
||||
* other parameters. |
||||
* |
||||
* @note Each time the core clock (HCLK) changes, this function must be called |
||||
* to update SystemCoreClock variable value. Otherwise, any configuration |
||||
* based on this variable will be incorrect. |
||||
* |
||||
* @note - The system frequency computed by this function is not the real |
||||
* frequency in the chip. It is calculated based on the predefined |
||||
* constant and the selected clock source: |
||||
* |
||||
* - If SYSCLK source is MSI, SystemCoreClock will contain the MSI |
||||
* value as defined by the MSI range. |
||||
* |
||||
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) |
||||
* |
||||
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) |
||||
* |
||||
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) |
||||
* or HSI_VALUE(*) multiplied/divided by the PLL factors. |
||||
* |
||||
* (*) HSI_VALUE is a constant defined in stm32l0xx_hal.h file (default value |
||||
* 16 MHz) but the real value may vary depending on the variations |
||||
* in voltage and temperature. |
||||
* |
||||
* (**) HSE_VALUE is a constant defined in stm32l0xx_hal.h file (default value |
||||
* 8 MHz), user has to ensure that HSE_VALUE is same as the real |
||||
* frequency of the crystal used. Otherwise, this function may |
||||
* have wrong result. |
||||
* |
||||
* - The result of this function could be not correct when using fractional |
||||
* value for HSE crystal. |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void SystemCoreClockUpdate (void) |
||||
{ |
||||
uint32_t tmp = 0U, pllmul = 0U, plldiv = 0U, pllsource = 0U, msirange = 0U; |
||||
|
||||
/* Get SYSCLK source -------------------------------------------------------*/ |
||||
tmp = RCC->CFGR & RCC_CFGR_SWS; |
||||
|
||||
switch (tmp) |
||||
{ |
||||
case 0x00U: /* MSI used as system clock */ |
||||
msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE) >> 13U; |
||||
SystemCoreClock = (32768U * (1U << (msirange + 1U))); |
||||
break; |
||||
case 0x04U: /* HSI used as system clock */ |
||||
SystemCoreClock = HSI_VALUE; |
||||
break; |
||||
case 0x08U: /* HSE used as system clock */ |
||||
SystemCoreClock = HSE_VALUE; |
||||
break; |
||||
case 0x0CU: /* PLL used as system clock */ |
||||
/* Get PLL clock source and multiplication factor ----------------------*/ |
||||
pllmul = RCC->CFGR & RCC_CFGR_PLLMUL; |
||||
plldiv = RCC->CFGR & RCC_CFGR_PLLDIV; |
||||
pllmul = PLLMulTable[(pllmul >> 18U)]; |
||||
plldiv = (plldiv >> 22U) + 1U; |
||||
|
||||
pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; |
||||
|
||||
if (pllsource == 0x00U) |
||||
{ |
||||
/* HSI oscillator clock selected as PLL clock entry */ |
||||
SystemCoreClock = (((HSI_VALUE) * pllmul) / plldiv); |
||||
} |
||||
else |
||||
{ |
||||
/* HSE selected as PLL clock entry */ |
||||
SystemCoreClock = (((HSE_VALUE) * pllmul) / plldiv); |
||||
} |
||||
break; |
||||
default: /* MSI used as system clock */ |
||||
msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE) >> 13U; |
||||
SystemCoreClock = (32768U * (1U << (msirange + 1U))); |
||||
break; |
||||
} |
||||
/* Compute HCLK clock frequency --------------------------------------------*/ |
||||
/* Get HCLK prescaler */ |
||||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; |
||||
/* HCLK clock frequency */ |
||||
SystemCoreClock >>= tmp; |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/** |
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,200 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : USART.c |
||||
* Description : This file provides code for the configuration |
||||
* of the USART instances. |
||||
****************************************************************************** |
||||
** 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 "usart.h" |
||||
|
||||
#include "gpio.h" |
||||
|
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
|
||||
UART_HandleTypeDef huart1; |
||||
UART_HandleTypeDef huart2; |
||||
|
||||
/* USART1 init function */ |
||||
|
||||
void MX_USART1_UART_Init(void) |
||||
{ |
||||
|
||||
huart1.Instance = USART1; |
||||
huart1.Init.BaudRate = 115200; |
||||
huart1.Init.WordLength = UART_WORDLENGTH_7B; |
||||
huart1.Init.StopBits = UART_STOPBITS_1; |
||||
huart1.Init.Parity = UART_PARITY_NONE; |
||||
huart1.Init.Mode = UART_MODE_TX_RX; |
||||
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; |
||||
huart1.Init.OverSampling = UART_OVERSAMPLING_16; |
||||
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; |
||||
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; |
||||
if (HAL_UART_Init(&huart1) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
} |
||||
/* USART2 init function */ |
||||
|
||||
void MX_USART2_UART_Init(void) |
||||
{ |
||||
|
||||
huart2.Instance = USART2; |
||||
huart2.Init.BaudRate = 115200; |
||||
huart2.Init.WordLength = UART_WORDLENGTH_7B; |
||||
huart2.Init.StopBits = UART_STOPBITS_1; |
||||
huart2.Init.Parity = UART_PARITY_NONE; |
||||
huart2.Init.Mode = UART_MODE_TX_RX; |
||||
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; |
||||
huart2.Init.OverSampling = UART_OVERSAMPLING_16; |
||||
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; |
||||
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; |
||||
if (HAL_UART_Init(&huart2) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
} |
||||
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) |
||||
{ |
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct; |
||||
if(uartHandle->Instance==USART1) |
||||
{ |
||||
/* USER CODE BEGIN USART1_MspInit 0 */ |
||||
|
||||
/* USER CODE END USART1_MspInit 0 */ |
||||
/* USART1 clock enable */ |
||||
__HAL_RCC_USART1_CLK_ENABLE(); |
||||
|
||||
/**USART1 GPIO Configuration
|
||||
PA9 ------> USART1_TX |
||||
PA10 ------> USART1_RX
|
||||
*/ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||||
GPIO_InitStruct.Pull = GPIO_PULLUP; |
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||||
GPIO_InitStruct.Alternate = GPIO_AF4_USART1; |
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||||
|
||||
/* USER CODE BEGIN USART1_MspInit 1 */ |
||||
|
||||
/* USER CODE END USART1_MspInit 1 */ |
||||
} |
||||
else if(uartHandle->Instance==USART2) |
||||
{ |
||||
/* USER CODE BEGIN USART2_MspInit 0 */ |
||||
|
||||
/* USER CODE END USART2_MspInit 0 */ |
||||
/* USART2 clock enable */ |
||||
__HAL_RCC_USART2_CLK_ENABLE(); |
||||
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX |
||||
PA3 ------> USART2_RX
|
||||
*/ |
||||
GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||||
GPIO_InitStruct.Pull = GPIO_PULLUP; |
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||||
GPIO_InitStruct.Alternate = GPIO_AF4_USART2; |
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||||
|
||||
/* USER CODE BEGIN USART2_MspInit 1 */ |
||||
|
||||
/* USER CODE END USART2_MspInit 1 */ |
||||
} |
||||
} |
||||
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) |
||||
{ |
||||
|
||||
if(uartHandle->Instance==USART1) |
||||
{ |
||||
/* USER CODE BEGIN USART1_MspDeInit 0 */ |
||||
|
||||
/* USER CODE END USART1_MspDeInit 0 */ |
||||
/* Peripheral clock disable */ |
||||
__HAL_RCC_USART1_CLK_DISABLE(); |
||||
|
||||
/**USART1 GPIO Configuration
|
||||
PA9 ------> USART1_TX |
||||
PA10 ------> USART1_RX
|
||||
*/ |
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); |
||||
|
||||
/* USER CODE BEGIN USART1_MspDeInit 1 */ |
||||
|
||||
/* USER CODE END USART1_MspDeInit 1 */ |
||||
} |
||||
else if(uartHandle->Instance==USART2) |
||||
{ |
||||
/* USER CODE BEGIN USART2_MspDeInit 0 */ |
||||
|
||||
/* USER CODE END USART2_MspDeInit 0 */ |
||||
/* Peripheral clock disable */ |
||||
__HAL_RCC_USART2_CLK_DISABLE(); |
||||
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX |
||||
PA3 ------> USART2_RX
|
||||
*/ |
||||
HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin); |
||||
|
||||
/* USER CODE BEGIN USART2_MspDeInit 1 */ |
||||
|
||||
/* USER CODE END USART2_MspDeInit 1 */ |
||||
} |
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -1,83 +0,0 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : USART.h |
||||
* Description : This file provides code for the configuration |
||||
* of the USART instances. |
||||
****************************************************************************** |
||||
** 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. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __usart_H |
||||
#define __usart_H |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* USER CODE BEGIN Includes */ |
||||
|
||||
/* USER CODE END Includes */ |
||||
|
||||
extern UART_HandleTypeDef huart1; |
||||
extern UART_HandleTypeDef huart2; |
||||
|
||||
/* USER CODE BEGIN Private defines */ |
||||
|
||||
/* USER CODE END Private defines */ |
||||
|
||||
extern void _Error_Handler(char *, int); |
||||
|
||||
void MX_USART1_UART_Init(void); |
||||
void MX_USART2_UART_Init(void); |
||||
|
||||
/* USER CODE BEGIN Prototypes */ |
||||
|
||||
/* USER CODE END Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /*__ usart_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Loading…
Reference in new issue