Kind of working hardware sync

This commit is contained in:
Mike Davis
2016-12-10 21:42:20 +02:00
parent 3672f38b27
commit 976c99c1ad
3 changed files with 15 additions and 15 deletions

View File

@ -853,6 +853,9 @@ void pin_setup(void) {
/* Safe state: start with VAA turned off: */
disable_rf_power();
scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
gpio_input(&gpio_sync_in_a);
gpio_input(&gpio_sync_in_b);
@ -904,9 +907,8 @@ void led_toggle(const led_t led) {
gpio_toggle(&gpio_led[led]);
}
void hw_sync_start() {
void hw_sync_syn() {
gpio_set(&gpio_sync_out_a);
gpio_set(&gpio_sync_out_b);
}
void hw_sync_stop() {
@ -914,6 +916,10 @@ void hw_sync_stop() {
gpio_clear(&gpio_sync_out_b);
}
void hw_sync_ack() {
gpio_set(&gpio_sync_out_b);
}
void hw_sync_copy_state() {
if(gpio_read(&gpio_sync_in_a)) {
gpio_set(&gpio_sync_out_a);

View File

@ -271,8 +271,9 @@ void led_on(const led_t led);
void led_off(const led_t led);
void led_toggle(const led_t led);
void hw_sync_start();
void hw_sync_syn();
void hw_sync_stop();
void hw_sync_ack();
bool hw_sync_ready();
void hw_sync_copy_state();

View File

@ -253,25 +253,18 @@ int main(void) {
unsigned int phase = 0;
hw_sync_start();
led_off(LED3);
hw_sync_syn();
while(true) {
// Check whether we need to initiate a CPLD update
if (start_cpld_update)
cpld_update();
hw_sync_copy_state();
// check for hardware sync
if(hw_sync_ready()) {
synced = true;
//hw_sync_start();
} else if(hw_sync_count++ > 1000000) {
//hw_sync_stop();
led_toggle(LED3);
hw_sync_count = 0;
} else if(hw_sync_count == 500000) {
//hw_sync_start();
hw_sync_ack();
led_on(LED3);
}
//int gpio_sync_in_flag = gpio_get(gpio_sync_in);