/**
******************************************************************************
* @file stm8l15x_tim1.c
* @author MCD Application Team
* @version V1.4.0
* @date 09/24/2010
* @brief This file provides all the TIM1 firmware functions.
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2010 STMicroelectronics</center></h2>
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8l15x_tim1.h"
/** @addtogroup STM8L15x_StdPeriph_Driver
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void TI1_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
static void TI2_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
static void TI3_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
static void TI4_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
/**
* @addtogroup TIM1_Public_Functions
* @{
*/
/**
* @brief Deinitializes the TIM1 peripheral registers to their default reset values.
* @param None
* @retval None
*/
void TIM1_DeInit(void)
{
TIM1->CR1 = TIM1_CR1_RESET_VALUE;
TIM1->CR2 = TIM1_CR2_RESET_VALUE;
TIM1->SMCR = TIM1_SMCR_RESET_VALUE;
TIM1->ETR = TIM1_ETR_RESET_VALUE;
TIM1->IER = TIM1_IER_RESET_VALUE;
/* Disable channels */
TIM1->CCER1 = TIM1_CCER1_RESET_VALUE;
TIM1->CCER2 = TIM1_CCER2_RESET_VALUE;
/* Configure channels as inputs: it is necessary if lock level is equal to 2 or 3 */
TIM1->CCMR1 = 0x01;
TIM1->CCMR2 = 0x01;
TIM1->CCMR3 = 0x01;
TIM1->CCMR4 = 0x01;
/* Then reset channel registers: it also works if lock level is equal to 2 or 3 */
TIM1->CCER1 = TIM1_CCER1_RESET_VALUE;
TIM1->CCER2 = TIM1_CCER2_RESET_VALUE;
TIM1->CCMR1 = TIM1_CCMR1_RESET_VALUE;
TIM1->CCMR2 = TIM1_CCMR2_RESET_VALUE;
TIM1->CCMR3 = TIM1_CCMR3_RESET_VALUE;
TIM1->CCMR4 = TIM1_CCMR4_RESET_VALUE;
TIM1->CNTRH = TIM1_CNTRH_RESET_VALUE;
TIM1->CNTRL = TIM1_CNTRL_RESET_VALUE;
TIM1->PSCRH = TIM1_PSCRH_RESET_VALUE;
TIM1->PSCRL = TIM1_PSCRL_RESET_VALUE;
TIM1->ARRH = TIM1_ARRH_RESET_VALUE;
TIM1->ARRL = TIM1_ARRL_RESET_VALUE;
TIM1->CCR1H = TIM1_CCR1H_RESET_VALUE;
TIM1->CCR1L = TIM1_CCR1L_RESET_VALUE;
TIM1->CCR2H = TIM1_CCR2H_RESET_VALUE;
TIM1->CCR2L = TIM1_CCR2L_RESET_VALUE;
TIM1->CCR3H = TIM1_CCR3H_RESET_VALUE;
TIM1->CCR3L = TIM1_CCR3L_RESET_VALUE;
TIM1->CCR4H = TIM1_CCR4H_RESET_VALUE;
TIM1->CCR4L = TIM1_CCR4L_RESET_VALUE;
TIM1->OISR = TIM1_OISR_RESET_VALUE;
TIM1->EGR = 0x01; /* TIM1_EGR_UG */
TIM1->DTR = TIM1_DTR_RESET_VALUE;
TIM1->BKR = TIM1_BKR_RESET_VALUE;
TIM1->RCR = TIM1_RCR_RESET_VALUE;
TIM1->SR1 = TIM1_SR1_RESET_VALUE;
TIM1->SR2 = TIM1_SR2_RESET_VALUE;
}
/**
* @brief Initializes the TIM1 Time Base Unit according to the specified parameters.
* @param TIM1_Prescaler specifies the Prescaler value.
* @param TIM1_CounterMode specifies the counter mode from
* @ref TIM1_CounterMode_TypeDef .
* @param TIM1_Period specifies the Period value.
* @param TIM1_RepetitionCounter specifies the Repetition counter value
* @retval None
*/
void TIM1_TimeBaseInit(uint16_t TIM1_Prescaler,
TIM1_CounterMode_TypeDef TIM1_CounterMode,
uint16_t TIM1_Period,
uint8_t TIM1_RepetitionCounter)
{
/* Check parameters */
assert_param(IS_TIM1_COUNTER_MODE(TIM1_CounterMode));
/* Set the Autoreload value */
TIM1->ARRH = (uint8_t)(TIM1_Period >> 8);
TIM1->ARRL = (uint8_t)(TIM1_Period);
/* Set the Prescaler value */
TIM1->PSCRH = (uint8_t)(TIM1_Prescaler >> 8);
TIM1->PSCRL = (uint8_t)(TIM1_Prescaler);
/* Select the Counter Mode */
TIM1->CR1 = (uint8_t)((uint8_t)(TIM1->CR1 & (uint8_t)(~(TIM1_CR1_CMS | TIM1_CR1_DIR)))
| (uint8_t)(TIM1_CounterMode));
/* Set the Repetition Counter value */
TIM1->RCR = TIM1_RepetitionCounter;
}
/**
* @brief Initializes the TIM1 Channel1 according to the specified parameters.
* @param TIM1_OCMode specifies the Output Compare mode from
* @ref TIM1_OCMode_TypeDef.
* @param TIM1_OutputState specifies the Output State from
* @ref TIM1_OutputState_TypeDef.
* @param TIM1_OutputNState specifies the Complementary Output State from
* @ref TIM1_OutputNState_TypeDef.
* @param TIM1_Pulse specifies the Pulse width value.
* @param TIM1_OCPolarity specifies the Output Compare Polarity from
* @ref TIM1_OCPolarity_TypeDef.
* @param TIM1_OCNPolarity specifies the Complementary Output Compare
* Polarity from @ref TIM1_OCNPolarity_TypeDef.
* @param TIM1_OCIdleState specifies the Output Compare Idle State from
* @ref TIM1_OCIdleState_TypeDef.
* @param TIM1_OCNIdleState specifies the Complementary Output Compare
* Idle State from @ref TIM1_OCIdleState_TypeDef.
* @retval None
*/
void TIM1_OC1Init(TIM1_OCMode_TypeDef TIM1_OCMode,
TIM1_OutputState_TypeDef TIM1_OutputState,
TIM1_OutputNState_TypeDef TIM1_OutputNState,
uint16_t TIM1_Pulse,
TIM1_OCPolarity_TypeDef TIM1_OCPolarity,
TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity,
TIM1_OCIdleState_TypeDef TIM1_OCIdleState,
TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState)
{
/* Check the parameters */
assert_param(IS_TIM1_OC_MODE(TIM1_OCMode));
assert_param(IS_TIM1_OUTPUT_STATE(TIM1_OutputState));
assert_param(IS_TIM1_OUTPUTN_STATE(TIM1_OutputNState));
assert_param(IS_TIM1_OC_POLARITY(TIM1_OCPolarity));
assert_param(IS_TIM1_OCN_POLARITY(TIM1_OCNPolarity));
assert_param(IS_TIM1_OCIDLE_STATE(TIM1_OCIdleState));
assert_param(IS_TIM1_OCNIDLE_STATE(TIM1_OCNIdleState));
/* Disable the Channel 1: Reset the CCE Bit, Set the Output State ,
the Output N State, the Output Polarity & the Output N Polarity*/
TIM1->CCER1 &= (uint8_t)(~(TIM1_CCER1_CC1E | TIM1_CCER1_CC1NE
| TIM1_CCER1_CC1P | TIM1_CCER1_CC1NP));
/* Set the Output State & Set the Output N State & Set the Output Polarity
& Set the Output N Polarity */
TIM1->CCER1 |= (uint8_t)((uint8_t)((uint8_t)(TIM1_OutputState & TIM1_CCER1_CC1E)
| (uint8_t)(TIM1_OutputNState & TIM1_CCER1_CC1NE))
| (uint8_t)( (uint8_t)(TIM1_OCPolarity & TIM1_CCER1_CC1P)
| (uint8_t)(TIM1_OCNPolarity & TIM1_CCER1_CC1NP)));
/* Reset the Output Compare Bits & Set the Ouput Compare Mode */
TIM1->CCMR1 = (uint8_t)((uint8_t)(TIM1->CCMR1 & (uint8_t)(~TIM1_CCMR_OCM))
| (uint8_t)TIM1_OCMode);
/* Reset the Output Idle state & the Outp
LoRa点对点系统源代码
5星 · 超过95%的资源 需积分: 0 101 浏览量
更新于2016-10-25
11
收藏 1.21MB RAR 举报
LoRa点对点系统源代码是一个专为物联网(IoT)设计的通信解决方案,它利用了LoRa(Long Range)技术的优势,实现低功耗、远距离的数据传输。LoRa是一种基于扩频调制技术的无线通信标准,特别适合于需要广覆盖、低功耗的应用场景,如智慧城市、农业监测、资产追踪等。
在该系统中,LoRa终端平台采用了STM8L151C8T6微控制器,这是一个低功耗的8位微控制器,由STMicroelectronics制造。STM8L151C8T6具有高效的能源管理功能,适用于长时间运行的IoT设备。同时,它集成了LoRa收发器SX1278,这是一款高性能的射频芯片,支持LoRa调制解调,能提供高达15km以上的通信距离,具体取决于环境条件。
SX1278是Semtech公司生产的LoRa芯片,其特点包括宽电压输入范围、高接收灵敏度和出色的抗干扰能力。它能够工作在多个频率带,如433MHz、868MHz和915MHz,这使得LoRa网络可以在全球范围内部署。在LoRa点对点系统中,SX1278负责处理无线信号的发射和接收。
Contiki操作系统是一个开源的、轻量级的物联网操作系统,专门为资源有限的设备设计。它包含了实时性、多任务调度、网络协议栈等功能,支持IPv6和6LoWPAN,为LoRa终端提供了一个强大的软件基础。在本项目中,Contiki系统被用于实现LoRa终端间的通信协议,使得数据能在两个或更多的设备之间可靠地传输。
压缩包文件"LoRaP2P"可能包含以下内容:
1. LoRa终端的固件源代码:这部分代码实现了STM8L151C8T6微控制器的驱动程序,以及LoRa通信协议栈。
2. Contiki操作系统配置和应用:可能包含针对LoRa通信定制的Contiki子系统,如网络层和应用层的代码。
3. 上位机评估软件:用于从PC向LoRa终端发送数据的工具,可能包含GUI界面和通信接口。
4. 编译脚本和构建工具:帮助用户编译和烧录固件到LoRa终端的工具。
5. 文档和说明:详细描述系统的使用方法、硬件连接和软件配置。
通过分析和理解这些源代码,开发者可以学习如何构建和优化LoRa点对点通信系统,掌握LoRa、STM8L151C8T6、SX1278和Contiki的相关知识,进一步开发出适用于各种应用场景的物联网解决方案。
RimeLink
- 粉丝: 2389
- 资源: 15
最新资源
- 基于STM32为电子香味项目,通过蓝牙模块传输数据,嵌入式硬件平台,RFID使用的是RC522.整个项目包括软硬件以及android程序详细文档+全部资料+高分项目+源码.zip
- 基于发布-订阅模型的多线程消息框架,用于嵌入式平台,纯C实现,性能和灵活性极高详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式Linux的一套可视对讲设备代码,比较底层,写的比较好,里面的lib库是一些图像处理库详细文档+全部资料+高分项目+源码.zip
- php 实现各种排序和查找算法源代码.zip
- 基于嵌入式qt的车载系统详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式的基础图形库详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式平台ARM Linux的新冠肺炎疫情监控平台详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式的视觉运动控制详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式综合项目:STM32F407基于ARM Cortex-M4处理器,云服务器Linux操作系统,MySQL数据存储转发详细文档+全部资料+高分项目+源码
- 基于热风控制系统嵌入式项目,基于STM32F1芯片和RT-Thread实时系统开发出温度闭环控制和风速控制详细文档+全部资料+高分项目+源码.zip
- 基于全志V3S的嵌入式开发者打怪升级项目详细文档+全部资料+高分项目+源码.zip
- 基于事件型嵌入式驱动框架。详细文档+全部资料+高分项目+源码.zip
- 基于使用B-Tree作为索引,基于MMap的嵌入式键值数据库详细文档+全部资料+高分项目+源码.zip
- 基于三个嵌入式的小项目:一个是基于科大讯飞的语音识别系统,一个是智能音乐相册,一个是别踩白块小游戏详细文档+全部资料+高分项目+源码.zip
- 基于物联网模式开发的嵌入式程序详细文档+全部资料+高分项目+源码.zip
- 基于以太网通信的电力电子设备运行状态的远程监控嵌入式系统设计详细文档+全部资料+高分项目+源码.zip
- 1
- 2
前往页