void RF_SPI_MasterIO(unsigned char out) {
unsigned char i;
for (i = 0; i < 8; i++) {
if (out & 0x80) /* check if MSB is high */
RF_SDI_H;
else
RF_SDI_L; /* if not, set to low */
RF_CKL_H; /* toggle clock high */
out = (out << 1); /* shift 1 place for next bit */
RF_CKL_L; /* toggle clock low */
}
}
unsigned char RF_SPI_READ_BYTE() {
unsigned char j;
unsigned char i;
j = 0;
for (i = 0; i < 8; i++) {
RF_CKL_H;
j = (j << 1); // shift 1 place to the left or shift in 0 //
if ( SX1278_SDO) // check to see if bit is high //
j = j | 0x01; // if high, make bit high //
// toggle clock high //
RF_CKL_L; // toggle clock low //
}
/*
function:set sx1278 work mode ,here you can control the mode which is send or recieve
parm:
*/
void SX1276LoRaSetOpMode(RFMode_SET opMode) {
unsigned char opModePrev;
opModePrev = SX1276ReadBuffer(REG_LR_OPMODE);
opModePrev &= 0xf8;
opModePrev |= (unsigned char) opMode;
SX1276WriteBuffer( REG_LR_OPMODE, opModePrev);
}