手头上有一个项目需要用到MBI5043芯片,但是我对照数据手册的时序图写的时候,为啥没有想要的输出?以下是我的代码void MBI5043_init(void)
{
nrf_gpio_cfg_output(LED_PWR);
nrf_gpio_cfg_output(MBI5043_SDI_PIN);
nrf_gpio_cfg_output(MBI5043_DCLK_PIN);
nrf_gpio_cfg_output(MBI5043_LED_R_LE_PIN);
nrf_gpio_cfg_output(MBI5043_LED_R_GCLK_PIN);
nrf_gpio_cfg_output(MBI5043_LED_Y_LE_PIN);
nrf_gpio_cfg_output(MBI5043_LED_Y_GCLK_PIN);
nrf_gpio_pin_clear(MBI5043_SDI_PIN);
nrf_gpio_pin_clear(MBI5043_DCLK_PIN);
nrf_gpio_pin_clear(MBI5043_LED_R_LE_PIN);
nrf_gpio_pin_clear(MBI5043_LED_R_GCLK_PIN);
nrf_gpio_pin_clear(MBI5043_LED_Y_LE_PIN);
nrf_gpio_pin_clear(MBI5043_LED_Y_GCLK_PIN);
}
static void MBI5043_Data_Lock(uint16_t data)
{
for(uint8_t i = 0;i < 16;i++)
{
if(data & 0x8000)
{
MBI5043_SDI_SET();
}
else
{
MBI5043_SDI_RESET();
}
if(i == 15)
{
MBI5043_LED_R_LE_SET();
MBI5043_DCLK_SET();
MBI5043_DCLK_RESET();
MBI5043_LED_R_LE_RESET();
}
else
{
MBI5043_DCLK_SET();
data=data<<1;
MBI5043_DCLK_RESET();
}
}
}
static void MBI5043_Global_Lock()
{
for(uint8_t i = 0;i < 13;i++)
{
MBI5043_SDI_RESET();
MBI5043_DCLK_RESET();
MBI5043_DCLK_SET();
}
MBI5043_LED_R_LE_SET();
for(uint8_t i = 0;i < 3;i++)
{
MBI5043_SDI_RESET();
MBI5043_DCLK_RESET();
MBI5043_DCLK_SET();
}
MBI5043_LED_R_LE_RESET();
}
void set(void)
{
for(uint8_t i = 0;i < 16;i++)
{
MBI5043_Data_Lock(0x5555);
}
MBI5043_Global_Lock();
nrf_gpio_pin_set(LED_PWR);
}
int main(void)
{
MBI5043_init();
for (;;)
{
//my_fw_sched_execute();
//power_manage();
set();
nrf_delay_ms(500);
}
}
|