diff options
Diffstat (limited to 'device-functions.c')
-rw-r--r-- | device-functions.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/device-functions.c b/device-functions.c index 35c2662..26d2a5f 100644 --- a/device-functions.c +++ b/device-functions.c @@ -4621,3 +4621,49 @@ void Main_update_shift_registers() globals.Registers.last_relay_driver_settings[1]=globals.Registers.shift_reg_out[3]; } + +int IO_Setup_RS232(int baud, char parity, char stopbits, char databits, char hardhand, char echo) +{ + // debugging + printf ("baud: %d, parity %d, stop bits %d, data bits %d, handshaking %d, echo %d\n\r", + baud, + parity, // 0 = none, 1 = odd, 2 = even + stopbits, + databits, + hardhand, // 0 = none, 1 = hard + echo); + + // FIXME implement serial port changes here + + if (1) { // FIXME if changes are successful + globals.Flash.baud = baud; + globals.Flash.parity = parity; + globals.Flash.stopbits = stopbits; + globals.Flash.databits = databits; + globals.Flash.hardhand = hardhand; + globals.Flash.echo = echo; + + int eprom_loc = (char *) &(globals.Flash.baud) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(globals.Flash.baud)); + + eprom_loc = (char *) &(globals.Flash.parity) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(globals.Flash.parity)); + + eprom_loc = (char *) &(globals.Flash.stopbits) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(globals.Flash.stopbits)); + + eprom_loc = (char *) &(globals.Flash.databits) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(globals.Flash.databits)); + + eprom_loc = (char *) &(globals.Flash.hardhand) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(globals.Flash.hardhand)); + + eprom_loc = (char *) &(globals.Flash.echo) - (char *) &(globals.Flash.flash_start); + writeUserBlock(&globals.Flash, eprom_loc, sizeof(globals.Flash.echo)); + + return OK; + } else { + return HardwareError; + } +} + |