在线时间132 小时
UID372360
ROHM金币152
注册时间2018-5-2
该用户从未签到
金牌会员
- 最后登录
- 2024-4-10
|
- #include "stm32f10x.h"
- #include "DRV_595.h"
- /*----------*/
- void Delay(unsigned int usData)
- {
- unsigned int i=0,j=0;
- for(i=0;i<usData;i++)
- for(j=0;j<72;j++);
- }
- /*---------------------------*/
- void IO_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5| GPIO_Pin_6| GPIO_Pin_7;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- GPIO_SetBits(GPIOA, GPIO_Pin_4 | GPIO_Pin_5|GPIO_Pin_6 |GPIO_Pin_7 ); // turn off all led
- }
- //--
- void WriteBite(unsigned char Data)
- {
- unsigned char i=0;
- for(i=0;i<8;i++)
- {
- SCLK_L;//--时钟底
- if((Data&Bit(i))!=0)
- {
- S_Data_H;
- }
- else
- {
- S_Data_L;
- }
- Delay(4);
- SCLK_H;//--上升沿采集数据---
- CS_H;
- Delay(4);
- CS_L;
- }
- SCLK_L;//--时钟底
- CS_L;
- }
- /*---写字符串-----*/
- void WriteStr(unsigned char *Buf,unsigned char Len)
- {
- int i=0;
- for(i=0;i<Len;i++)
- {
- WriteBite(*(Buf+i));
- }
- }
- /*----------------------------------------- end of the files ---------------------------------------*/
复制代码
|
|