Libraries and Example of mbed parallel bus using I2C port expanders
Dependencies: HDSP253X mbed PCF8574_Bus
main.cpp@1:e180256ba6fb, 2011-09-17 (annotated)
- Committer:
- wim
- Date:
- Sat Sep 17 15:35:39 2011 +0000
- Revision:
- 1:e180256ba6fb
- Parent:
- 0:2467aed99127
Example of using the parallel bus to control a smart alphanumeric display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:2467aed99127 | 1 | /* mbed bus - Main |
wim | 0:2467aed99127 | 2 | * Copyright (c) 2011 Wim Huiskamp |
wim | 0:2467aed99127 | 3 | * |
wim | 0:2467aed99127 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
wim | 0:2467aed99127 | 5 | * |
wim | 0:2467aed99127 | 6 | * version 0.2 Initial Release |
wim | 0:2467aed99127 | 7 | */ |
wim | 0:2467aed99127 | 8 | #include "mbed.h" |
wim | 0:2467aed99127 | 9 | #include "BusDefines.h" |
wim | 0:2467aed99127 | 10 | #include "PCF8574_DataBus.h" |
wim | 0:2467aed99127 | 11 | #include "PCF8574_AddressBus.h" |
wim | 0:2467aed99127 | 12 | #include "PCF8574_EnableBus.h" |
wim | 0:2467aed99127 | 13 | #include "MBED_ControlBus.h" |
wim | 1:e180256ba6fb | 14 | #include "HDSP253X_Display.h" |
wim | 0:2467aed99127 | 15 | |
wim | 0:2467aed99127 | 16 | // Debug stuff |
wim | 0:2467aed99127 | 17 | #define __DEBUG |
wim | 0:2467aed99127 | 18 | #include "Dbg.h" |
wim | 0:2467aed99127 | 19 | |
wim | 0:2467aed99127 | 20 | // mbed Interface Hardware definitions |
wim | 0:2467aed99127 | 21 | DigitalOut myled1(LED1); |
wim | 0:2467aed99127 | 22 | DigitalOut myled2(LED2); |
wim | 0:2467aed99127 | 23 | DigitalOut myled3(LED3); |
wim | 0:2467aed99127 | 24 | DigitalOut heartbeatLED(LED4); |
wim | 0:2467aed99127 | 25 | |
wim | 0:2467aed99127 | 26 | // Host PC Communication channels |
wim | 0:2467aed99127 | 27 | Serial pc(USBTX, USBRX); |
wim | 0:2467aed99127 | 28 | |
wim | 0:2467aed99127 | 29 | //I2C Bus |
wim | 0:2467aed99127 | 30 | I2C i2c(D_SDA, D_SCL); |
wim | 0:2467aed99127 | 31 | |
wim | 0:2467aed99127 | 32 | // Bus Interface Hardware definitions |
wim | 0:2467aed99127 | 33 | PCF8574_DataBus databus = PCF8574_DataBus(i2c, D_I2C_DATA_BUS); //Copy constructors.. |
wim | 0:2467aed99127 | 34 | PCF8574_AddressBus addressbus = PCF8574_AddressBus(i2c, D_I2C_ADDR_BUS); |
wim | 0:2467aed99127 | 35 | PCF8574_EnableBus enablebus = PCF8574_EnableBus(i2c, D_I2C_ENA_BUS); |
wim | 0:2467aed99127 | 36 | MBED_ControlBus controlbus = MBED_ControlBus(D_WR, D_RD, D_DTR, D_CDBUF, D_CDINT); |
wim | 0:2467aed99127 | 37 | |
wim | 1:e180256ba6fb | 38 | // Display Hardware definitions |
wim | 1:e180256ba6fb | 39 | HDSP253X_Display LED_display = HDSP253X_Display(databus, addressbus, enablebus, controlbus); |
wim | 1:e180256ba6fb | 40 | |
wim | 0:2467aed99127 | 41 | // Dummy delay |
wim | 0:2467aed99127 | 42 | #define DEVICE_WAIT_MS 0 |
wim | 0:2467aed99127 | 43 | |
wim | 0:2467aed99127 | 44 | |
wim | 0:2467aed99127 | 45 | // Variables for Heartbeat and Status monitoring |
wim | 0:2467aed99127 | 46 | Ticker heartbeat; |
wim | 0:2467aed99127 | 47 | bool heartbeatflag=false; |
wim | 0:2467aed99127 | 48 | |
wim | 0:2467aed99127 | 49 | // Cycle Timer |
wim | 0:2467aed99127 | 50 | Timer cycletimer; |
wim | 0:2467aed99127 | 51 | int cyclecount = 0; |
wim | 0:2467aed99127 | 52 | const int maxcount = 10; |
wim | 0:2467aed99127 | 53 | |
wim | 0:2467aed99127 | 54 | // Local functions |
wim | 0:2467aed99127 | 55 | void clear_screen() { |
wim | 0:2467aed99127 | 56 | //ANSI Terminal Commands |
wim | 0:2467aed99127 | 57 | pc.printf("\x1B[2J"); |
wim | 0:2467aed99127 | 58 | pc.printf("\x1B[H"); |
wim | 0:2467aed99127 | 59 | } |
wim | 0:2467aed99127 | 60 | |
wim | 0:2467aed99127 | 61 | |
wim | 0:2467aed99127 | 62 | void init_interfaces() { |
wim | 0:2467aed99127 | 63 | // Init Host PC communication, default is 9600 |
wim | 0:2467aed99127 | 64 | pc.baud(D_BAUDRATE); |
wim | 0:2467aed99127 | 65 | |
wim | 0:2467aed99127 | 66 | // Init I/F hardware |
wim | 0:2467aed99127 | 67 | i2c.frequency(100000); |
wim | 0:2467aed99127 | 68 | |
wim | 0:2467aed99127 | 69 | //Done, Tell me about it |
wim | 0:2467aed99127 | 70 | myled1 = 1; |
wim | 1:e180256ba6fb | 71 | // DBG("Init Interfaces Done\r"); |
wim | 0:2467aed99127 | 72 | } |
wim | 0:2467aed99127 | 73 | |
wim | 0:2467aed99127 | 74 | |
wim | 0:2467aed99127 | 75 | // Heartbeat monitor |
wim | 0:2467aed99127 | 76 | void pulse() { |
wim | 0:2467aed99127 | 77 | heartbeatLED = !heartbeatLED; |
wim | 0:2467aed99127 | 78 | } |
wim | 0:2467aed99127 | 79 | |
wim | 0:2467aed99127 | 80 | void heartbeat_start() { |
wim | 0:2467aed99127 | 81 | heartbeat.attach(&pulse, 0.5); |
wim | 0:2467aed99127 | 82 | heartbeatflag = true; |
wim | 0:2467aed99127 | 83 | } |
wim | 0:2467aed99127 | 84 | |
wim | 0:2467aed99127 | 85 | void heartbeat_stop() { |
wim | 0:2467aed99127 | 86 | heartbeat.detach(); |
wim | 0:2467aed99127 | 87 | heartbeatflag = false; |
wim | 0:2467aed99127 | 88 | } |
wim | 0:2467aed99127 | 89 | |
wim | 0:2467aed99127 | 90 | void show_LEDS () { |
wim | 0:2467aed99127 | 91 | static int state = 0; |
wim | 0:2467aed99127 | 92 | |
wim | 0:2467aed99127 | 93 | switch (state) { |
wim | 0:2467aed99127 | 94 | case 0: |
wim | 0:2467aed99127 | 95 | myled1 = 1; |
wim | 0:2467aed99127 | 96 | myled2 = 0; |
wim | 0:2467aed99127 | 97 | myled3 = 0; |
wim | 0:2467aed99127 | 98 | state = 1; |
wim | 0:2467aed99127 | 99 | break; |
wim | 0:2467aed99127 | 100 | case 1: |
wim | 0:2467aed99127 | 101 | myled1 = 0; |
wim | 0:2467aed99127 | 102 | myled2 = 1; |
wim | 0:2467aed99127 | 103 | myled3 = 0; |
wim | 0:2467aed99127 | 104 | state = 2; |
wim | 0:2467aed99127 | 105 | break; |
wim | 0:2467aed99127 | 106 | case 2: |
wim | 0:2467aed99127 | 107 | myled1 = 0; |
wim | 0:2467aed99127 | 108 | myled2 = 0; |
wim | 0:2467aed99127 | 109 | myled3 = 1; |
wim | 0:2467aed99127 | 110 | state = 0; |
wim | 0:2467aed99127 | 111 | break; |
wim | 0:2467aed99127 | 112 | } |
wim | 0:2467aed99127 | 113 | } |
wim | 0:2467aed99127 | 114 | |
wim | 0:2467aed99127 | 115 | |
wim | 0:2467aed99127 | 116 | // The next two functions are examples of low-level reading and writing to a device that is connected on the mbed bus. |
wim | 0:2467aed99127 | 117 | // In your own application you can develop a Class for each specific slave device and include modified versions of the |
wim | 0:2467aed99127 | 118 | // functions below as 'private' functions. This allows you to hardcode the device CS_pin signals, define specific delays |
wim | 0:2467aed99127 | 119 | // when needed, change the sequence of CS, WR etc or mask out certain address or databits when they are not used in a certain case. |
wim | 0:2467aed99127 | 120 | // |
wim | 0:2467aed99127 | 121 | |
wim | 0:2467aed99127 | 122 | /*---------------------------------------------------------------------------*\ |
wim | 0:2467aed99127 | 123 | | |
wim | 0:2467aed99127 | 124 | | Function: write |
wim | 0:2467aed99127 | 125 | | |
wim | 0:2467aed99127 | 126 | | Description: Low level data write routine for device. Takes in data |
wim | 0:2467aed99127 | 127 | | and address and CS pin to identify the device and writes |
wim | 0:2467aed99127 | 128 | | data to the display. For simplicity, entire address byte |
wim | 0:2467aed99127 | 129 | | is written, even though top two bits are unused inputs. |
wim | 0:2467aed99127 | 130 | | After performing the operation, address lines are set |
wim | 0:2467aed99127 | 131 | | all high, in order to eliminate current drain through |
wim | 0:2467aed99127 | 132 | | pullup resistors (0.5mA per pin with 10K pullups) |
wim | 0:2467aed99127 | 133 | | |
wim | 0:2467aed99127 | 134 | | Parameters: address - full address in bits 0-5 |
wim | 0:2467aed99127 | 135 | | device - enum CS_Pin for Chip Select pin |
wim | 0:2467aed99127 | 136 | | data - data byte to write out |
wim | 0:2467aed99127 | 137 | | |
wim | 0:2467aed99127 | 138 | | Returns: Nothing. |
wim | 0:2467aed99127 | 139 | | |
wim | 0:2467aed99127 | 140 | \*---------------------------------------------------------------------------*/ |
wim | 0:2467aed99127 | 141 | |
wim | 0:2467aed99127 | 142 | void write(uint8_t address, CS_Pin device, uint8_t data) |
wim | 0:2467aed99127 | 143 | { |
wim | 0:2467aed99127 | 144 | // // Switch databus buffer to outputs (note: this is the default state) |
wim | 0:2467aed99127 | 145 | // controlbus.busdir(WRITE); |
wim | 0:2467aed99127 | 146 | // // Switch databus to outputs |
wim | 0:2467aed99127 | 147 | // databus.busdir(WRITE); |
wim | 0:2467aed99127 | 148 | |
wim | 0:2467aed99127 | 149 | |
wim | 0:2467aed99127 | 150 | // Write out the address on to the addressbus and wait |
wim | 0:2467aed99127 | 151 | addressbus.write(address); |
wim | 0:2467aed99127 | 152 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 153 | |
wim | 0:2467aed99127 | 154 | // Set CE low and wait |
wim | 0:2467aed99127 | 155 | enablebus.chipselect(device, LOW); |
wim | 0:2467aed99127 | 156 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 157 | |
wim | 0:2467aed99127 | 158 | // Write data to the databus |
wim | 0:2467aed99127 | 159 | databus.write(data); |
wim | 0:2467aed99127 | 160 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 161 | |
wim | 0:2467aed99127 | 162 | // Set WR low, wait, then set high and wait |
wim | 0:2467aed99127 | 163 | controlbus.WR(LOW); |
wim | 0:2467aed99127 | 164 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 165 | controlbus.WR(HIGH); |
wim | 0:2467aed99127 | 166 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 167 | |
wim | 0:2467aed99127 | 168 | // Set CE high and wait |
wim | 0:2467aed99127 | 169 | enablebus.chipselect(device, HIGH); |
wim | 0:2467aed99127 | 170 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 171 | |
wim | 0:2467aed99127 | 172 | // // Switch databus back to inputs |
wim | 0:2467aed99127 | 173 | // databus.busdir(READ); |
wim | 0:2467aed99127 | 174 | // // Switch databus buffer back to inputs |
wim | 0:2467aed99127 | 175 | // controlbus.busdir(READ); |
wim | 0:2467aed99127 | 176 | |
wim | 0:2467aed99127 | 177 | // // Set address lines all high to minimise power through pullups |
wim | 0:2467aed99127 | 178 | // addressbus.write(0xFF); |
wim | 0:2467aed99127 | 179 | } |
wim | 0:2467aed99127 | 180 | |
wim | 0:2467aed99127 | 181 | /*---------------------------------------------------------------------------*\ |
wim | 0:2467aed99127 | 182 | | |
wim | 0:2467aed99127 | 183 | | Function: read |
wim | 0:2467aed99127 | 184 | | |
wim | 0:2467aed99127 | 185 | | Description: Low level data read routine for a Device. Takes in |
wim | 0:2467aed99127 | 186 | | address and CS pin to identify the device and then |
wim | 0:2467aed99127 | 187 | | reads data from the device. |
wim | 0:2467aed99127 | 188 | | After performing the operation, address lines are set |
wim | 0:2467aed99127 | 189 | | all high, in order to eliminate current drain through |
wim | 0:2467aed99127 | 190 | | pullup resistors (0.5mA per pin with 10K pullups) |
wim | 0:2467aed99127 | 191 | | |
wim | 0:2467aed99127 | 192 | | Parameters: address - 8 bit address |
wim | 0:2467aed99127 | 193 | | device - enum CS_Pin for Chip Select pin |
wim | 0:2467aed99127 | 194 | | Returns: data - data byte read |
wim | 0:2467aed99127 | 195 | | |
wim | 0:2467aed99127 | 196 | \*---------------------------------------------------------------------------*/ |
wim | 0:2467aed99127 | 197 | |
wim | 0:2467aed99127 | 198 | uint8_t read(uint8_t address, CS_Pin device) |
wim | 0:2467aed99127 | 199 | { |
wim | 0:2467aed99127 | 200 | uint8_t data = 0; |
wim | 0:2467aed99127 | 201 | |
wim | 0:2467aed99127 | 202 | // Switch databus to inputs (default state is output) |
wim | 0:2467aed99127 | 203 | databus.busdir(READ); |
wim | 0:2467aed99127 | 204 | // Switch databus buffer to inputs |
wim | 0:2467aed99127 | 205 | controlbus.busdir(READ); |
wim | 0:2467aed99127 | 206 | |
wim | 0:2467aed99127 | 207 | // Write out the address on to the addressbus and wait |
wim | 0:2467aed99127 | 208 | addressbus.write(address); |
wim | 0:2467aed99127 | 209 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 210 | |
wim | 0:2467aed99127 | 211 | // Set CE low and wait |
wim | 0:2467aed99127 | 212 | enablebus.chipselect(device, LOW); |
wim | 0:2467aed99127 | 213 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 214 | |
wim | 0:2467aed99127 | 215 | // Set RD low and wait |
wim | 0:2467aed99127 | 216 | controlbus.RD(LOW); |
wim | 0:2467aed99127 | 217 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 218 | |
wim | 0:2467aed99127 | 219 | // Read the data byte from databus |
wim | 0:2467aed99127 | 220 | data = databus.read(); |
wim | 0:2467aed99127 | 221 | |
wim | 0:2467aed99127 | 222 | // set RD high and wait |
wim | 0:2467aed99127 | 223 | controlbus.RD(HIGH); |
wim | 0:2467aed99127 | 224 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 225 | |
wim | 0:2467aed99127 | 226 | // Set CE high and wait |
wim | 0:2467aed99127 | 227 | enablebus.chipselect(device, HIGH); |
wim | 0:2467aed99127 | 228 | wait_ms(DEVICE_WAIT_MS); |
wim | 0:2467aed99127 | 229 | |
wim | 0:2467aed99127 | 230 | // // Set address lines all high to minimise power through pullups |
wim | 0:2467aed99127 | 231 | // addressbus.write(0xFF); |
wim | 0:2467aed99127 | 232 | |
wim | 0:2467aed99127 | 233 | // Switch databus buffer back to outputs |
wim | 0:2467aed99127 | 234 | controlbus.busdir(WRITE); |
wim | 0:2467aed99127 | 235 | // Switch databus to outputs |
wim | 0:2467aed99127 | 236 | databus.busdir(WRITE); |
wim | 0:2467aed99127 | 237 | |
wim | 0:2467aed99127 | 238 | // Return read data to caller |
wim | 0:2467aed99127 | 239 | return data; |
wim | 0:2467aed99127 | 240 | } |
wim | 0:2467aed99127 | 241 | |
wim | 1:e180256ba6fb | 242 | |
wim | 1:e180256ba6fb | 243 | void HDSP_BITE() { |
wim | 1:e180256ba6fb | 244 | int count; |
wim | 1:e180256ba6fb | 245 | |
wim | 1:e180256ba6fb | 246 | for (count=0; count<5; count++) { |
wim | 1:e180256ba6fb | 247 | LED_display.locate(0); |
wim | 1:e180256ba6fb | 248 | LED_display.printf("BITE - "); |
wim | 1:e180256ba6fb | 249 | wait(0.05); |
wim | 1:e180256ba6fb | 250 | LED_display.locate(0); |
wim | 1:e180256ba6fb | 251 | LED_display.printf("BITE \\ "); |
wim | 1:e180256ba6fb | 252 | wait(0.05); |
wim | 1:e180256ba6fb | 253 | LED_display.locate(0); |
wim | 1:e180256ba6fb | 254 | LED_display.printf("BITE | "); |
wim | 1:e180256ba6fb | 255 | wait(0.05); |
wim | 1:e180256ba6fb | 256 | LED_display.locate(0); |
wim | 1:e180256ba6fb | 257 | LED_display.printf("BITE / "); |
wim | 1:e180256ba6fb | 258 | wait(0.05); |
wim | 1:e180256ba6fb | 259 | LED_display.locate(0); |
wim | 1:e180256ba6fb | 260 | LED_display.printf("BITE - "); |
wim | 1:e180256ba6fb | 261 | wait(0.05); |
wim | 1:e180256ba6fb | 262 | }; |
wim | 1:e180256ba6fb | 263 | |
wim | 1:e180256ba6fb | 264 | LED_display.locate(0); |
wim | 1:e180256ba6fb | 265 | LED_display.printf("BITE OK"); |
wim | 1:e180256ba6fb | 266 | |
wim | 1:e180256ba6fb | 267 | LED_display.set_blink_mode(true); |
wim | 1:e180256ba6fb | 268 | wait(2.0); |
wim | 1:e180256ba6fb | 269 | LED_display.set_blink_mode(false); |
wim | 1:e180256ba6fb | 270 | |
wim | 1:e180256ba6fb | 271 | LED_display.cls(); |
wim | 1:e180256ba6fb | 272 | |
wim | 1:e180256ba6fb | 273 | //Done, Tell me about it |
wim | 1:e180256ba6fb | 274 | // DBG("BITE Done, Main, Step = %d\r", 30); |
wim | 1:e180256ba6fb | 275 | } |
wim | 1:e180256ba6fb | 276 | |
wim | 1:e180256ba6fb | 277 | void HDSP_Init_UDC() { |
wim | 1:e180256ba6fb | 278 | |
wim | 1:e180256ba6fb | 279 | // batt empty |
wim | 1:e180256ba6fb | 280 | LED_display.define_user_char(0, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F); |
wim | 1:e180256ba6fb | 281 | // batt full |
wim | 1:e180256ba6fb | 282 | LED_display.define_user_char(1, 0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F); |
wim | 1:e180256ba6fb | 283 | } |
wim | 1:e180256ba6fb | 284 | |
wim | 1:e180256ba6fb | 285 | |
wim | 1:e180256ba6fb | 286 | void HDSP_Show_UDC() { |
wim | 1:e180256ba6fb | 287 | |
wim | 1:e180256ba6fb | 288 | LED_display.locate(0); |
wim | 1:e180256ba6fb | 289 | LED_display.printf("Batt "); |
wim | 1:e180256ba6fb | 290 | // LED_display.putc(HDSP253X_ASCII_UDC_CHARS + 0); |
wim | 1:e180256ba6fb | 291 | // LED_display.putc(HDSP253X_ASCII_UDC_CHARS + 1); |
wim | 1:e180256ba6fb | 292 | LED_display.putudc(0); |
wim | 1:e180256ba6fb | 293 | LED_display.putudc(1); |
wim | 1:e180256ba6fb | 294 | |
wim | 1:e180256ba6fb | 295 | wait(2.0); |
wim | 1:e180256ba6fb | 296 | } |
wim | 1:e180256ba6fb | 297 | |
wim | 0:2467aed99127 | 298 | int main() { |
wim | 0:2467aed99127 | 299 | int address, result; |
wim | 0:2467aed99127 | 300 | uint8_t data, dummy; |
wim | 0:2467aed99127 | 301 | |
wim | 0:2467aed99127 | 302 | init_interfaces(); |
wim | 0:2467aed99127 | 303 | |
wim | 0:2467aed99127 | 304 | heartbeat_start(); |
wim | 0:2467aed99127 | 305 | |
wim | 0:2467aed99127 | 306 | clear_screen(); |
wim | 1:e180256ba6fb | 307 | |
wim | 1:e180256ba6fb | 308 | HDSP_Init_UDC(); |
wim | 1:e180256ba6fb | 309 | |
wim | 1:e180256ba6fb | 310 | // DBG("Start Main Loop\r"); |
wim | 0:2467aed99127 | 311 | |
wim | 0:2467aed99127 | 312 | //Testing stuff |
wim | 0:2467aed99127 | 313 | |
wim | 0:2467aed99127 | 314 | //Test cycletime |
wim | 0:2467aed99127 | 315 | cycletimer.start(); |
wim | 0:2467aed99127 | 316 | cycletimer.reset(); |
wim | 1:e180256ba6fb | 317 | |
wim | 1:e180256ba6fb | 318 | |
wim | 1:e180256ba6fb | 319 | #if (0) |
wim | 1:e180256ba6fb | 320 | // Bus test |
wim | 0:2467aed99127 | 321 | while (1) { |
wim | 0:2467aed99127 | 322 | for (address=0; address<256; address++) { |
wim | 0:2467aed99127 | 323 | //data = read(address, CS_SWITCH); |
wim | 0:2467aed99127 | 324 | |
wim | 0:2467aed99127 | 325 | dummy = ~address; |
wim | 0:2467aed99127 | 326 | write(address, LATCHEN_1, dummy); |
wim | 0:2467aed99127 | 327 | // wait(0.05); |
wim | 0:2467aed99127 | 328 | } |
wim | 0:2467aed99127 | 329 | |
wim | 0:2467aed99127 | 330 | // Just for Info, lets see how fast this cycle is... |
wim | 0:2467aed99127 | 331 | cyclecount++; |
wim | 0:2467aed99127 | 332 | if (cyclecount == maxcount) { |
wim | 0:2467aed99127 | 333 | pc.printf("Freq = %d Hz\r", (cyclecount * 256 * 1000) / cycletimer.read_ms()); |
wim | 0:2467aed99127 | 334 | cyclecount = 0; |
wim | 0:2467aed99127 | 335 | cycletimer.reset(); |
wim | 0:2467aed99127 | 336 | } |
wim | 0:2467aed99127 | 337 | |
wim | 0:2467aed99127 | 338 | show_LEDS (); |
wim | 0:2467aed99127 | 339 | } |
wim | 1:e180256ba6fb | 340 | #else |
wim | 1:e180256ba6fb | 341 | // LED Display test |
wim | 1:e180256ba6fb | 342 | while (1) { |
wim | 1:e180256ba6fb | 343 | HDSP_BITE(); |
wim | 0:2467aed99127 | 344 | |
wim | 1:e180256ba6fb | 345 | cyclecount++; |
wim | 1:e180256ba6fb | 346 | if (cyclecount == 10) { |
wim | 1:e180256ba6fb | 347 | cyclecount = 0; |
wim | 1:e180256ba6fb | 348 | // LED_display.printf ("Restart "); |
wim | 1:e180256ba6fb | 349 | HDSP_Show_UDC(); |
wim | 1:e180256ba6fb | 350 | } |
wim | 1:e180256ba6fb | 351 | else { |
wim | 1:e180256ba6fb | 352 | LED_display.printf ("Cnt= %2d", cyclecount); |
wim | 1:e180256ba6fb | 353 | } |
wim | 1:e180256ba6fb | 354 | wait(2.0); |
wim | 1:e180256ba6fb | 355 | pc.printf ("."); |
wim | 1:e180256ba6fb | 356 | |
wim | 1:e180256ba6fb | 357 | show_LEDS (); |
wim | 1:e180256ba6fb | 358 | } |
wim | 1:e180256ba6fb | 359 | |
wim | 1:e180256ba6fb | 360 | #endif |
wim | 0:2467aed99127 | 361 | |
wim | 0:2467aed99127 | 362 | DBG("I'll be back...\r\r"); |
wim | 0:2467aed99127 | 363 | } |