int main(int argc, char *argv[]) {
int g;
+
+ ps_setup_protocol();
+
//const struct sched_param priority = {99};
// Some command line switch stuffles
printf("%s switch found, but no config filename specified.\n", argv[g]);
} else {
g++;
- cfg = load_config_file(argv[g]);
- if (cfg) {
+ FILE *chk = fopen(argv[g], "rb");
+ if (chk == NULL) {
+ printf("Config file %s does not exist, please check that you've specified the path correctly.\n", argv[g]);
+ } else {
+ fclose(chk);
+ load_new_config = 1;
set_pistorm_devcfg_filename(argv[g]);
}
}
switch_config:
srand(clock());
- ps_setup_protocol();
ps_reset_state_machine();
ps_pulse_reset();
usleep(1500);
if (load_new_config != 0) {
uint8_t config_action = load_new_config - 1;
load_new_config = 0;
- free_config_file(cfg);
if (cfg) {
+ free_config_file(cfg);
free(cfg);
cfg = NULL;
}
- /*for(int i = 0; i < 2 * SIZE_MEGA; i++) {
- write8(i, 0);
- }*/
-
switch(config_action) {
case PICFG_LOAD:
case PICFG_RELOAD:
if (address & 0xFF000000)
return;
- if (address & 0x01)
- printf("Unaligned WORD write!\n");
+ if (address & 0x01) {
+ write8(value & 0xFF, address);
+ write8((value >> 8) & 0xFF, address + 1);
+ return;
+ }
write16((uint32_t)address, value);
return;
if (address & 0xFF000000)
return;
- if (address & 0x01)
- printf("Unaligned LONGWORD write!\n");
+ if (address & 0x01) {
+ write8(value & 0xFF, address);
+ write16(htobe16(((value >> 8) & 0xFFFF)), address + 1);
+ write8((value >> 24), address + 3);
+ return;
+ }
write16(address, value >> 16);
write16(address + 2, value);