void SystemObj::McBSP1Init(void)//SPI配置 { McBSP1->SPSA = SPCR1; McBSP1->SPSD = 0; // McBSP1->SPSD &= ~(1 << SPCR1_RRST);//禁止串口接收 __nop(); __nop(); McBSP1->SPSA = SPCR2; McBSP1->SPSD = 0; // McBSP1->SPSD &= ~(1 << SPCR2_XRST);//禁止串口发送 __nop(); __nop(); McBSP1->SPSA = SPCR1; McBSP1->SPSD = (0x03 << SPCR1_CLKSTP);//CLKSTP=11b __nop(); __nop(); McBSP1->SPSA = PCR; // McBSP1->SPSD = (1 << PCR_FSXM) | (1 << PCR_CLKXM)\ // | (1 << PCR_FSXP) | (1 << PCR_CLKXP);//CLKXP=1,SS=1 McBSP1->SPSD = (1 << PCR_FSXM) | (1 << PCR_CLKXM)\ | (0 << PCR_FSXP) | (1 << PCR_CLKXP);//CLKXP=1,SS=0 __nop(); __nop(); McBSP1->SPSA = SRGR1; McBSP1->SPSD = (0x07 << SRGR1_FWID) | (0x80 << SRGR1_CLKGDV); __nop(); __nop(); McBSP1->SPSA = SRGR2; McBSP1->SPSD = (1 << SRGR2_CLKSM); __nop(); __nop(); McBSP1->SPSA = RCR1; McBSP1->SPSD = (0x00 << RCR1_RFRLEN1);//8BIT __nop(); __nop(); McBSP1->SPSA = XCR1; McBSP1->SPSD = (0x00 << XCR1_RFRLEN1);//BIT __nop(); __nop(); McBSP1->SPSA = RCR2; McBSP1->SPSD = (0x01 << RCR2_RDATDLY); __nop(); __nop(); McBSP1->SPSA = XCR2; McBSP1->SPSD = (0x01 << XCR2_RDATDLY); __nop(); __nop(); McBSP1->SPSA = SPCR2; McBSP1->SPSD |= (1 << SPCR2_GRST) | (1 << SPCR2_XRST) | (1 << SPCR2_FRST); __nop(); __nop(); } void LedObj::LedDisplay(unsigned char cData) { static const unsigned char LedTab[] = { ~LedChar0, ~LedChar1, ~LedChar2, ~LedChar3, ~LedChar4, ~LedChar5, ~LedChar6, ~LedChar7, ~LedChar8, ~LedChar9, ~LedCharA, ~LedCharB, ~LedCharC, ~LedCharD, ~LedCharE, ~LedCharF }; cData = LedTab[cData & 0xff]; McBSP1->DXR1 = cData & 0xff;//向595发送串行数据 __nop(); __nop(); McBSP1->SPSA = SPCR2; while((McBSP1->SPSD & (1 << SPCR2_XRDY)) == 0) { __nop(); __nop(); } } |
文章评论(0条评论)
登录后参与讨论