Create system and user storage registers

The DAQ features five 32-bit battery-backed registers. One of the register is reserved for system configuration while the four others are user-controlled. The system configuration register is accessed through the DaqConfig.IsOptionEnabled() and DaqConfig.SetOption() API calls which get and set specific option bits in the register. The user registers are treated as unsigned 32-bit values accessed through the DaqConfig.GetUserRegister() and DaqConfig.SetUserRegister() API calls. Changes made to the system and user registers are stored on the DAQ with the DaqConfig.Commit() call. 

Sample output:

System config options:
    ClockConfigured: True
    ClockTimeSet: True
    DiagnosticsToSerial: True
User register[1] = 3735928559
User register[2] = 322424845
User register[3] = 195948557
User register[4] = 3133020853
System Diagnostic Messages

The DAQ module features built-in diagnostic messages which are disabled by default in the System register configuration. When enabled, diagnostic messages are sent to a dumb terminal such as TeraTerm or HyperTerminal connected to the USART port (RX, TX, GND) on the DAQ. Each DAQ sub-system (File System, I2C, USART, RTC, ADC, GPIO, etc...) reports diagnostic messages when something goes wrong, when configuration settings are invalid or during their boot-time initialization. These diagnostics are particularly useful when troubleshooting application and driver issues as they generally provide more in-depth details than the C# exceptions thrown by the DAQ.

Enabling System Diagnostic Messages

The following code can be used to check for and enable system diagnostic messages:

            using (var daqConfig = new DaqConfig(daq)) {
                if (daqConfig.IsOptionEnabled(DaqSetting.DiagnosticsToSerial) == false) {
                    daqConfig.SetOption(DaqSetting.DiagnosticsToSerial, true);
                    daqConfig.Commit(daq);
                    daq.Reboot();
                }
            }
Dumb Terminal Communication Settings

By default, the DAQ uses the following communication settings:

Baud rate: 115200
Data: 8 bit
Parity: None
Stop bits: 1
Flow Control: None
Terminal Emulation: VT100
Color-Coding Scheme

The DAQ module uses VT100 escape sequences to write color-coded strings to the dumb terminal, indicating the message severity.

White: informational
Yellow: informational
Red: failure
Green: success
Sample Boot Time Diagnostic Messages Output

On boot, the DAQ produces diagnostic messages such as these:

[nwazet DAQ module init | Rev: [nwazet.daqL.1.0
Clock freq. kHz:
        SYSCLK: 16000000
        HCLK: 16000000
        PCLK: 16000000
        ADCCLK: 14000000
        CECCLK: 32786
        I2C1CLK: 8000000
        USART1CLK: 16000000
RTC init
RTC init ok
Time: 2012/09/13, 15:11:30.0
Backup registers:
        SR: 0x7
        U1: 0xdeadbeef
        U2: 0x1337d00d
        U3: 0xbadf00d
        U4: 0xbabe1ab5
ADC init
ADC init ok
SPI channel 2 init
SPI channel 2 ok
Digital GPIO init
Digital GPIO init ok
I2C init
I2C init ok
SysTick init (1ms freq.)
SysTick init ok
File system reset
File system reset ok
[nwazet DAQ module ready]