资源简介
使用STM32F103ZET6单片机,KEIL5编译环境,包括IIC和SPI的驱动的.C和.H文件,亲测可用,希望能帮到你。
代码片段和文件信息
/******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
* File Name : LIS3DH_driver.c
* Author : MSH Application Team
* Author : Fabio Tota
* Version : $Revision:$
* Date : $Date:$
* Description : LIS3DH driver file
*
* HISTORY:
* Date | Modification | Author
* 24/06/2011 | Initial Revision | Fabio Tota
* 11/06/2012 | Support for multiple drivers in the same program | Abhishek Anand
********************************************************************************
* 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.
*
* THIS SOFTWARE IS SPECIFICALLY DESIGNED FOR EXCLUSIVE USE WITH ST PARTS.
*
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include “lis3dh_driver.h“
#include “delay.h“
#include “usart.h“
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
//int main(void)
//{
// delay_init(); //延时函数初始化
// uart_init(115200); //串口初始化为115200
// IIC2_Init();
// delay_ms(100);
// while(1)
// {
// LIS3DH_Data_Init();
// delay_ms(1000);
// }
//
//}
//OLED初始化IIC
void IIC2_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB ENABLE ); //使能GPIOB时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB &GPIO_InitStructure);
GPIO_SetBits(GPIOBGPIO_Pin_10|GPIO_Pin_11); //PB6PB7 输出高
}
void LIS3DH_Data_Init()
{
//uint8_t buffer[26];
AxesRaw_t data;
uint8_t lisidresponse;
uint8_t lisidtemp;
//set ODR (turn ON device)
LIS3DH_SetODR(LIS3DH_ODR_100Hz);
//set PowerMode
LIS3DH_SetMode(LIS3DH_NORMAL);
//set Fullscale
LIS3DH_SetFullScale(LIS3DH_FULLSCALE_2);
//set axis Enable
LIS3DH_SetAxis(LIS3DH_X_ENABLE | LIS3DH_Y_ENABLE | LIS3DH_Z_ENABLE);
// Read ID
LIS3DH_GetWHO_AM_I(&lisidtemp);
lisid=(uint16_t)lisidtemp;
printf(“LIS3D
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 57151 2018-12-11 12:38 LIS3DH驱动和相关资料\IIC\lis3dh_driver.c
文件 22224 2018-12-09 08:41 LIS3DH驱动和相关资料\IIC\lis3dh_driver.h
文件 5560964 2018-03-08 09:06 LIS3DH驱动和相关资料\LIS3DH 资料_完整例程_手册_电路等.rar
文件 56201 2018-12-13 19:09 LIS3DH驱动和相关资料\SPI\lis3dh_driver_spi.c
文件 21889 2018-12-13 17:22 LIS3DH驱动和相关资料\SPI\lis3dh_driver_spi.h
目录 0 2018-12-13 19:10 LIS3DH驱动和相关资料\IIC
目录 0 2018-12-13 19:10 LIS3DH驱动和相关资料\SPI
目录 0 2018-12-13 19:08 LIS3DH驱动和相关资料
----------- --------- ---------- ----- ----
5718429 8
- 上一篇:UCI数据集55个
- 下一篇:医院设备科管理系统解决方案.doc
评论
共有 条评论