• 大小: 87.49MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2022-07-13
  • 语言: 其他
  • 标签: 蓝桥杯  嵌入式  

资源简介

蓝桥杯嵌入式考试时,官方会提供给参赛者的数据包,分享出来,供大家参考

资源截图

代码片段和文件信息

/*
  程序说明: CT117E嵌入式竞赛板GPIO模拟I2C总线驱动程序
  软件环境: Keil uVision 4.10 
  硬件环境: CT117E嵌入式竞赛板
  日    期: 2011-8-9
*/

#include “stm32f10x.h“

/** I2C 总线接口 */
#define I2C_PORT GPIOB
#define SDA_Pin GPIO_Pin_7
#define SCL_Pin GPIO_Pin_6

#define FAILURE 0
#define SUCCESS 1

//配置SDA信号线为输入模式
void SDA_Input_Mode()
{
GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = SDA_Pin;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;  

   GPIO_Init(I2C_PORT &GPIO_InitStructure);
}

//配置SDA信号线为输出模式
void SDA_Output_Mode()
{
GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = SDA_Pin;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

   GPIO_Init(I2C_PORT &GPIO_InitStructure);
}

//
void SDA_Output( uint16_t val )
{
if ( val ) {
GPIO_SetBits(I2C_PORTSDA_Pin);
} else {
GPIO_ResetBits(I2C_PORTSDA_Pin);
}
}

//
void SCL_Output( uint16_t val )
{
if ( val ) {
GPIO_SetBits(I2C_PORTSCL_Pin);
} else {
GPIO_ResetBits(I2C_PORTSCL_Pin);
}
}

//
uint8_t SDA_Input()
{
return GPIO_ReadInputDataBit( I2C_PORT SDA_Pin);
}

//延时程序
void delay1(unsigned int n)
{
unsigned int i;
for ( i=0;i}

//I2C总线启动
void I2CStart(void)
{
SDA_Output(1);delay1(500);
SCL_Output(1);delay1(500);
SDA_Output(0);delay1(500);
SCL_Output(0);delay1(500);
}

//I2C总线停止
void I2CStop(void)
{
SCL_Output(0); delay1(500);
SDA_Output(0); delay1(500);
SCL_Output(1); delay1(500);
SDA_Output(1); delay1(500);

}

//等待应答
unsigned char I2CWaitAck(void)
{
unsigned short cErrTime = 5;
SDA_Input_Mode(); 
delay1(500);
SCL_Output(1);delay1(500);
while(SDA_Input())
{
cErrTime--;
delay1(500);
if (0 == cErrTime)
{
SDA_Output_Mode();
I2CStop();
return FAILURE;
}
}
SDA_Output_Mode();
SCL_Output(0);delay1(500); 
return SUCCESS;
}

//发送应答位
void I2CSendAck(void)
{
SDA_Output(0);delay1(500);
delay1(500);
SCL_Output(1); delay1(500);
SCL_Output(0); delay1(500);

}

//
void I2CSendNotAck(void)
{
SDA_Output(1);
delay1(500);
SCL_Output(1); delay1(500);
SCL_Output(0); delay1(500);

}

//通过I2C总线发送一个字节数据
void I2CSendByte(unsigned char cSendByte)
{
unsigned char  i = 8;
while (i--)
{
SCL_Output(0);delay1(500); 
SDA_Output(cSendByte & 0x80); delay1(500);
cSendByte += cSendByte;
delay1(500); 
SCL_Output(1);delay1(500); 
}
SCL_Output(0);delay1(500); 
}

//从I2C总线接收一个字节数据
unsigned char I2CReceiveByte(void)
{
unsigned char i = 8;
unsigned char cR_Byte = 0;
SDA_Input_Mode(); 
while (i--)
{
cR_Byte += cR_Byte;
SCL_Output(0);delay1(500); 
delay1(500); 
SCL_Output(1);delay1(500); 
cR_Byte |=  SDA_Input(); 
}
SCL_Output(0);delay1(500); 
SDA_Output_Mode();
return cR_Byte;
}

//I2C总线初始化
void i2c_init()
{
GPIO_InitTypeDef GPIO_InitStructure;


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     486344  2013-12-03 09:54  蓝桥杯嵌入式\嵌入式设计与开发\CT117E嵌入式竞赛板使用说明-V1.1.pdf

     文件     203942  2013-12-03 10:57  蓝桥杯嵌入式\嵌入式设计与开发\CT117E电路原理图.pdf

     文件       3382  2012-09-04 11:32  蓝桥杯嵌入式\嵌入式设计与开发\I2C参考程序\i2c.c

     文件        316  2012-09-04 11:32  蓝桥杯嵌入式\嵌入式设计与开发\I2C参考程序\i2c.h

     文件      17273  2010-06-07 10:25  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport\core_cm3.c

     文件      85714  2011-02-09 14:59  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport\core_cm3.h

     文件      26297  2011-03-14 12:31  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\Release_Notes.html

     文件      15766  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_cl.s

     文件      15503  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_hd.s

     文件      15692  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_hd_vl.s

     文件      12376  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_ld.s

     文件      13656  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_ld_vl.s

     文件      12765  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_md.s

     文件      14073  2011-03-10 10:51  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_md_vl.s

     文件      15955  2011-03-10 10:51  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm\startup_stm32f10x_xl.s

     文件      13072  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_cl.s

     文件      13160  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_hd.s

     文件      12482  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_hd_vl.s

     文件       9814  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_ld.s

     文件      10562  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_ld_vl.s

     文件      10269  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_md.s

     文件      11058  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_md_vl.s

     文件      13261  2011-03-10 10:52  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\gcc_ride7\startup_stm32f10x_xl.s

     文件      16626  2011-03-10 10:53  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_cl.s

     文件      16229  2011-03-10 10:53  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_hd.s

     文件      15675  2011-03-10 10:53  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_hd_vl.s

     文件      12650  2011-03-10 10:53  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_ld.s

     文件      12950  2011-03-10 10:53  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_ld_vl.s

     文件      12912  2011-03-10 10:53  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_md.s

     文件      13601  2011-03-10 10:53  蓝桥杯嵌入式\嵌入式设计与开发\STM32固件库v3.5\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_md_vl.s

............此处省略1381个文件信息

评论

共有 条评论