Hi Ian,
That is exactly what I was getting at. Except I wanted to know if it could be expanded to a 'Data' type (I know it is is not a type, but for lack of a better word...).
What they (HopeRF) did in C, was a little similar to what you did, except some really key issues:
1) They used defines that allow for > 1 value for each *constant Name*
2) They combined the defines (*constants*) into a multidemensional array, where each element has a different field length - which *is* similar to yours in that you describe the length of data to be part of the Data line.
Maybe I am missing something. Is by default a list of Data commands, as called by Ian a "structure" similar to or equal to a Structure in other languages?
[quote:d5a9e13af5]
Rx_structure:
Data 2 , Setup_aw , &B00000001 '3bit address
Data 4 , Rx_addr_p0 , &H01 , &H42 , &H24 'RX adress for pipe0
Data 2 , En_aa , &H01 'Enable auto ACK for pipe0
Data 2 , En_rxaddr , &H01 'Enable RX adress for pipe0
Data 2 , Rf_ch , 99 'Set RF channel
Data 2 , Rx_pw_p0 , 3 'Set RX pload width for pipe0
Data 2 , Rf_setup , &B00000111 'Setup RF-> Output power 5dbm, datarate 1Mbps and LNA gain on
Data 2 , Config_nrf , &B00001011 'Setup CONFIG-> PRX=1(RX_device), PWR_UP=1, CRC 1bytes, Enable CRC
Data 0 'end of data
[/quote:d5a9e13af5]
LIke you have done Ian, I am trying to find a way to make understanding the code , and what each parameter of each command & property means, without going to some lookup reference document. Not ever having to try to do this in BASCOM, it is new to me and therefore the seemingly ridiculous questions.
Tim
*C Code*
[code]#define RF_POWER_UP 0x02, 0x01, 0x01, 0x01, 0xC9, 0xC3, 0x80
#define RF_GPIO_PIN_CFG 0x13, 0x5C, 0x53, 0x5B, 0x51, 0x00, 0x00
#define RF_GLOBAL_XO_TUNE_1 0x11, 0x00, 0x01, 0x00, 0x3F
#define RF_GLOBAL_CONFIG_1 0x11, 0x00, 0x01, 0x03, 0x40
#define RF_INT_CTL_ENABLE_2 0x11, 0x01, 0x02, 0x00, 0x01, 0x30
#define RF_FRR_CTL_A_MODE_4 0x11, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00
#define RF_PREAMBLE_TX_LENGTH_9 0x11, 0x10, 0x09, 0x00, 0x08, 0x14, 0x00, 0x0F, 0x31, 0x00, 0x00, 0x00, 0x00
#define RF_SYNC_CONFIG_5 0x11, 0x11, 0x05, 0x00, 0x01, 0xB4, 0x2B, 0x00, 0x00
#define RF_PKT_CRC_CONFIG_1 0x11, 0x12, 0x01, 0x00, 0x80
#define RF_PKT_CONFIG1_1 0x11, 0x12, 0x01, 0x06, 0x02
#define RF_PKT_LEN_3 0x11, 0x12, 0x03, 0x08, 0x00, 0x00, 0x00
#define RF_PKT_FIELD_1_LENGTH_12_8_12 0x11, 0x12, 0x0C, 0x0D, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
#define RF_PKT_FIELD_4_LENGTH_12_8_8 0x11, 0x12, 0x08, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
//#define RF_MODEM_MOD_TYPE_12 0x11, 0x20, 0x0C, 0x00, 0x02, 0x00, 0x07, 0x00, 0x09, 0x60, 0x00, 0x2D, 0xC6, 0xC0, 0x00, 0x09
#define RF_MODEM_MOD_TYPE_12 0x11, 0x20, 0x0C, 0x00, 0x02, 0x00, 0x07, 0x00, 0x09, 0x60, 0x00, 0x2D, 0xC6, 0xC0, 0x00, 0x04
//#define RF_MODEM_FREQ_DEV_0_1 0x11, 0x20, 0x01, 0x0C, 0x8F
#define RF_MODEM_FREQ_DEV_0_1 0x11, 0x20, 0x01, 0x0C, 0xC7
//#define RF_MODEM_TX_RAMP_DELAY_8 0x11, 0x20, 0x08, 0x18, 0x01, 0x80, 0x08, 0x03, 0x80, 0x00, 0x12, 0x10
#define RF_MODEM_TX_RAMP_DELAY_8 0x11, 0x20, 0x08, 0x18, 0x01, 0x80, 0x08, 0x03, 0xC0, 0x00, 0x12, 0x10
#define RF_MODEM_BCR_OSR_1_9 0x11, 0x20, 0x09, 0x22, 0x04, 0x12, 0x00, 0x7D, 0xD4, 0x00, 0x3F, 0x02, 0xC2
//#define RF_MODEM_AFC_GEAR_7 0x11, 0x20, 0x07, 0x2C, 0x04, 0x36, 0x80, 0x02, 0x75, 0x0B, 0x80
#define RF_MODEM_AFC_GEAR_7 0x11, 0x20, 0x07, 0x2C, 0x04, 0x36, 0x80, 0x01, 0x75, 0x0B, 0x80
#define RF_MODEM_AGC_CONTROL_1 0x11, 0x20, 0x01, 0x35, 0xE2
#define RF_MODEM_AGC_WINDOW_SIZE_9 0x11, 0x20, 0x09, 0x38, 0x11, 0xE4, 0xE4, 0x00, 0x02, 0x74, 0xAA, 0x00, 0x2B
#define RF_MODEM_OOK_CNT1_11 0x11, 0x20, 0x0B, 0x42, 0xA4, 0x02, 0xD6, 0x81, 0x05, 0xEA, 0x01, 0x80, 0xFF, 0x0C, 0x00
#define RF_MODEM_RSSI_COMP_1 0x11, 0x20, 0x01, 0x4E, 0x40
#define RF_MODEM_CLKGEN_BAND_1 0x11, 0x20, 0x01, 0x51, 0x08
#define RF_MODEM_CHFLT_RX1_CHFLT_COE13_7_0_12 0x11, 0x21, 0x0C, 0x00, 0xFF, 0xBA, 0x0F, 0x51, 0xCF, 0xA9, 0xC9, 0xFC, 0x1B, 0x1E, 0x0F, 0x01
#define RF_MODEM_CHFLT_RX1_CHFLT_COE1_7_0_12 0x11, 0x21, 0x0C, 0x0C, 0xFC, 0xFD, 0x15, 0xFF, 0x00, 0x0F, 0xFF, 0xBA, 0x0F, 0x51, 0xCF, 0xA9
#define RF_MODEM_CHFLT_RX2_CHFLT_COE7_7_0_12 0x11, 0x21, 0x0C, 0x18, 0xC9, 0xFC, 0x1B, 0x1E, 0x0F, 0x01, 0xFC, 0xFD, 0x15, 0xFF, 0x00, 0x0F
#define RF_PA_MODE_4 0x11, 0x22, 0x04, 0x00, 0x08, 0x7F, 0x00, 0x0E
#define RF_SYNTH_PFDCP_CPFF_7 0x11, 0x23, 0x07, 0x00, 0x2C, 0x0E, 0x0B, 0x04, 0x0C, 0x73, 0x03
#define RF_MATCH_VALUE_1_12 0x11, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
#define RF_FREQ_CONTROL_INTE_8 0x11, 0x40, 0x08, 0x00, 0x3C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF
#define RADIO_CONFIGURATION_DATA_ARRAY {
0x07, RF_POWER_UP,
0x07, RF_GPIO_PIN_CFG,
0x05, RF_GLOBAL_XO_TUNE_1,
0x05, RF_GLOBAL_CONFIG_1,
0x06, RF_INT_CTL_ENABLE_2,
0x08, RF_FRR_CTL_A_MODE_4,
0x0D, RF_PREAMBLE_TX_LENGTH_9,
0x09, RF_SYNC_CONFIG_5,
0x05, RF_PKT_CRC_CONFIG_1,
0x05, RF_PKT_CONFIG1_1,
0x07, RF_PKT_LEN_3,
0x10, RF_PKT_FIELD_1_LENGTH_12_8_12,
0x0C, RF_PKT_FIELD_4_LENGTH_12_8_8,
0x10, RF_MODEM_MOD_TYPE_12,
0x05, RF_MODEM_FREQ_DEV_0_1,
0x0C, RF_MODEM_TX_RAMP_DELAY_8,
0x0D, RF_MODEM_BCR_OSR_1_9,
0x0B, RF_MODEM_AFC_GEAR_7,
0x05, RF_MODEM_AGC_CONTROL_1,
0x0D, RF_MODEM_AGC_WINDOW_SIZE_9,
0x0F, RF_MODEM_OOK_CNT1_11,
0x05, RF_MODEM_RSSI_COMP_1,
0x05, RF_MODEM_CLKGEN_BAND_1,
0x10, RF_MODEM_CHFLT_RX1_CHFLT_COE13_7_0_12,
0x10, RF_MODEM_CHFLT_RX1_CHFLT_COE1_7_0_12,
0x10, RF_MODEM_CHFLT_RX2_CHFLT_COE7_7_0_12,
0x08, RF_PA_MODE_4,
0x0B, RF_SYNTH_PFDCP_CPFF_7,
0x10, RF_MATCH_VALUE_1_12,
0x0C, RF_FREQ_CONTROL_INTE_8,
0x00
}
const u8 RFM24_CONFIGURATION_DATA[]=RADIO_CONFIGURATION_DATA_ARRAY;
↧