Skip to content

Commit

Permalink
Ensure radio module gets initialized first
Browse files Browse the repository at this point in the history
HACK for debug backplane
Added delay for debug backplane "radio" clock to stabilize. Without it
GPIOs were not stabilizing. #23
  • Loading branch information
nealjack committed Feb 22, 2017
1 parent 761c7a7 commit ac68837
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
25 changes: 23 additions & 2 deletions software/apps/controller/signpost_controller_app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ static void check_module_initialization (void) {
}
// this module took too long to talk to controller
// XXX need more to police bad modules (repeat offenders)
else if (isolated_count > 4) {
else if (isolated_count > 15) {
printf("Module %d took too long\n", MODOUT_pin_to_mod_name(mod_isolated_out));
gpio_set(mod_isolated_in);
mod_isolated_out = -1;
mod_isolated_in = -1;
controller_all_modules_enable_i2c();
} else {
} else {
isolated_count++;
}
}
Expand Down Expand Up @@ -469,6 +469,27 @@ int main (void) {

printf("Everything intialized\n");

delay_ms(2000);
// hack: initialize radio first
size_t j = 2;
printf("Module %d granted isolation\n", MODOUT_pin_to_mod_name(MOD_OUTS[j]));
// module requesting isolation
mod_isolated_out = MOD_OUTS[j];
printf("%d\n", mod_isolated_out);
mod_isolated_in = MOD_INS[j];
printf("%d\n", mod_isolated_in);
last_mod_isolated_out = MOD_OUTS[j];
isolated_count = 0;

// create private channel for this module
//XXX warn modules of i2c disable
controller_all_modules_disable_i2c();
controller_module_enable_i2c(MODOUT_pin_to_mod_name(mod_isolated_out));
// signal to module that it has a private channel
// XXX this should be a controller function operating on the
// module number, not index
gpio_clear(mod_isolated_in);

printf("Entering loop\n");
uint8_t index = 0;
while(1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ int main (void) {
// Install hooks for the signpost APIs we implement
static api_handler_t networking_handler = {NetworkingApiType, networking_api_callback};
static api_handler_t* handlers[] = {&networking_handler, NULL};
delay_ms(1000);
do {
rc = signpost_initialization_module_init(ModuleAddressRadio, handlers);
if (rc < 0) {
Expand Down
7 changes: 3 additions & 4 deletions software/apps/libs/signpost_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ int signpost_initialization_controller_module_init(api_handler_t** api_handlers)

// Begin listening for replies
signpost_api_start_new_async_recv();
// delay for a second to wait for storage master to init
delay_ms(2000);

SIGNBUS_DEBUG("complete\n");
return SUCCESS;
}
Expand Down Expand Up @@ -349,11 +348,11 @@ int signpost_initialization_module_init(uint8_t i2c_address, api_handler_t** api
int signpost_initialization_request_isolation(void) {
// Initialize Mod Out/In GPIO
// both are active low
gpio_interrupt_callback(signpost_initialization_isolation_callback, NULL);
gpio_enable_interrupt(MOD_IN, PullUp, FallingEdge);
gpio_enable_output(MOD_OUT);
gpio_set(MOD_OUT);
led_off(RED_LED);
gpio_enable_interrupt(MOD_IN, PullUp, FallingEdge);
gpio_interrupt_callback(signpost_initialization_isolation_callback, NULL);

// Pull Mod_Out Low to signal controller
// Wait on controller interrupt on MOD_IN
Expand Down

0 comments on commit ac68837

Please sign in to comment.