Routines for 7 segment display. More...
#include <cfg/os.h>
#include <cfg/arch.h>
#include <compiler.h>
#include <string.h>
#include <stdlib.h>
#include <sys/nutdebug.h>
#include <sys/timer.h>
#include <stdio.h>
#include <cfg/memory.h>
#include <dev/blockdev.h>
#include <cfg/spi_7seg.h>
#include <dev/spi_7seg.h>
#include <cfg/arch/gpio.h>
#include <dev/spibus_at91.h>
Go to the source code of this file.
Data Structures | |
struct | DCB_7SEG |
Device Control Block for 7-Segment Display. More... | |
Defines | |
#define | NPRINTF(args,...) |
#define | SEG7_DIGITS 4 |
#define | SEG7_REVERSE |
#define | SEGR_NOOP 0x00 |
#define | SEGR_DIG0 0x01 |
#define | SEGR_DIG1 0x02 |
#define | SEGR_DIG2 0x03 |
#define | SEGR_DIG3 0x04 |
#define | SEGR_DIG4 0x05 |
#define | SEGR_DIG5 0x06 |
#define | SEGR_DIG6 0x07 |
#define | SEGR_DIG7 0x08 |
#define | SEGR_DEC_MODE 0x09 |
#define | SEGR_INTENSITY 0x0a |
#define | SEGR_SCAN_LIM 0x0b |
#define | SEGR_SHUTDOWN 0x0c |
#define | SEGR_FEATURE 0x0e |
#define | SEGR_DSP_TEST 0x0f |
#define | SHUTDOWN_RESET 0x00 |
#define | SHUTDOWN_SOFT 0x80 |
#define | NORM_OP_RESET 0x01 |
#define | NORM_OP_SOFT 0x81 |
#define | NO_DIG_DECODE 0x00 |
#define | DIG_0_DECODE 0x01 |
#define | DIG_0_3_DECODE 0x0f |
#define | DIG_0_7_DECODE 0xff |
#define | SEGF_EXTCLK 0x01 |
#define | SEGF_REGRES 0x02 |
#define | SEGF_DECSEL 0x04 |
#define | SEGF_SPIEN 0x08 |
#define | SEGF_BLINK 0x10 |
#define | SEGF_BLSLOW 0x20 |
#define | SEGF_BLSYNC 0x40 |
#define | SEGF_BLSTART 0x80 |
#define | SEGF_BLMASK (SEGF_BLINK|SEGF_BLSLOW) |
#define | TEST_MODE_OFF 0x00 |
#define | TEST_MODE_ON 0x01 |
#define | DISPLAY_LIMIT 2 |
#define | SPI_RATE_DISP_7SEG 400000 |
#define | SPI_MODE_DISP_7SEG SPI_MODE_3 |
#define | ICMD_UPDATE 0x01 |
#define | ICMD_INTENS 0x02 |
#define | ICMD_ESCAPE 0x80 |
Functions | |
void | Spi7SegPush (NUTDEVICE *dev) |
Push display buffer to display. | |
int | Spi7segPutc (NUTDEVICE *dev, char c) |
Send single character to 7-Segment Display. | |
int | Spi7segWrite (NUTFILE *fp, CONST void *buffer, int len) |
Send characters to 7-Segment Display. | |
void | Spi7segDot (NUTDEVICE *dev, uint8_t pos, uint8_t act) |
File Handle for 7-Sefgment Display. | |
NUTFILE * | Spi7SegOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc) |
Generate File Handle for 7-Sefgment Display. | |
int | Spi7segInit (NUTDEVICE *dev) |
Initialize the 7seg device. | |
Variables | |
NUTSPINODE | nodeSpi7SEG |
7seg SPI node implementation structure. | |
NUTDEVICE | devSpi7SEG |
7seg device implementation structure. |
#define NPRINTF | ( | args, | |
... | |||
) |
Definition at line 57 of file spi_7seg.c.
Referenced by Spi7segInit(), Spi7SegPush(), and Spi7segPutc().
#define SEG7_DIGITS 4 |
Definition at line 77 of file spi_7seg.c.
Referenced by Spi7segDot(), Spi7segInit(), Spi7SegPush(), and Spi7segPutc().
#define SEG7_REVERSE |
Definition at line 80 of file spi_7seg.c.
#define SEGR_NOOP 0x00 |
Definition at line 83 of file spi_7seg.c.
#define SEGR_DIG0 0x01 |
Definition at line 84 of file spi_7seg.c.
Referenced by Spi7segInit().
#define SEGR_DIG1 0x02 |
Definition at line 85 of file spi_7seg.c.
Referenced by Spi7segInit().
#define SEGR_DIG2 0x03 |
Definition at line 86 of file spi_7seg.c.
Referenced by Spi7segInit().
#define SEGR_DIG3 0x04 |
Definition at line 87 of file spi_7seg.c.
#define SEGR_DIG4 0x05 |
Definition at line 88 of file spi_7seg.c.
#define SEGR_DIG5 0x06 |
Definition at line 89 of file spi_7seg.c.
#define SEGR_DIG6 0x07 |
Definition at line 90 of file spi_7seg.c.
#define SEGR_DIG7 0x08 |
Definition at line 91 of file spi_7seg.c.
#define SEGR_DEC_MODE 0x09 |
Definition at line 93 of file spi_7seg.c.
Referenced by Spi7segInit().
#define SEGR_INTENSITY 0x0a |
Definition at line 94 of file spi_7seg.c.
Referenced by Spi7segInit(), and Spi7segPutc().
#define SEGR_SCAN_LIM 0x0b |
Definition at line 95 of file spi_7seg.c.
Referenced by Spi7segInit().
#define SEGR_SHUTDOWN 0x0c |
Definition at line 96 of file spi_7seg.c.
Referenced by Spi7segInit().
#define SEGR_FEATURE 0x0e |
Definition at line 97 of file spi_7seg.c.
Referenced by Spi7segPutc().
#define SEGR_DSP_TEST 0x0f |
Definition at line 98 of file spi_7seg.c.
Referenced by Spi7segInit().
#define SHUTDOWN_RESET 0x00 |
Definition at line 101 of file spi_7seg.c.
#define SHUTDOWN_SOFT 0x80 |
Definition at line 102 of file spi_7seg.c.
#define NORM_OP_RESET 0x01 |
Definition at line 103 of file spi_7seg.c.
Referenced by Spi7segInit().
#define NORM_OP_SOFT 0x81 |
Definition at line 104 of file spi_7seg.c.
#define NO_DIG_DECODE 0x00 |
Definition at line 107 of file spi_7seg.c.
Referenced by Spi7segInit().
#define DIG_0_DECODE 0x01 |
Definition at line 108 of file spi_7seg.c.
#define DIG_0_3_DECODE 0x0f |
Definition at line 109 of file spi_7seg.c.
#define DIG_0_7_DECODE 0xff |
Definition at line 110 of file spi_7seg.c.
#define SEGF_EXTCLK 0x01 |
Definition at line 113 of file spi_7seg.c.
#define SEGF_REGRES 0x02 |
Definition at line 114 of file spi_7seg.c.
#define SEGF_DECSEL 0x04 |
Definition at line 115 of file spi_7seg.c.
#define SEGF_SPIEN 0x08 |
Definition at line 116 of file spi_7seg.c.
#define SEGF_BLINK 0x10 |
Definition at line 117 of file spi_7seg.c.
Referenced by Spi7segPutc().
#define SEGF_BLSLOW 0x20 |
Definition at line 118 of file spi_7seg.c.
Referenced by Spi7segPutc().
#define SEGF_BLSYNC 0x40 |
Definition at line 119 of file spi_7seg.c.
#define SEGF_BLSTART 0x80 |
Definition at line 120 of file spi_7seg.c.
#define SEGF_BLMASK (SEGF_BLINK|SEGF_BLSLOW) |
Definition at line 122 of file spi_7seg.c.
Referenced by Spi7segPutc().
#define TEST_MODE_OFF 0x00 |
Definition at line 125 of file spi_7seg.c.
Referenced by Spi7segInit().
#define TEST_MODE_ON 0x01 |
Definition at line 126 of file spi_7seg.c.
#define DISPLAY_LIMIT 2 |
Definition at line 129 of file spi_7seg.c.
#define SPI_RATE_DISP_7SEG 400000 |
Definition at line 132 of file spi_7seg.c.
#define SPI_MODE_DISP_7SEG SPI_MODE_3 |
Definition at line 136 of file spi_7seg.c.
#define ICMD_UPDATE 0x01 |
Definition at line 140 of file spi_7seg.c.
Referenced by Spi7segPutc().
#define ICMD_INTENS 0x02 |
Definition at line 141 of file spi_7seg.c.
Referenced by Spi7segPutc().
#define ICMD_ESCAPE 0x80 |
Definition at line 142 of file spi_7seg.c.
Referenced by Spi7segPutc().
void Spi7SegPush | ( | NUTDEVICE * | dev | ) |
Push display buffer to display.
dev | Display device. |
Definition at line 289 of file spi_7seg.c.
References _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, DCB_7SEG::digit, NPRINTF, NUTASSERT, and SEG7_DIGITS.
Referenced by Spi7segDot(), and Spi7segPutc().
int Spi7segPutc | ( | NUTDEVICE * | dev, |
char | c | ||
) |
Send single character to 7-Segment Display.
A newline character will reset write pointer to digit 0. Carriage return is ignored.
Definition at line 329 of file spi_7seg.c.
References _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, DCB_7SEG::digit, DCB_7SEG::dip, DCB_7SEG::freg, DCB_7SEG::icmd, ICMD_ESCAPE, ICMD_INTENS, ICMD_UPDATE, memset(), NPRINTF, NUTASSERT, SEG7_DIGITS, SEGF_BLINK, SEGF_BLMASK, SEGF_BLSLOW, SEGR_FEATURE, SEGR_INTENSITY, and Spi7SegPush().
Referenced by Spi7segWrite().
int Spi7segWrite | ( | NUTFILE * | fp, |
CONST void * | buffer, | ||
int | len | ||
) |
Send characters to 7-Segment Display.
A newline character will reset write pointer to digit 0. Carriage return is ignored.
Definition at line 457 of file spi_7seg.c.
References CONST, _NUTFILE::nf_dev, NUTASSERT, and Spi7segPutc().
File Handle for 7-Sefgment Display.
pos | Selects the digit. |
act | Selects the action for the digits decimal dot. |
Definition at line 478 of file spi_7seg.c.
References _NUTDEVICE::dev_dcb, DCB_7SEG::digit, DOT_7SEG_CLR, DOT_7SEG_FLIP, DOT_7SEG_SET, NUTASSERT, SEG7_DIGITS, and Spi7SegPush().
Generate File Handle for 7-Sefgment Display.
dev | Specifies the 7seg device. |
Definition at line 506 of file spi_7seg.c.
References malloc(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, NUTASSERT, and NUTFILE_EOF.
int Spi7segInit | ( | NUTDEVICE * | dev | ) |
Initialize the 7seg device.
This routine determines the 7seg type. It is internally called by Nut/OS during device registration.
The driver framework may call this function more than once.
dev | Specifies the 7seg device. |
Definition at line 556 of file spi_7seg.c.
References _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, DCB_7SEG::freg, malloc(), memset(), NO_DIG_DECODE, NORM_OP_RESET, NPRINTF, NUTASSERT, SEG7_DIGITS, SEGR_DEC_MODE, SEGR_DIG0, SEGR_DIG1, SEGR_DIG2, SEGR_DSP_TEST, SEGR_INTENSITY, SEGR_SCAN_LIM, SEGR_SHUTDOWN, and TEST_MODE_OFF.
{ NULL, NULL, SPI_RATE_DISP_7SEG, SPI_MODE_DISP_7SEG, 8, 0 }
7seg SPI node implementation structure.
Definition at line 604 of file spi_7seg.c.
{ NULL, {'7', 'S', 'E', 'G', 0, 0, 0}, IFTYP_CHAR, 0, 0, &nodeSpi7SEG, 0, Spi7segInit, Spi7SegIOCtl, 0, Spi7segWrite, 0, Spi7SegOpen, Spi7SegClose, 0 }
7seg device implementation structure.
Definition at line 616 of file spi_7seg.c.