DOGS102x6_DRAW_NORMAL);
Dogs102x6_charDraw(7,0,ptr0[0],DOGS102x6_DRAW_NORMAL);//将一个字符写入确定行列的LCD液晶显示屏上
Dogs102x6_charDraw(7,6,ptr0[1],DOGS102x6_DRAW_NORMAL);//将一个字符写入确定行列的LCD液晶显示屏上
Dogs102x6_charDraw(7,12,ptr0[2],DOGS102x6_DRAW_NORMAL);//将一个字符写入确定行列的LCD液晶显示屏上
Dogs102x6_charDraw(7,18,ptr0[3],DOGS102x6_DRAW_NORMAL);//将一个字符写入确定行列的LCD液晶显示屏上
Dogs102x6_charDraw(7,24,ptr0[4],DOGS102x6_DRAW_NORMAL);//将一个字符写入确定行列的LCD液晶显示屏上 break; //
case 5: break; // default: break; } }
/**sub functions**/
externcharspi_readByte( uint8_taddr, uint8_t * data) {
rxlen = 1;
rxbuf = data;
txaddr = addr | 0x80;
P2OUT &= ~BIT0;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = txaddr;
while (!(UCB0IFG&UCTXIFG));
UCB0TXBUF = 0;
while (UCB0STAT & UCBUSY); * rxbuf = UCB0RXBUF;
while (UCB0STAT & UCBUSY); P2OUT |= BIT0;
return 0; }
externcharspi_readWord(uint8_taddr, unsignedint * data) {
rxlen = 2;
rxbuf = &wordbuf[0]; txaddr = addr | 0x80;
P2OUT &= ~BIT0;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = txaddr;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = 0;
while (UCB0STAT & UCBUSY); * rxbuf = UCB0RXBUF; rxbuf++;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = 0;
while (UCB0STAT & UCBUSY); * rxbuf = UCB0RXBUF;
while (UCB0STAT & UCBUSY); P2OUT |= BIT0;
return 0;
}
externcharspi_readBytes( uint8_taddr, uint8_t * buffer, uint8_tlen) {
rxlen = len; rxbuf = buffer;
txaddr = addr | 0x80;
P2OUT &= ~BIT0;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = txaddr;
while (rxlen> 0) {
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = 0;
while (UCB0STAT & UCBUSY); * rxbuf = UCB0RXBUF; rxbuf++; rxlen--; }
while (UCB0STAT & UCBUSY); P2OUT |= BIT0;
return 0; }
externcharspi_writeByte(uint8_taddr, uint8_t data) {
wordbuf[0] = data; // copy from stack to memory txlen = 1;
txbuf = &wordbuf[0]; txaddr = addr& ~0x80;
P2OUT &= ~BIT0;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = txaddr;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = *txbuf;
while (UCB0STAT & UCBUSY); P2OUT |= BIT0;
return 0; }
externcharspi_writeWord(uint8_taddr, unsignedint data) {
wordbuf[0] = data >> 8; // Big Endian wordbuf[1] = data & 0xFF; txlen = 2;
txbuf = &wordbuf[0]; txaddr = addr& ~0x80;
P2OUT &= ~BIT0;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = txaddr;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = *txbuf; txbuf++;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = *txbuf;
while (UCB0STAT & UCBUSY); P2OUT |= BIT0;
return 0;
}
externcharspi_writeBytes( uint8_t addr,uint8_t * buffer, uint8_tlen) {
txlen = len; txbuf = buffer;
txaddr = addr& ~0x80;
P2OUT &= ~BIT0;
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = txaddr;
while (txlen> 0) {
while (!(UCB0IFG&UCTXIFG)); UCB0TXBUF = *txbuf; txbuf++; txlen--; }
while (UCB0STAT & UCBUSY); P2OUT |= BIT0;
return 0; }
//////////////////////////////////////步进电////////////////////////////////////////////// //延时n*0.5ms //P4口延时函数
voiddelay_nms1(unsignedint n)
机程序