Library for the MAX7219 LED display driver

Dependents:   MAXREFDES99_demo MAXREFDES99_RTC_Display nucleo_spi_max7219_led8x8 max7219 ... more

Committer:
j3
Date:
Thu May 12 19:31:40 2016 +0000
Revision:
3:c245060379b9
Parent:
2:9150a0dc77a3
Child:
4:b5e4379a3d90
fixed caps for autodoc tag descriptions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:798fb343e022 1 /******************************************************************//**
j3 0:798fb343e022 2 * @file max7219.h
j3 0:798fb343e022 3 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:798fb343e022 4 *
j3 0:798fb343e022 5 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:798fb343e022 6 * copy of this software and associated documentation files (the "Software"),
j3 0:798fb343e022 7 * to deal in the Software without restriction, including without limitation
j3 0:798fb343e022 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:798fb343e022 9 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:798fb343e022 10 * Software is furnished to do so, subject to the following conditions:
j3 0:798fb343e022 11 *
j3 0:798fb343e022 12 * The above copyright notice and this permission notice shall be included
j3 0:798fb343e022 13 * in all copies or substantial portions of the Software.
j3 0:798fb343e022 14 *
j3 0:798fb343e022 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:798fb343e022 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:798fb343e022 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:798fb343e022 18 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:798fb343e022 19 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:798fb343e022 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:798fb343e022 21 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:798fb343e022 22 *
j3 0:798fb343e022 23 * Except as contained in this notice, the name of Maxim Integrated
j3 0:798fb343e022 24 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:798fb343e022 25 * Products, Inc. Branding Policy.
j3 0:798fb343e022 26 *
j3 0:798fb343e022 27 * The mere transfer of this software does not imply any licenses
j3 0:798fb343e022 28 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:798fb343e022 29 * trademarks, maskwork rights, or any other form of intellectual
j3 0:798fb343e022 30 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:798fb343e022 31 * ownership rights.
j3 0:798fb343e022 32 **********************************************************************/
j3 0:798fb343e022 33
j3 0:798fb343e022 34
j3 0:798fb343e022 35 #ifndef MAX7219_H
j3 0:798fb343e022 36 #define MAX7219_H
j3 0:798fb343e022 37
j3 0:798fb343e022 38 #include "mbed.h"
j3 0:798fb343e022 39
j3 0:798fb343e022 40
j3 2:9150a0dc77a3 41 /**
j3 2:9150a0dc77a3 42 * @brief Structure for device configuration
j3 2:9150a0dc77a3 43 * @code
j3 2:9150a0dc77a3 44 * #include "max7219.h"
j3 2:9150a0dc77a3 45 *
j3 2:9150a0dc77a3 46 * max7219_configuration_t cfg = {
j3 2:9150a0dc77a3 47 * .device_number = 1,
j3 2:9150a0dc77a3 48 * .decode_mode = 0,
j3 2:9150a0dc77a3 49 * .intensity = Max7219::MAX7219_INTENSITY_8,
j3 2:9150a0dc77a3 50 * .scan_limit = Max7219::MAX7219_SCAN_8
j3 2:9150a0dc77a3 51 * };
j3 2:9150a0dc77a3 52 * @endcode
j3 2:9150a0dc77a3 53 */
j3 0:798fb343e022 54 typedef struct
j3 0:798fb343e022 55 {
j3 0:798fb343e022 56 uint8_t device_number;
j3 0:798fb343e022 57 uint8_t decode_mode;
j3 0:798fb343e022 58 uint8_t intensity;
j3 0:798fb343e022 59 uint8_t scan_limit;
j3 0:798fb343e022 60 }max7219_configuration_t;
j3 0:798fb343e022 61
j3 0:798fb343e022 62
j3 2:9150a0dc77a3 63 /**
j3 2:9150a0dc77a3 64 * @brief Serially Interfaced, 8-Digit, LED Display Driver
j3 2:9150a0dc77a3 65 *
j3 2:9150a0dc77a3 66 * @details The MAX7219/MAX7221 are compact, serial input/output common-cathode
j3 2:9150a0dc77a3 67 * display drivers that interface microprocessors (µPs) to 7-segment numeric
j3 2:9150a0dc77a3 68 * LED displays of up to 8 digits, bar-graph displays, or 64 individual LEDs.
j3 2:9150a0dc77a3 69 * Included on-chip are a BCD code-B decoder, multiplex scan circuitry, segment
j3 2:9150a0dc77a3 70 * and digit drivers, and an 8x8 static RAM that stores each digit. Only one
j3 2:9150a0dc77a3 71 * external resistor is required to set the segment current for all LEDs.
j3 2:9150a0dc77a3 72 * The MAX7221 is compatible with SPI™, QSPI™, and MICROWIRE™, and has
j3 2:9150a0dc77a3 73 * slew-rate-limited segment drivers to reduce EMI.
j3 2:9150a0dc77a3 74 *
j3 2:9150a0dc77a3 75 * @code
j3 2:9150a0dc77a3 76 * #include "mbed.h"
j3 2:9150a0dc77a3 77 * #include "max7219.h"
j3 2:9150a0dc77a3 78 *
j3 2:9150a0dc77a3 79 * Max7219 max7219(SPI0_MOSI, SPI0_MISO, SPI0_SCK, SPI0_SS);
j3 2:9150a0dc77a3 80 *
j3 2:9150a0dc77a3 81 * int main()
j3 2:9150a0dc77a3 82 * {
j3 2:9150a0dc77a3 83 * max7219_configuration_t cfg = {
j3 2:9150a0dc77a3 84 * .device_number = 1,
j3 2:9150a0dc77a3 85 * .decode_mode = 0,
j3 2:9150a0dc77a3 86 * .intensity = Max7219::MAX7219_INTENSITY_8,
j3 2:9150a0dc77a3 87 * .scan_limit = Max7219::MAX7219_SCAN_8
j3 2:9150a0dc77a3 88 * };
j3 2:9150a0dc77a3 89 *
j3 2:9150a0dc77a3 90 * max7219.init_device(cfg);
j3 2:9150a0dc77a3 91 * max7219.enable_device(1);
j3 2:9150a0dc77a3 92 * max7219.set_display_test();
j3 2:9150a0dc77a3 93 * wait(1);
j3 2:9150a0dc77a3 94 * max7219.clear_display_test();
j3 2:9150a0dc77a3 95 *
j3 2:9150a0dc77a3 96 * while (1) {
j3 2:9150a0dc77a3 97 * max7219.write_digit(1, Max7219::MAX7219_DIGIT_0, ...
j3 2:9150a0dc77a3 98 * }
j3 2:9150a0dc77a3 99 * }
j3 2:9150a0dc77a3 100 * @endcode
j3 2:9150a0dc77a3 101 */
j3 0:798fb343e022 102 class Max7219
j3 0:798fb343e022 103 {
j3 0:798fb343e022 104 public:
j3 0:798fb343e022 105
j3 2:9150a0dc77a3 106 /**
j3 2:9150a0dc77a3 107 * @brief Digit and Control Registers
j3 2:9150a0dc77a3 108 * @details The 14 addressable digit and control registers.
j3 2:9150a0dc77a3 109 */
j3 0:798fb343e022 110 typedef enum
j3 0:798fb343e022 111 {
j3 0:798fb343e022 112 MAX7219_NO_OP = 0,
j3 0:798fb343e022 113 MAX7219_DIGIT_0,
j3 0:798fb343e022 114 MAX7219_DIGIT_1,
j3 0:798fb343e022 115 MAX7219_DIGIT_2,
j3 0:798fb343e022 116 MAX7219_DIGIT_3,
j3 0:798fb343e022 117 MAX7219_DIGIT_4,
j3 0:798fb343e022 118 MAX7219_DIGIT_5,
j3 0:798fb343e022 119 MAX7219_DIGIT_6,
j3 0:798fb343e022 120 MAX7219_DIGIT_7,
j3 0:798fb343e022 121 MAX7219_DECODE_MODE,
j3 0:798fb343e022 122 MAX7219_INTENSITY,
j3 0:798fb343e022 123 MAX7219_SCAN_LIMIT,
j3 0:798fb343e022 124 MAX7219_SHUTDOWN,
j3 0:798fb343e022 125 MAX7219_DISPLAY_TEST = 15
j3 0:798fb343e022 126 }max7219_register_e;
j3 0:798fb343e022 127
j3 0:798fb343e022 128
j3 2:9150a0dc77a3 129 /**
j3 2:9150a0dc77a3 130 * @brief Intensity values
j3 2:9150a0dc77a3 131 * @details Digital control of display brightness is provided by an
j3 2:9150a0dc77a3 132 * internal pulse-width modulator, which is controlled by
j3 2:9150a0dc77a3 133 * the lower nibble of the intensity register.
j3 2:9150a0dc77a3 134 */
j3 0:798fb343e022 135 typedef enum
j3 0:798fb343e022 136 {
j3 0:798fb343e022 137 MAX7219_INTENSITY_0 = 0,
j3 0:798fb343e022 138 MAX7219_INTENSITY_1,
j3 0:798fb343e022 139 MAX7219_INTENSITY_2,
j3 0:798fb343e022 140 MAX7219_INTENSITY_3,
j3 0:798fb343e022 141 MAX7219_INTENSITY_4,
j3 0:798fb343e022 142 MAX7219_INTENSITY_5,
j3 0:798fb343e022 143 MAX7219_INTENSITY_6,
j3 0:798fb343e022 144 MAX7219_INTENSITY_7,
j3 0:798fb343e022 145 MAX7219_INTENSITY_8,
j3 0:798fb343e022 146 MAX7219_INTENSITY_9,
j3 0:798fb343e022 147 MAX7219_INTENSITY_A,
j3 0:798fb343e022 148 MAX7219_INTENSITY_B,
j3 0:798fb343e022 149 MAX7219_INTENSITY_C,
j3 0:798fb343e022 150 MAX7219_INTENSITY_D,
j3 0:798fb343e022 151 MAX7219_INTENSITY_E,
j3 0:798fb343e022 152 MAX7219_INTENSITY_F
j3 0:798fb343e022 153 }max7219_intensity_e;
j3 0:798fb343e022 154
j3 0:798fb343e022 155
j3 2:9150a0dc77a3 156 /**
j3 2:9150a0dc77a3 157 * @brief Scan limit for mutiplexing digits
j3 2:9150a0dc77a3 158 * @details The scan-limit register sets how many digits are
j3 2:9150a0dc77a3 159 * displayed, from 1 to 8. They are displayed in a multiplexed
j3 2:9150a0dc77a3 160 * manner with a typical display scan rate of 800Hz with 8
j3 2:9150a0dc77a3 161 * digits displayed.
j3 2:9150a0dc77a3 162 */
j3 0:798fb343e022 163 typedef enum
j3 0:798fb343e022 164 {
j3 0:798fb343e022 165 MAX7219_SCAN_1 = 0,
j3 0:798fb343e022 166 MAX7219_SCAN_2,
j3 0:798fb343e022 167 MAX7219_SCAN_3,
j3 0:798fb343e022 168 MAX7219_SCAN_4,
j3 0:798fb343e022 169 MAX7219_SCAN_5,
j3 0:798fb343e022 170 MAX7219_SCAN_6,
j3 0:798fb343e022 171 MAX7219_SCAN_7,
j3 0:798fb343e022 172 MAX7219_SCAN_8
j3 0:798fb343e022 173 }max7219_scan_limit_e;
j3 0:798fb343e022 174
j3 0:798fb343e022 175
j3 0:798fb343e022 176 /**********************************************************//**
j3 0:798fb343e022 177 * @brief Constructor for Max7219 Class.
j3 0:798fb343e022 178 *
j3 0:798fb343e022 179 * @details Allows user to pass pointer to existing SPI bus
j3 0:798fb343e022 180 *
j3 0:798fb343e022 181 * On Entry:
j3 0:798fb343e022 182 * @param[in] spi_bus - pointer to existing SPI object
j3 0:798fb343e022 183 * @param[in] cs - pin to use for cs
j3 0:798fb343e022 184 *
j3 0:798fb343e022 185 * On Exit:
j3 0:798fb343e022 186 * @return none
j3 0:798fb343e022 187 **************************************************************/
j3 0:798fb343e022 188 Max7219(SPI *spi_bus, PinName cs);
j3 0:798fb343e022 189
j3 0:798fb343e022 190
j3 0:798fb343e022 191 /**********************************************************//**
j3 0:798fb343e022 192 * @brief Constructor for Max7219 Class.
j3 0:798fb343e022 193 *
j3 0:798fb343e022 194 * @details Allows user to specify SPI peripheral to use
j3 0:798fb343e022 195 *
j3 0:798fb343e022 196 * On Entry:
j3 0:798fb343e022 197 * @param[in] mosi - pin to use for mosi
j3 0:798fb343e022 198 * @param[in] miso - pin to use for miso
j3 0:798fb343e022 199 * @param[in] sclk - pin to use for sclk
j3 0:798fb343e022 200 * @param[in] cs - pin to use for cs
j3 0:798fb343e022 201 *
j3 0:798fb343e022 202 * On Exit:
j3 0:798fb343e022 203 * @return none
j3 0:798fb343e022 204 **************************************************************/
j3 0:798fb343e022 205 Max7219(PinName mosi, PinName miso, PinName sclk, PinName cs);
j3 0:798fb343e022 206
j3 0:798fb343e022 207
j3 0:798fb343e022 208 /**********************************************************//**
j3 0:798fb343e022 209 * @brief Default destructor for Max7219 Class.
j3 0:798fb343e022 210 *
j3 0:798fb343e022 211 * @details Destroys SPI object if owner
j3 0:798fb343e022 212 *
j3 0:798fb343e022 213 * On Entry:
j3 0:798fb343e022 214 *
j3 0:798fb343e022 215 * On Exit:
j3 0:798fb343e022 216 * @return none
j3 0:798fb343e022 217 **************************************************************/
j3 0:798fb343e022 218 ~Max7219();
j3 0:798fb343e022 219
j3 0:798fb343e022 220
j3 0:798fb343e022 221 /**********************************************************//**
j3 0:798fb343e022 222 * @brief Sets the number of MAX7219 devices being used.
j3 0:798fb343e022 223 * Defaults to one
j3 0:798fb343e022 224 *
j3 0:798fb343e022 225 * @details
j3 0:798fb343e022 226 *
j3 0:798fb343e022 227 * On Entry:
j3 0:798fb343e022 228 * @param[in] num_devices - number of MAX7219 devices being
j3 0:798fb343e022 229 * used, max of 255
j3 0:798fb343e022 230 *
j3 0:798fb343e022 231 * On Exit:
j3 0:798fb343e022 232 * @return returns number of devices
j3 0:798fb343e022 233 **************************************************************/
j3 0:798fb343e022 234 int32_t set_num_devices(uint8_t num_devices);
j3 0:798fb343e022 235
j3 0:798fb343e022 236
j3 0:798fb343e022 237 /**********************************************************//**
j3 0:798fb343e022 238 * @brief Tests all devices being used
j3 0:798fb343e022 239 *
j3 0:798fb343e022 240 * @details Sets bit0 of DISPLAY_TEST regiser in all devices
j3 0:798fb343e022 241 *
j3 0:798fb343e022 242 * On Entry:
j3 0:798fb343e022 243 *
j3 0:798fb343e022 244 * On Exit:
j3 0:798fb343e022 245 * @return none
j3 0:798fb343e022 246 **************************************************************/
j3 0:798fb343e022 247 void set_display_test(void);
j3 0:798fb343e022 248
j3 0:798fb343e022 249
j3 0:798fb343e022 250 /**********************************************************//**
j3 0:798fb343e022 251 * @brief Stops test
j3 0:798fb343e022 252 *
j3 0:798fb343e022 253 * @details Clear bit0 of DISPLAY_TEST regiser in all devices
j3 0:798fb343e022 254 *
j3 0:798fb343e022 255 * On Entry:
j3 0:798fb343e022 256 *
j3 0:798fb343e022 257 * On Exit:
j3 0:798fb343e022 258 * @return none
j3 0:798fb343e022 259 **************************************************************/
j3 0:798fb343e022 260 void clear_display_test(void);
j3 0:798fb343e022 261
j3 0:798fb343e022 262
j3 0:798fb343e022 263 /**********************************************************//**
j3 3:c245060379b9 264 * @brief Initializes specific device in display with given
j3 0:798fb343e022 265 * config data
j3 0:798fb343e022 266 *
j3 0:798fb343e022 267 * @details
j3 0:798fb343e022 268 *
j3 0:798fb343e022 269 * On Entry:
j3 1:90a7cf4e7d26 270 * @param[in] config - Structure containing configuration
j3 1:90a7cf4e7d26 271 * data of device
j3 0:798fb343e022 272 *
j3 0:798fb343e022 273 * On Exit:
j3 1:90a7cf4e7d26 274 * @return returns 0 on success
j3 1:90a7cf4e7d26 275 * returns -1 if device number is > _num_devices
j3 1:90a7cf4e7d26 276 * returns -2 if device number is 0
j3 0:798fb343e022 277 **************************************************************/
j3 1:90a7cf4e7d26 278 int32_t init_device(max7219_configuration_t config);
j3 0:798fb343e022 279
j3 0:798fb343e022 280
j3 0:798fb343e022 281 /**********************************************************//**
j3 3:c245060379b9 282 * @brief Initializes all devices with given config data
j3 0:798fb343e022 283 *
j3 3:c245060379b9 284 * @details All devices are configured with given data
j3 0:798fb343e022 285 *
j3 0:798fb343e022 286 * On Entry:
j3 1:90a7cf4e7d26 287 * @param[in] config - Structure containing configuration
j3 1:90a7cf4e7d26 288 * data
j3 0:798fb343e022 289 * On Exit:
j3 0:798fb343e022 290 * @return none
j3 0:798fb343e022 291 **************************************************************/
j3 0:798fb343e022 292 void init_display(max7219_configuration_t config);
j3 0:798fb343e022 293
j3 0:798fb343e022 294
j3 0:798fb343e022 295 /**********************************************************//**
j3 3:c245060379b9 296 * @brief Enables specific device in display
j3 0:798fb343e022 297 *
j3 0:798fb343e022 298 * @details
j3 0:798fb343e022 299 *
j3 0:798fb343e022 300 * On Entry:
j3 1:90a7cf4e7d26 301 * @param[in] device_number - device to enable
j3 0:798fb343e022 302 *
j3 0:798fb343e022 303 * On Exit:
j3 1:90a7cf4e7d26 304 * @return returns 0 on success
j3 1:90a7cf4e7d26 305 * returns -1 if device number is > _num_devices
j3 1:90a7cf4e7d26 306 * returns -2 if device number is 0
j3 0:798fb343e022 307 **************************************************************/
j3 0:798fb343e022 308 int32_t enable_device(uint8_t device_number);
j3 0:798fb343e022 309
j3 0:798fb343e022 310
j3 0:798fb343e022 311 /**********************************************************//**
j3 3:c245060379b9 312 * @brief Enables all device in display
j3 0:798fb343e022 313 *
j3 0:798fb343e022 314 * @details
j3 0:798fb343e022 315 *
j3 0:798fb343e022 316 * On Entry:
j3 0:798fb343e022 317 *
j3 0:798fb343e022 318 * On Exit:
j3 0:798fb343e022 319 * @return none
j3 0:798fb343e022 320 **************************************************************/
j3 0:798fb343e022 321 void enable_display(void);
j3 0:798fb343e022 322
j3 0:798fb343e022 323
j3 0:798fb343e022 324 /**********************************************************//**
j3 3:c245060379b9 325 * @brief Disables specific device in display
j3 0:798fb343e022 326 *
j3 0:798fb343e022 327 * @details
j3 0:798fb343e022 328 *
j3 0:798fb343e022 329 * On Entry:
j3 1:90a7cf4e7d26 330 * @param[in] device_number - device to disable
j3 0:798fb343e022 331 *
j3 0:798fb343e022 332 * On Exit:
j3 1:90a7cf4e7d26 333 * @return returns 0 on success,
j3 1:90a7cf4e7d26 334 * returns -1 if device number is > _num_devices
j3 1:90a7cf4e7d26 335 * returns -2 if device number is 0
j3 0:798fb343e022 336 **************************************************************/
j3 0:798fb343e022 337 int32_t disable_device(uint8_t device_number);
j3 0:798fb343e022 338
j3 0:798fb343e022 339
j3 0:798fb343e022 340 /**********************************************************//**
j3 3:c245060379b9 341 * @brief Disables all devices in display
j3 0:798fb343e022 342 *
j3 0:798fb343e022 343 * @details
j3 0:798fb343e022 344 *
j3 0:798fb343e022 345 * On Entry:
j3 0:798fb343e022 346 *
j3 0:798fb343e022 347 * On Exit:
j3 0:798fb343e022 348 * @return none
j3 0:798fb343e022 349 **************************************************************/
j3 0:798fb343e022 350 void disable_display(void);
j3 0:798fb343e022 351
j3 0:798fb343e022 352
j3 0:798fb343e022 353 /**********************************************************//**
j3 3:c245060379b9 354 * @brief Writes digit of given device with given data, user
j3 0:798fb343e022 355 * must enter correct data for decode_mode chosen
j3 0:798fb343e022 356 *
j3 0:798fb343e022 357 * @details
j3 0:798fb343e022 358 *
j3 0:798fb343e022 359 * On Entry:
j3 1:90a7cf4e7d26 360 * @param[in] device_number - device to write too
j3 1:90a7cf4e7d26 361 * @param[in] digit - digit to write
j3 1:90a7cf4e7d26 362 * @param[in] data - data to write
j3 0:798fb343e022 363 *
j3 0:798fb343e022 364 * On Exit:
j3 1:90a7cf4e7d26 365 * @return returns 0 on success,
j3 1:90a7cf4e7d26 366 * returns -1 if device number is > _num_devices
j3 1:90a7cf4e7d26 367 * returns -2 if device number is 0
j3 1:90a7cf4e7d26 368 * returns -3 if digit > 8
j3 1:90a7cf4e7d26 369 * returns -4 if digit < 1
j3 0:798fb343e022 370 **************************************************************/
j3 0:798fb343e022 371 int32_t write_digit(uint8_t device_number, uint8_t digit, uint8_t data);
j3 0:798fb343e022 372
j3 0:798fb343e022 373
j3 0:798fb343e022 374 /**********************************************************//**
j3 3:c245060379b9 375 * @brief Clears digit of given device
j3 0:798fb343e022 376 *
j3 0:798fb343e022 377 * @details
j3 0:798fb343e022 378 *
j3 0:798fb343e022 379 * On Entry:
j3 1:90a7cf4e7d26 380 * @param[in] device_number - device to write too
j3 1:90a7cf4e7d26 381 * @param[in] digit - digit to clear
j3 0:798fb343e022 382 *
j3 0:798fb343e022 383 * On Exit:
j3 1:90a7cf4e7d26 384 * @return returns 0 on success,
j3 1:90a7cf4e7d26 385 * returns -1 if device number is > _num_devices
j3 1:90a7cf4e7d26 386 * returns -2 if device number is 0
j3 1:90a7cf4e7d26 387 * returns -3 if digit > 8
j3 1:90a7cf4e7d26 388 * returns -4 if digit < 1
j3 0:798fb343e022 389 **************************************************************/
j3 0:798fb343e022 390 int32_t clear_digit(uint8_t device_number, uint8_t digit);
j3 0:798fb343e022 391
j3 0:798fb343e022 392
j3 0:798fb343e022 393 /**********************************************************//**
j3 3:c245060379b9 394 * @brief Turns on all segments/digits of given device
j3 0:798fb343e022 395 *
j3 0:798fb343e022 396 * @details
j3 0:798fb343e022 397 *
j3 0:798fb343e022 398 * On Entry:
j3 1:90a7cf4e7d26 399 * @param[in] device_number - device to write too
j3 0:798fb343e022 400 *
j3 0:798fb343e022 401 * On Exit:
j3 1:90a7cf4e7d26 402 * @return returns 0 on success,
j3 1:90a7cf4e7d26 403 * returns -1 if device number is > _num_devices
j3 1:90a7cf4e7d26 404 * returns -2 if device number is 0
j3 0:798fb343e022 405 **************************************************************/
j3 0:798fb343e022 406 int32_t device_all_on(uint8_t device_number);
j3 0:798fb343e022 407
j3 0:798fb343e022 408
j3 0:798fb343e022 409 /**********************************************************//**
j3 3:c245060379b9 410 * @brief Turns off all segments/digits of given device
j3 0:798fb343e022 411 *
j3 0:798fb343e022 412 * @details
j3 0:798fb343e022 413 *
j3 0:798fb343e022 414 * On Entry:
j3 1:90a7cf4e7d26 415 * @param[in] device_number - device to write too
j3 0:798fb343e022 416 *
j3 0:798fb343e022 417 * On Exit:
j3 1:90a7cf4e7d26 418 * @return returns 0 on success,
j3 1:90a7cf4e7d26 419 * returns -1 if device number is > _num_devices
j3 1:90a7cf4e7d26 420 * returns -2 if device number is 0
j3 0:798fb343e022 421 **************************************************************/
j3 0:798fb343e022 422 int32_t device_all_off(uint8_t device_number);
j3 0:798fb343e022 423
j3 0:798fb343e022 424
j3 0:798fb343e022 425 /**********************************************************//**
j3 3:c245060379b9 426 * @brief Turns on all segments/digits of display
j3 0:798fb343e022 427 *
j3 0:798fb343e022 428 * @details
j3 0:798fb343e022 429 *
j3 0:798fb343e022 430 * On Entry:
j3 0:798fb343e022 431 *
j3 0:798fb343e022 432 * On Exit:
j3 0:798fb343e022 433 * @return none
j3 0:798fb343e022 434 **************************************************************/
j3 0:798fb343e022 435 void display_all_on(void);
j3 0:798fb343e022 436
j3 0:798fb343e022 437
j3 0:798fb343e022 438 /**********************************************************//**
j3 3:c245060379b9 439 * @brief Turns off all segments/digits of display
j3 0:798fb343e022 440 *
j3 0:798fb343e022 441 * @details
j3 0:798fb343e022 442 *
j3 0:798fb343e022 443 * On Entry:
j3 0:798fb343e022 444 *
j3 0:798fb343e022 445 * On Exit:
j3 0:798fb343e022 446 * @return none
j3 0:798fb343e022 447 **************************************************************/
j3 0:798fb343e022 448 void display_all_off(void);
j3 0:798fb343e022 449
j3 0:798fb343e022 450
j3 0:798fb343e022 451 private:
j3 0:798fb343e022 452
j3 0:798fb343e022 453 SPI *_p_spi;
j3 0:798fb343e022 454 DigitalOut *_p_cs;
j3 0:798fb343e022 455 bool _spi_owner;
j3 0:798fb343e022 456
j3 0:798fb343e022 457 uint8_t _num_devices;
j3 0:798fb343e022 458
j3 0:798fb343e022 459 };
j3 0:798fb343e022 460 #endif /* MAX7219_H*/