Experiments with gpio pins, for hardware sync
This commit is contained in:
@ -86,10 +86,16 @@ static struct gpio_t gpio_rffc5072_clock = GPIO(5, 6);
|
|||||||
static struct gpio_t gpio_rffc5072_data = GPIO(3, 3);
|
static struct gpio_t gpio_rffc5072_data = GPIO(3, 3);
|
||||||
static struct gpio_t gpio_rffc5072_reset = GPIO(2, 14);
|
static struct gpio_t gpio_rffc5072_reset = GPIO(2, 14);
|
||||||
|
|
||||||
|
/*
|
||||||
static struct gpio_t gpio_sync_in_a = GPIO(3, 8);
|
static struct gpio_t gpio_sync_in_a = GPIO(3, 8);
|
||||||
static struct gpio_t gpio_sync_in_b = GPIO(3, 9);
|
static struct gpio_t gpio_sync_in_b = GPIO(3, 9);
|
||||||
static struct gpio_t gpio_sync_out_a = GPIO(3, 10);
|
static struct gpio_t gpio_sync_out_a = GPIO(3, 10);
|
||||||
static struct gpio_t gpio_sync_out_b = GPIO(3, 11);
|
static struct gpio_t gpio_sync_out_b = GPIO(3, 11);
|
||||||
|
*/
|
||||||
|
static struct gpio_t gpio_sync_in_a = GPIO(3, 10);
|
||||||
|
static struct gpio_t gpio_sync_in_b = GPIO(3, 11);
|
||||||
|
static struct gpio_t gpio_sync_out_a = GPIO(3, 8);
|
||||||
|
static struct gpio_t gpio_sync_out_b = GPIO(3, 9);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* RF LDO control */
|
/* RF LDO control */
|
||||||
@ -846,6 +852,12 @@ void pin_setup(void) {
|
|||||||
|
|
||||||
/* Safe state: start with VAA turned off: */
|
/* Safe state: start with VAA turned off: */
|
||||||
disable_rf_power();
|
disable_rf_power();
|
||||||
|
|
||||||
|
gpio_input(&gpio_sync_in_a);
|
||||||
|
gpio_input(&gpio_sync_in_b);
|
||||||
|
|
||||||
|
gpio_output(&gpio_sync_out_a);
|
||||||
|
gpio_output(&gpio_sync_out_b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* enable input on SCL and SDA pins */
|
/* enable input on SCL and SDA pins */
|
||||||
@ -897,6 +909,24 @@ void hw_sync_start() {
|
|||||||
gpio_set(&gpio_sync_out_b);
|
gpio_set(&gpio_sync_out_b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hw_sync_stop() {
|
||||||
|
gpio_clear(&gpio_sync_out_a);
|
||||||
|
gpio_clear(&gpio_sync_out_b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hw_sync_copy_state() {
|
||||||
|
if(gpio_read(&gpio_sync_in_a)) {
|
||||||
|
gpio_set(&gpio_sync_out_a);
|
||||||
|
} else {
|
||||||
|
gpio_clear(&gpio_sync_out_a);
|
||||||
|
}
|
||||||
|
if(gpio_read(&gpio_sync_in_b)) {
|
||||||
|
gpio_set(&gpio_sync_out_b);
|
||||||
|
} else {
|
||||||
|
gpio_clear(&gpio_sync_out_b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool hw_sync_ready() {
|
bool hw_sync_ready() {
|
||||||
return (gpio_read(&gpio_sync_in_a) && gpio_read(&gpio_sync_in_b));
|
return (gpio_read(&gpio_sync_in_a) && gpio_read(&gpio_sync_in_b));
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,10 @@ void led_off(const led_t led);
|
|||||||
void led_toggle(const led_t led);
|
void led_toggle(const led_t led);
|
||||||
|
|
||||||
void hw_sync_start();
|
void hw_sync_start();
|
||||||
|
void hw_sync_stop();
|
||||||
bool hw_sync_ready();
|
bool hw_sync_ready();
|
||||||
|
void hw_sync_copy_state();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -252,20 +252,27 @@ int main(void) {
|
|||||||
int hw_sync_count = 0;
|
int hw_sync_count = 0;
|
||||||
|
|
||||||
unsigned int phase = 0;
|
unsigned int phase = 0;
|
||||||
|
|
||||||
|
hw_sync_start();
|
||||||
while(true) {
|
while(true) {
|
||||||
// Check whether we need to initiate a CPLD update
|
// Check whether we need to initiate a CPLD update
|
||||||
if (start_cpld_update)
|
if (start_cpld_update)
|
||||||
cpld_update();
|
cpld_update();
|
||||||
|
|
||||||
|
|
||||||
|
hw_sync_copy_state();
|
||||||
|
|
||||||
// check for hardware sync
|
// check for hardware sync
|
||||||
if(hw_sync_ready()) {
|
if(hw_sync_ready()) {
|
||||||
synced = true;
|
synced = true;
|
||||||
hw_sync_start();
|
//hw_sync_start();
|
||||||
} /*else if(hw_sync_count++ > 1000) {
|
} else if(hw_sync_count++ > 1000000) {
|
||||||
|
//hw_sync_stop();
|
||||||
led_toggle(LED3);
|
led_toggle(LED3);
|
||||||
hw_sync_count = 0;
|
hw_sync_count = 0;
|
||||||
}*/
|
} else if(hw_sync_count == 500000) {
|
||||||
|
//hw_sync_start();
|
||||||
|
}
|
||||||
|
|
||||||
//int gpio_sync_in_flag = gpio_get(gpio_sync_in);
|
//int gpio_sync_in_flag = gpio_get(gpio_sync_in);
|
||||||
|
|
||||||
@ -276,7 +283,8 @@ int main(void) {
|
|||||||
usb_transfer_schedule_block(
|
usb_transfer_schedule_block(
|
||||||
(transceiver_mode() == TRANSCEIVER_MODE_RX)
|
(transceiver_mode() == TRANSCEIVER_MODE_RX)
|
||||||
? &usb_endpoint_bulk_in : &usb_endpoint_bulk_out,
|
? &usb_endpoint_bulk_in : &usb_endpoint_bulk_out,
|
||||||
synced ? &usb_bulk_buffer[0x0000] : &usb_dummy_buffer[0x0000],
|
//synced ? &usb_bulk_buffer[0x0000] : &usb_dummy_buffer[0x0000],
|
||||||
|
&usb_bulk_buffer[0x0000],
|
||||||
0x4000,
|
0x4000,
|
||||||
NULL, NULL
|
NULL, NULL
|
||||||
);
|
);
|
||||||
@ -290,7 +298,8 @@ int main(void) {
|
|||||||
usb_transfer_schedule_block(
|
usb_transfer_schedule_block(
|
||||||
(transceiver_mode() == TRANSCEIVER_MODE_RX)
|
(transceiver_mode() == TRANSCEIVER_MODE_RX)
|
||||||
? &usb_endpoint_bulk_in : &usb_endpoint_bulk_out,
|
? &usb_endpoint_bulk_in : &usb_endpoint_bulk_out,
|
||||||
synced ? &usb_bulk_buffer[0x4000] : &usb_dummy_buffer[0x4000],
|
//synced ? &usb_bulk_buffer[0x4000] : &usb_dummy_buffer[0x4000],
|
||||||
|
&usb_bulk_buffer[0x4000],
|
||||||
0x4000,
|
0x4000,
|
||||||
NULL, NULL
|
NULL, NULL
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user