中级会员
 
- 积分
- 233
- 金钱
- 233
- 注册时间
- 2014-4-29
- 在线时间
- 6 小时
|
5金钱
.h文件中
#ifndef __TLC5615__H
#define __TLC5615__H
#define din PBout(0);
#define sclk PBout(1);
#define cs PBout(2);
void tlc5615_init(void);
void tlc5615_exchange(u8 datevalue);
#endif
.c文件中的程序
#include"stm32f10x.h"
#include"includes.h"
#include"tlc5615.h"
void tlc5615_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
void tlc5615_exchange(u8 datevalue)
{
u8 i;
sclk = 0;
cs = 0;
for(i = 0; i<12; i++)
{
din = datevalue&0x800;
sclk = 1;
datevalue = datevalue<<1;
sclk = 0;
}
cs = 1;
}
总是报错说那几个宏定义的变量 din,sclk,cs使用错误呢?
|
最佳答案
查看完整内容[请看2#楼]
看来楼主最基本的调试语法错误的功力还木有。
#define din Bout(0)
#define sclk Bout(1)
#define cs Bout(2)
|