|
本帖最后由 qiushenghua 于 2015-9-29 00:40 编辑
- #include "msp430x14x.h"
- #include "nrf24l01.h"
- #include "PORT.h"
- void SPI_CP1306(unsigned char byte_a,unsigned char byte_b);
- void SPI_CP1306_Reg(unsigned char reg,unsigned char value);
- #define BCLK BIT2 //P4.2
- #define SYNC_PCM BIT3 //P4.3
- #define PCMSO BIT4 //P4.4
- #define ADPCMSO BIT5 //P4.5
- #define ADPCMRI BIT6 //P4.6
- #define PCMRI BIT7 //P4.7
- #define CSN_PCM BIT0 //P5.0
- #define DCLK_PCM BIT1 //P5.1
- #define DIN_PCM BIT2 //P5.2
- #define DOUT_PCM BIT3 //P5.3
- #define RST_PCM BIT4 //P5.4
- #define POWER_PCM BIT5 //P5.5
- //==============================================================================
- void SPI_CP1306(unsigned char byte_a,unsigned char byte_b)
- {
- unsigned char i;
-
- P5OUT &= ~DIN_PCM;
- P5OUT |= DCLK_PCM;
- P5OUT &= ~DCLK_PCM;
-
- byte_a<<5;
- for(i=0;i<3;i++)
- {
- if(byte_a&0x80)
- P5OUT |= DIN_PCM;
- else
- P5OUT &= ~DIN_PCM;
- byte_a = (byte_a<<1);
- P5OUT |= DCLK_PCM;
- P5OUT &= ~DCLK_PCM;
- }
- for(i=0;i<8;i++)
- {
- if(byte_b&0x80)
- P5OUT |= DIN_PCM;
- else
- P5OUT &= ~DIN_PCM;
- byte_b = (byte_b<<1);
- P5OUT |= DCLK_PCM;
- P5OUT &= ~DCLK_PCM;
- }
- }
- void SPI_CP1306_Reg(unsigned char reg,unsigned char value)
- {
- unsigned char status;
-
- P5OUT &= ~CSN_PCM;
- SPI_CP1306(0x00,0x20);
- P5OUT |= CSN_PCM;
-
- P5OUT &= ~CSN_PCM;
- SPI_CP1306(0x01,0x00);
- P5OUT |= CSN_PCM;
- }
复制代码
|
|