diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-09-11 09:23:09 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-09-11 09:23:09 -0400 |
commit | c9b47b6f58017ce6a0ae48a454545edb4715ca7a (patch) | |
tree | 873df2844e82edf1f77c5c31a66906eb1cccbe0d /device-functions.c | |
parent | 959e1cf54cea0a3252c4852224a290c56c50df2a (diff) |
added support for serial parameters
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; + } +} + |