📄 ad8400.c
字号:
///////////////////////////////////////////////////////////////////////////
//// Library for a AD8400 ////
//// ////
//// init_pots (); Sets all of the pots to 0 ////
//// ////
//// set_pot (pot_num, new_value); Sets pot pot_num to new_value ////
//// ////
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#define RST1 PIN_B0
#define CLK PIN_B1
#define DI PIN_B2
#define NUM_POTS 1
BYTE pots;
set_pot (int pot_num, int new_value) {
BYTE i;
BYTE cmd[2];
pots = new_value;
cmd[0] = pots;
cmd[1] = 0;
for(i=1;i<=6;i++)
shift_left(cmd,2,0);
output_low(CLK);
output_low(RST1);
delay_us(2);
for(i=1;i<=10;++i) {
output_bit(DI, shift_left(cmd,2,0));
delay_us(2);
output_high(CLK);
delay_us(2);
output_low(CLK);
delay_us(2);
}
output_high(RST1);
}
void init_pots ()
{
pots = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -