attempt to support "on change" for every register
This commit is contained in:
BIN
Binary file not shown.
BIN
Binary file not shown.
+62
-21
@@ -8,6 +8,22 @@
|
||||
#define rec_gain_index 1
|
||||
#define adc_clock_ratio_index 2
|
||||
|
||||
#define sti_duration0_index 0
|
||||
#define sti_duration1_index 1
|
||||
#define sti_duration2_index 2
|
||||
#define sti_duration3_index 3
|
||||
#define sti_amp_pos_index 4
|
||||
#define sti_amp_neg_index 5
|
||||
#define sti_polarity_index 6
|
||||
#define sti_cycle_ch01_index 7
|
||||
#define sti_cycle_ch23_index 8
|
||||
#define sti_cycle_ch45_index 9
|
||||
#define sti_cycle_ch67_index 10
|
||||
#define sti_enable_index 11
|
||||
#define sti_clk_ratio_index 12
|
||||
#define sti_arbitrary_en_index 13
|
||||
#define sti_mode_index 14
|
||||
|
||||
//#define DBS_REGISTER \
|
||||
// uint8_t address; \
|
||||
// void (*write_reg) (DBSRegister *self, uint32_t reg_value); \
|
||||
@@ -26,32 +42,57 @@ void write_reg(DBSRegister *self, uint32_t reg_value){
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void read_reg(DBSRegister *self, uint32_t reg_value){
|
||||
uint32_t read_reg(DBSRegister *self){
|
||||
spi_txbuf[0] = 0x7F & self->address;
|
||||
spi_txbuf[1] = 0x7F & self->address; // it's don't care actually
|
||||
spi_txbuf[2] = 0x7F & self->address; // it's don't care actually
|
||||
SPICallBack = READ_REG;
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
|
||||
// TODO: read spi value and return the real value of register
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DBSRegister rec_register[3] ={
|
||||
{
|
||||
// rec_channel
|
||||
[rec_channel_index].address = 48,
|
||||
[rec_channel_index].write_reg = &write_reg,
|
||||
[rec_channel_index].read_reg = &read_reg
|
||||
},
|
||||
{
|
||||
// rec_gain
|
||||
[rec_gain_index].address = 49,
|
||||
[rec_gain_index].write_reg = &write_reg,
|
||||
[rec_gain_index].read_reg = &read_reg
|
||||
},
|
||||
{
|
||||
// sampling rate
|
||||
[adc_clock_ratio_index].address = 51,
|
||||
[adc_clock_ratio_index].write_reg = &write_reg,
|
||||
[adc_clock_ratio_index].read_reg = &read_reg
|
||||
}
|
||||
};
|
||||
static DBSRegister rec_register[3];
|
||||
static DBSRegister sti_register[15];
|
||||
|
||||
static void InitRecRegister(){
|
||||
// rec_channel
|
||||
rec_register[rec_channel_index].address = 48;
|
||||
rec_register[rec_channel_index].write_reg = &write_reg;
|
||||
rec_register[rec_channel_index].read_reg = &read_reg;
|
||||
|
||||
// rec_gain
|
||||
rec_register[rec_gain_index].address = 49;
|
||||
rec_register[rec_gain_index].write_reg = &write_reg;
|
||||
rec_register[rec_gain_index].read_reg = &read_reg;
|
||||
|
||||
// sampling rate
|
||||
rec_register[adc_clock_ratio_index].address = 51;
|
||||
rec_register[adc_clock_ratio_index].write_reg = &write_reg;
|
||||
rec_register[adc_clock_ratio_index].read_reg = &read_reg;
|
||||
}
|
||||
|
||||
static void InitStiRegister(){
|
||||
sti_register[sti_duration0_index].address = 1;
|
||||
sti_register[sti_duration1_index].address = 2;
|
||||
sti_register[sti_duration2_index].address = 3;
|
||||
sti_register[sti_duration3_index].address = 4;
|
||||
sti_register[sti_amp_pos_index].address = 37;
|
||||
sti_register[sti_amp_neg_index].address = 38;
|
||||
sti_register[sti_polarity_index].address = 40;
|
||||
sti_register[sti_cycle_ch01_index].address = 42;
|
||||
sti_register[sti_cycle_ch23_index].address = 43;
|
||||
sti_register[sti_cycle_ch45_index].address = 44;
|
||||
sti_register[sti_cycle_ch67_index].address = 45;
|
||||
sti_register[sti_enable_index].address = 46;
|
||||
sti_register[sti_clk_ratio_index].address = 52;
|
||||
sti_register[sti_arbitrary_en_index].address = 54;
|
||||
sti_register[sti_mode_index].address = 56;
|
||||
|
||||
for(int i=0 ; i<15 ; i++ ){
|
||||
sti_register[i].write_reg = &write_reg;
|
||||
sti_register[i].read_reg = &read_reg;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+3
@@ -318,6 +318,9 @@ static void headstage_init() {
|
||||
headstage_spi_open();
|
||||
headstage_led_open();
|
||||
headstage_pwm_open();
|
||||
InitRecRegister();
|
||||
InitStiRegister();
|
||||
|
||||
headstage_led_color(COLOR_GREEN); // color green
|
||||
headstage_pwm_start(headstage_system_pwm_handle);
|
||||
headstage_pwm_start(headstage_poly_r_pwm_handle);
|
||||
|
||||
+4
-4
@@ -4,13 +4,13 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 28
|
||||
#define VERSION_DATE_HOUR 18
|
||||
#define VERSION_DATE_MINUTE 24
|
||||
#define VERSION_DATE_DAY 31
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 34
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
#define VERSION_HASH 8635b1b8782e716ef4c97d6118b9134e4d2457a0
|
||||
#define VERSION_HASH 5d88871e587271b6ce8bdb8578c1d4a310bf17ee
|
||||
#define VERSION_GIT_BRANCH neulive20_development_without_central
|
||||
|
||||
static void get_board_name(char *board_name_ch, uint8 *board_name_int, uint8 name_size){
|
||||
|
||||
Reference in New Issue
Block a user