/********************************************************************* * INCLUDES */ #include "bsp_AiP650E.h" #include "debug_drv.h" /********************************************************************* * LOCAL VARIABLES */ u8 s_7number[10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; // 7段显示方式0~9 u8 s_8number[10] = {0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xEF}; // 8段显示方式0~9 /************************************************************* SYSOFF 4800 系统禁止,时钟振荡,不显示 √ SYSON 4801 系统使能,开启显示,按键,8 级亮度 SLEEPOFF 4800 睡眠禁止 SLEEPON 4804 睡眠使能,时钟停振 7SEG_ON 4809 系统使能,7 段显示 8SEG_ON 4801 系统使能,8 段显示,DP 作 SEG 显示驱动,8 级亮度 SYSON_1,8SEG_ON 4811 系统使能,8 段显示,1 级亮度 SYSON_2,8SEG_ON 4821 系统使能,8 段显示,2 级亮度 SYSON_3,8SEG_ON 4831 系统使能,8 段显示,3 级亮度 SYSON_4,8SEG_ON 4841 系统使能,8 段显示,4 级亮度 SYSON_5,8SEG_ON 4851 系统使能,8 段显示,5 级亮度 SYSON_6,8SEG_ON 4861 系统使能,8 段显示,6 级亮度 SYSON_7,8SEG_ON 4871 系统使能,8 段显示,7 级亮度 SYSON_8,8SEG_ON 4801 系统使能,8 段显示,8 级亮度 SYSON_1,7SEG_ON 4819 系统使能,7 段显示,1 级亮度 SYSON_2,7SEG_ON 4829 系统使能,7 段显示,2 级亮度 SYSON_3,7SEG_ON 4839 系统使能,7 段显示,3 级亮度 SYSON_4,7SEG_ON 4849 系统使能,7 段显示,4 级亮度 SYSON_5,7SEG_ON 4859 系统使能,7 段显示,5 级亮度 SYSON_6,7SEG_ON 4869 系统使能,7 段显示,6 级亮度 SYSON_7,7SEG_ON 4879 系统使能,7 段显示,7 级亮度 SYSON_8,7SEG_ON 4809 系统使能,7 段显示,8 级亮度 DIG0 68XX 写 DIG0 的 8 段显示数据,‘1’亮,‘0’暗。 DIG1 6AXX 写 DIG1 的 8 段显示数据,‘1’亮,‘0’暗。 DIG2 6CXX 写 DIG2 的 8 段显示数据,‘1’亮,‘0’暗。 DIG3 6EXX 写 DIG0 的 8 段显示数据,‘1’亮,‘0’暗。 GET_KEY 4F00 读取按键数据 |----------------------------------------------------------------| | led5 led1 led2 | ref | | | 88 88 88 | show | DIG56 DIG45 DIG23 | sch | 12 34 12 | ic | SEG_CLK2 SEG_CLK1 | | num12 num34 num56 | | | | ch2+ 12 ch1+34 ch1+12| | | -----------------------------------------------| | | | | | | | | | | | | |---------------| num ic,addr **************************************************/ u8 num_ic_addr[6][2]=////[行][列] { D_iicch_DIG2,0x68,////0 1, D_iicch_DIG2,0x6a,////1 2, D_iicch_DIG1,0x6c,////2 3, D_iicch_DIG1,0x6e,////3 4, D_iicch_DIG1,0x68,////4 5, D_iicch_DIG1,0x6a ////5 6, }; void L1_LEDSEG_init(void) { L0_IICMx_INIT(D_iicch_DIG1,1); L0_IICMx_INIT(D_iicch_DIG2,1); L0_IICMx_INIT(D_iicch_DIG4,1); L2_IICMx_Write1Reg(D_iicch_DIG1,0x68,0xff); L2_IICMx_Write1Reg(D_iicch_DIG1,0x6a,0xff); L2_IICMx_Write1Reg(D_iicch_DIG1,0x6c,0xff); L2_IICMx_Write1Reg(D_iicch_DIG1,0x6e,0xff); L2_IICMx_Write1Reg(D_iicch_DIG1,0x48,0x21); L2_IICMx_Write1Reg(D_iicch_DIG2,0x68,0xff); L2_IICMx_Write1Reg(D_iicch_DIG2,0x6a,0xff); // L2_IICMx_Write1Reg(D_iicch_DIG2,0x6c,0xff); // L2_IICMx_Write1Reg(D_iicch_DIG2,0x6e,0xff); L2_IICMx_Write1Reg(D_iicch_DIG2,0x48,0x21); /********* D_SEG_DIO2_INIT(); D_SEG_CLK2_INIT(); D_SEG_DIO1_INIT(); D_SEG_CLK1_INIT(); L0_LEDSEG1_SendData(0x68,0xff); L0_LEDSEG1_SendData(0x6a,0xff); L0_LEDSEG1_SendData(0x6c,0xff); L0_LEDSEG1_SendData(0x6e,0xff); L0_LEDSEG1_SendData(0x48,0x21); *******/ } void L0_LEDSEG1_SetNumber(uint8_t index, uint8_t mode, uint8_t num) { uint8_t numValue = 0; if(mode == 7) // 7段显示方式 { numValue = s_7number[num]; } else if(mode == 8) // 8段显示方式 { numValue = s_8number[num]; } /// printf("index:%02x, num:%02x\n", indexAddr, numValue); /// TM1650_Write(indexAddr, numValue); L2_IICMx_Write1Reg(num_ic_addr[index][0],num_ic_addr[index][1],numValue); } /******************** void L0_LEDSEG1_SendData(unsigned char H,unsigned char L ) { unsigned char ack=8; unsigned char BitCnt=8;//一字节8位 //设置SDA 口为输出 L0_LEDSEG1_SDA_OFF(); Lc_delay_us(2);///FIXme 移植的饿时候需要验证 L0_LEDSEG1_SCL_OFF(); Lc_delay_us(1); /// for(BitCnt = 0;BitCnt < 8;BitCnt ++) //要传送的数据长度为8位 { if((H << BitCnt ) & 0x80) { L0_LEDSEG1_SDA_ON(); //判断发送位 } else { L0_LEDSEG1_SDA_OFF(); } Lc_delay_us(1); L0_LEDSEG1_SCL_ON(); //置时钟线为高,通知被控器开始接收数据位 Lc_delay_us(1); L0_LEDSEG1_SCL_OFF(); Lc_delay_us(1); }//8clk L0_LEDSEG1_SDA_ON(); //8位发送完后释放数据线,准备接收应答位 L0_LEDSEG1_SCL_ON(); Lc_delay_us(1); ///gRccUs05 += L0_I2C_SDA_ask(); L0_LEDSEG1_SCL_OFF(); Lc_delay_us(1); for(BitCnt = 0;BitCnt < 8;BitCnt ++) //要传送的数据长度为8位 { if((L << BitCnt ) & 0x80) { L0_LEDSEG1_SDA_ON(); //判断发送位 } else { L0_LEDSEG1_SDA_OFF(); } Lc_delay_us(1); L0_LEDSEG1_SCL_ON(); //置时钟线为高,通知被控器开始接收数据位 Lc_delay_us(1); L0_LEDSEG1_SCL_OFF(); Lc_delay_us(1); }//8clk L0_LEDSEG1_SDA_ON(); //8位发送完后释放数据线,准备接收应答位 L0_LEDSEG1_SCL_ON(); Lc_delay_us(1); ///gRccUs05 += L0_I2C_SDA_ask(); L0_LEDSEG1_SCL_OFF(); Lc_delay_us(1); L0_LEDSEG1_SCL_ON(); Lc_delay_us(1); L0_LEDSEG1_SDA_ON(); Lc_delay_us(2);///FIXme 移植的饿时候需要验证 } ******************/ void L3_test_ledseg(u8 filter) { if(filter == pd->filter) {///filter num d1 d2 d3 ....dn //// FD 08 11 22 33 44 55 66 77 88 switch (pd->ocr) { case 0x11: printf("ch(%X):%X=%x ",(int)pd->R1,(int)pd->R2 ,(int)pd->R3); L2_IICMx_Write1Reg(pd->R1,pd->R2 ,pd->R3); /// L0_LEDSEG1_SendData(pd->R1 ,pd->R2); break; case 0x12: printf("num(%X):%X=%x ",(int)pd->R1,(int)pd->R2 ,(int)pd->R3); L0_LEDSEG1_SetNumber(pd->R1,pd->R2 ,pd->R3); ////F2 02 08 04 12 /// L0_LEDSEG1_SendData(pd->R1 ,pd->R2); break; default: printf(" pp error\r\n "); break; }; printf("333"); } } /** @brief 显示设置 @param brightness -[in] 亮度1~8级 @param mode -[in] 7/8段显示方式 @param state -[in] 开启/关闭显示 @return 无 void TM1650_SetDisplay(uint8_t brightness,uint8_t mode,uint8_t state) { if(state) { if(mode == 7) // 7段显示方式 { TM1650_Write(0x48, brightness*16 + 1*4 + 1); } else if(mode == 8) // 8段显示方式 { TM1650_Write(0x48, brightness*16 + 1); } } else { TM1650_Write(0x48, 0x00); // 关闭显示 } } @brief 显示数字 @param index -[in] 第几个数 @param mode -[in] 7/8段显示方式 @param num -[in] 显示数 @return 无 void TM1650_SetNumber(uint8_t index, uint8_t mode, uint8_t num) { uint8_t indexAddr = 0; uint8_t numValue = 0; if(index == 1) { indexAddr = 0x68; } else if(index == 2) { indexAddr = 0x6A; } else if(index == 3) { indexAddr = 0x6C; } else if(index == 4) { indexAddr = 0x6E; } if(mode == 7) // 7段显示方式 { numValue = s_7number[num]; } else if(mode == 8) // 8段显示方式 { numValue = s_8number[num]; } printf("index:%02x, num:%02x\n", indexAddr, numValue); TM1650_Write(indexAddr, numValue); } *************/ /****************************************************END OF FILE****************************************************/