Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tobi #79

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Tobi #79

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 78 additions & 1 deletion SFUsat/sfu_smartrf_cc1101.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ typedef struct {
#define SMARTRF_SETTING_RCCTRL0_STATUS_ADDR 0x003D


// TX
// Lower Band
#define SMARTRF_SETTING_IOCFG2_VAL_TX 0x1C // on for 3.58us, set HW 1. GDO2 is stuck, no matter the setting a single 35us pulse occures per task cycle
#define SMARTRF_SETTING_IOCFG1_VAL_TX 0x2E
#define SMARTRF_SETTING_IOCFG0_VAL_TX 0x01 // assert when rf fifo is filled above threshold or end of packet is reached, deassert when fifo is emtpy
Expand Down Expand Up @@ -168,4 +168,81 @@ typedef struct {
#define SMARTRF_SETTING_RCCTRL1_STATUS_VAL_TX 0x00
#define SMARTRF_SETTING_RCCTRL0_STATUS_VAL_TX 0x00

//Upper Band
//# Modulation Format = 2-FSK
//# PA Ramping = false
//# Packet Length = 62
//# Packet Length Mode = Fixed packet length mode. Length configured in PKTLEN register
//# no CRC
//# Preamble Count = 4
//# RX Filter BW = 58.035714
//# Sync Word Qualifier Mode = 30/32 sync word bits detected
//# TX Power = 0
//# Whitening = false
//# ---------------------------------------------------
//# Packet sniffer stttings for CC1101 Upper band 790Mhz
//# ---------------------------------------------------
#define SMARTRF_SETTING_IOCFG2_VAL_UB 0x1C
#define SMARTRF_SETTING_IOCFG1_VAL_UB 0x2E
#define SMARTRF_SETTING_IOCFG0_VAL_UB 0x06
#define SMARTRF_SETTING_FIFOTHR_VAL_UB 0x47
#define SMARTRF_SETTING_SYNC1_VAL_UB 0xD3
#define SMARTRF_SETTING_SYNC0_VAL_UB 0x91
#define SMARTRF_SETTING_PKTLEN_VAL_UB 0x37
#define SMARTRF_SETTING_PKTCTRL1_VAL_UB 0x00
#define SMARTRF_SETTING_PKTCTRL0_VAL_UB 0x00
#define SMARTRF_SETTING_ADDR_VAL_UB 0x00
#define SMARTRF_SETTING_CHANNR_VAL_UB 0x00
#define SMARTRF_SETTING_FSCTRL1_VAL_UB 0x06
#define SMARTRF_SETTING_FSCTRL0_VAL_UB 0x00
#define SMARTRF_SETTING_FREQ2_VAL_UB 0x1E
#define SMARTRF_SETTING_FREQ1_VAL_UB 0x62
#define SMARTRF_SETTING_FREQ0_VAL_UB 0x76
#define SMARTRF_SETTING_MDMCFG4_VAL_UB 0xF5
#define SMARTRF_SETTING_MDMCFG3_VAL_UB 0x83
#define SMARTRF_SETTING_MDMCFG2_VAL_UB 0x03
#define SMARTRF_SETTING_MDMCFG1_VAL_UB 0x22
#define SMARTRF_SETTING_MDMCFG0_VAL_UB 0xF8
#define SMARTRF_SETTING_DEVIATN_VAL_UB 0x15
#define SMARTRF_SETTING_MCSM2_VAL_UB 0x07
#define SMARTRF_SETTING_MCSM1_VAL_UB 0x30
#define SMARTRF_SETTING_MCSM0_VAL_UB 0x18
#define SMARTRF_SETTING_FOCCFG_VAL_UB 0x16
#define SMARTRF_SETTING_BSCFG_VAL_UB 0x6C
#define SMARTRF_SETTING_AGCCTRL2_VAL_UB 0x03
#define SMARTRF_SETTING_AGCCTRL1_VAL_UB 0x40
#define SMARTRF_SETTING_AGCCTRL0_VAL_UB 0x91
#define SMARTRF_SETTING_WOREVT1_VAL_UB 0x87
#define SMARTRF_SETTING_WOREVT0_VAL_UB 0x6B
#define SMARTRF_SETTING_WORCTRL_VAL_UB 0xFB
#define SMARTRF_SETTING_FREND1_VAL_UB 0x56
#define SMARTRF_SETTING_FREND0_VAL_UB 0x10
#define SMARTRF_SETTING_FSCAL3_VAL_UB 0xE9
#define SMARTRF_SETTING_FSCAL2_VAL_UB 0x2A
#define SMARTRF_SETTING_FSCAL1_VAL_UB 0x00
#define SMARTRF_SETTING_FSCAL0_VAL_UB 0x1F
#define SMARTRF_SETTING_RCCTRL1_VAL_UB 0x41
#define SMARTRF_SETTING_RCCTRL0_VAL_UB 0x00
#define SMARTRF_SETTING_FSTEST_VAL_UB 0x59
#define SMARTRF_SETTING_PTEST_VAL_UB 0x7F
#define SMARTRF_SETTING_AGCTEST_VAL_UB 0x3F
#define SMARTRF_SETTING_TEST2_VAL_UB 0x81
#define SMARTRF_SETTING_TEST1_VAL_UB 0x35
#define SMARTRF_SETTING_TEST0_VAL_UB 0x0B
#define SMARTRF_SETTING_PARTNUM_VAL_UB 0x00
#define SMARTRF_SETTING_VERSION_VAL_UB 0x04
#define SMARTRF_SETTING_FREQEST_VAL_UB 0x00
#define SMARTRF_SETTING_LQI_VAL_UB 0x00
#define SMARTRF_SETTING_RSSI_VAL_UB 0x00
#define SMARTRF_SETTING_MARCSTATE_VAL_UB 0x00
#define SMARTRF_SETTING_WORTIME1_VAL_UB 0x00
#define SMARTRF_SETTING_WORTIME0_VAL_UB 0x00
#define SMARTRF_SETTING_PKTSTATUS_VAL_UB 0x00
#define SMARTRF_SETTING_VCO_VC_DAC_VAL_UB 0x00
#define SMARTRF_SETTING_TXBYTES_VAL_UB 0x00
#define SMARTRF_SETTING_RXBYTES_VAL_UB 0x00
#define SMARTRF_SETTING_RCCTRL1_STATUS_VAL_UB 0x00
#define SMARTRF_SETTING_RCCTRL0_STATUS_VAL_UB 0x00


#endif /* SFUSAT_SFU_SMARTRF_CC1101_H_ */
97 changes: 91 additions & 6 deletions SFUsat/sfu_task_radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,41 @@ const uint16 SMARTRF_VALS_TX[NUM_CONFIG_REGISTERS] = {
[TEST0] = SMARTRF_SETTING_TEST0_VAL_TX
};

const uint16 SMARTRF_VALS_UB[NUM_CONFIG_REGISTERS] = {
[IOCFG0] = SMARTRF_SETTING_IOCFG0_VAL_UB,
[IOCFG1] = SMARTRF_SETTING_IOCFG1_VAL_UB,
[IOCFG2] = SMARTRF_SETTING_IOCFG2_VAL_UB,
[FIFOTHR] = SMARTRF_SETTING_FIFOTHR_VAL_UB,
[SYNC1] = SMARTRF_SETTING_SYNC1_VAL_UB,
[SYNC0] = SMARTRF_SETTING_SYNC0_VAL_UB,
[PKTLEN] = SMARTRF_SETTING_PKTLEN_VAL_UB,
[PKTCTRL1] = SMARTRF_SETTING_PKTCTRL1_VAL_UB,
[PKTCTRL0] = SMARTRF_SETTING_PKTCTRL0_VAL_UB,
[FSCTRL1] = SMARTRF_SETTING_FSCTRL1_VAL_UB,
[FREQ2] = SMARTRF_SETTING_FREQ2_VAL_UB,
[FREQ1] = SMARTRF_SETTING_FREQ1_VAL_UB,
[FREQ0] = SMARTRF_SETTING_FREQ0_VAL_UB,
[MDMCFG4] = SMARTRF_SETTING_MDMCFG4_VAL_UB,
[MDMCFG3] = SMARTRF_SETTING_MDMCFG3_VAL_UB,
[MDMCFG2] = SMARTRF_SETTING_MDMCFG2_VAL_UB,
[MDMCFG1] = SMARTRF_SETTING_MDMCFG1_VAL_UB,
[MDMCFG0] = SMARTRF_SETTING_MDMCFG0_VAL_UB,
[DEVIATN] = SMARTRF_SETTING_DEVIATN_VAL_UB,
[MCSM1] = SMARTRF_SETTING_MCSM1_VAL_UB,
[MCSM0] = SMARTRF_SETTING_MCSM0_VAL_UB,
[FOCCFG] = SMARTRF_SETTING_FOCCFG_VAL_UB,
[AGCCTRL2] = SMARTRF_SETTING_AGCCTRL2_VAL_UB,
[AGCCTRL1] = SMARTRF_SETTING_AGCCTRL1_VAL_UB,
[WORCTRL] = SMARTRF_SETTING_WORCTRL_VAL_UB,
[FSCAL3] = SMARTRF_SETTING_FSCAL3_VAL_UB,
[FSCAL2] = SMARTRF_SETTING_FSCAL2_VAL_UB,
[FSCAL1] = SMARTRF_SETTING_FSCAL1_VAL_UB,
[FSCAL0] = SMARTRF_SETTING_FSCAL0_VAL_UB,
[TEST2] = SMARTRF_SETTING_TEST2_VAL_UB,
[TEST1] = SMARTRF_SETTING_TEST1_VAL_UB,
[TEST0] = SMARTRF_SETTING_TEST0_VAL_UB
};


/**
* Masks.
Expand Down Expand Up @@ -469,6 +504,30 @@ static void receivePacket(uint8_t *destPayload) {
strobe(SFRX);
}

static void chimeTestSequence(){
char buffer[100] = {'\0'};
spiDataConfig.CSNR = RF_CONFIG_CS_UB;

uint8 goldsequence[SMARTRF_SETTING_PKTLEN_VAL_UB] = {0x67, 0x87, 0x5d, 0xef, 0xcb, 0x74, 0x0e, 0x55, 0xd1, 0x3f, 0x17, 0xb7, 0xcb, 0x67, 0xcd, 0x10, 0x7e, 0xc6, 0x34, 0xfa, 0x40, 0x11, 0x5e, 0xdc, 0x85, 0x7e, 0x42, 0x70, 0xf9, 0x18, 0x88, 0xbe, 0xf9, 0x65, 0x1c, 0xcd, 0x3b, 0xcc, 0x71, 0x70, 0x5a, 0xeb, 0x7f, 0x89, 0x41, 0xa4, 0x3f, 0xc0, 0x19, 0x7e, 0x5c, 0x45, 0xaa, 0xa4, 0x50};

snprintf(buffer, sizeof(buffer), "Sending CHIME cal. signal");
serialSendln(buffer);

strobe(SNOP);
if(statusByte & 0x70 == 0x70){strobe(SFTX);}
if (writeToTxFIFO(goldsequence, SMARTRF_SETTING_PKTLEN_VAL_UB) == 1) {
snprintf(buffer, sizeof(buffer), "%d Bytes Radio TX FIFO written", SMARTRF_SETTING_PKTLEN_VAL_UB);
serialSendln(buffer);
} else {
snprintf(buffer, sizeof(buffer), "Radio did not write");
serialSendln(buffer);
}


strobe(STX);
spiDataConfig.CSNR = RF_CONFIG_CS_LB;
}

static void rfTestSequence() {
strobe(SNOP);
char buffer[100] = {'\0'};
Expand Down Expand Up @@ -799,15 +858,17 @@ BaseType_t initRadio() {
* CC1101 is active-low, on CS0
* SPI_CS_0 -> 0xFE -> 11111110
*/
spiDataConfig.CSNR = RF_CONFIG_CS_LB;

uint8 *stat = readAllStatusRegisters();
char buffer[30];
//---------configure lower band CC1101
spiDataConfig.CSNR = RF_CONFIG_CS_LB;

strobe(SRES);
strobe(SNOP);

snprintf(buffer, 30, "Radio Status Registers:");
uint8 *stat = readAllStatusRegisters();
char buffer[30];

snprintf(buffer, 30, "LB Radio Status Registers:");
serialSendln(buffer);
snprintf(buffer, 30, "%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, ",
stat[0], stat[1], stat[2], stat[3], stat[4], stat[5], stat[6], stat[7], stat[8], stat[9],
Expand All @@ -824,9 +885,33 @@ BaseType_t initRadio() {
//attach irq

strobe(SRX);
//move here ##

//Move ##

//---------configure Upper band CC1101
spiDataConfig.CSNR = RF_CONFIG_CS_UB;

strobe(SRES);
strobe(SNOP);

stat = readAllStatusRegisters();

snprintf(buffer, 30, "UB Radio Status Registers:");
serialSendln(buffer);
snprintf(buffer, 30, "%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, ",
stat[0], stat[1], stat[2], stat[3], stat[4], stat[5], stat[6], stat[7], stat[8], stat[9],
stat[10], stat[11], stat[12], stat[13]);
serialSendln(buffer);

if(configureRadio(SMARTRF_VALS_UB, PA_TABLE_SETTING)){
snprintf(buffer, 30, "radio registers do not match!");
serialSendln(buffer);
}

strobe(SNOP);
strobe(SIDLE);

spiDataConfig.CSNR = RF_CONFIG_CS_LB;

return pdPASS;
}

Expand Down