595驱动

This commit is contained in:
2021-09-17 23:08:12 +08:00
parent 0058af14cd
commit 12016bd7bc
5 changed files with 415 additions and 177 deletions
+48
View File
@@ -6,8 +6,56 @@
*/
#include "my_main.h"
#define HC595_DCK(x) HAL_GPIO_WritePin(HC595_DCK_GPIO_Port, HC595_DCK_Pin, x);
#define HC595_RCK(x) HAL_GPIO_WritePin(HC595_RCK_GPIO_Port, HC595_RCK_Pin, x);
#define HC595_SCK(x) HAL_GPIO_WritePin(HC595_SCK_GPIO_Port, HC595_SCK_Pin, x);
#define MOTA(x) HAL_GPIO_WritePin(MOTA_GPIO_Port, MOTA_Pin, x);
#define MOTB(x) HAL_GPIO_WritePin(MOTB_GPIO_Port, MOTB_Pin, x);
void Send_to_595(char h,char l)
{
for(int a=0;a<8;a++)
{
if((h<<a)&0x80)
{
HC595_DCK(1);
}else
{
HC595_DCK(0);
}
HC595_SCK(1);
HC595_SCK(0);
}
for(int a=0;a<8;a++)
{
if((l<<a)&0x80)
{
HC595_DCK(1);
}else
{
HC595_DCK(0);
}
HC595_SCK(1);
HC595_SCK(0);
}
HC595_RCK(1);
HC595_RCK(0);
}
void mymain()
{
MOTA(0);
MOTB(0);
HC595_DCK(0);
HC595_RCK(0);
HC595_SCK(0);
Send_to_595(0x00,0x00);
while(1)
{