wdenk | 3be717f | 2004-01-03 19:43:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003, Li-Pro.Net <www.li-pro.net> |
| 3 | * Stephan Linz <linz@li-pro.net> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 3be717f | 2004-01-03 19:43:48 +0000 | [diff] [blame] | 6 | * |
| 7 | * common/sevenseg.h |
| 8 | * |
| 9 | * NIOS PIO based seven segment led support functions |
| 10 | */ |
| 11 | |
| 12 | #ifndef __DK1S10_SEVENSEG_H__ |
| 13 | #define __DK1S10_SEVENSEG_H__ |
| 14 | |
| 15 | #ifdef CONFIG_SEVENSEG |
| 16 | |
| 17 | /* |
| 18 | * 15 8 7 0 |
| 19 | * |-----------------------|--------| |
| 20 | * | controll value | value | |
| 21 | * ---------------------------------- |
| 22 | */ |
| 23 | #define SEVENSEG_RAW (int)(0) /* write out byte value (hex) */ |
| 24 | #define SEVENSEG_OFF (int)( 1 << 8) /* display switch off */ |
| 25 | #define SEVENSEG_SET_DPL (int)( 2 << 8) /* set dp low nibble */ |
| 26 | #define SEVENSEG_SET_DPH (int)( 3 << 8) /* set dp high nibble */ |
| 27 | #define SEVENSEG_RES_DPL (int)( 4 << 8) /* reset dp low nibble */ |
| 28 | #define SEVENSEG_RES_DPH (int)( 5 << 8) /* reset dp high nibble */ |
| 29 | #define SEVENSEG_TOG_DPL (int)( 6 << 8) /* toggle dp low nibble */ |
| 30 | #define SEVENSEG_TOG_DPH (int)( 7 << 8) /* toggle dp high nibble */ |
| 31 | #define SEVENSEG_LO (int)( 8 << 8) /* write out low nibble only */ |
| 32 | #define SEVENSEG_HI (int)( 9 << 8) /* write out high nibble only */ |
| 33 | #define SEVENSEG_STR (int)(10 << 8) /* write out a string */ |
| 34 | |
| 35 | #define SEVENSEG_MASK_VAL (0xff) /* only used by SEVENSEG_RAW */ |
| 36 | #define SEVENSEG_MASK_CTRL (~SEVENSEG_MASK_VAL) |
| 37 | |
| 38 | #ifdef SEVENSEG_DIGIT_HI_LO_EQUAL |
| 39 | |
| 40 | #define SEVENSEG_DIGITS_0 ( SEVENSEG_DIGIT_A \ |
| 41 | | SEVENSEG_DIGIT_B \ |
| 42 | | SEVENSEG_DIGIT_C \ |
| 43 | | SEVENSEG_DIGIT_D \ |
| 44 | | SEVENSEG_DIGIT_E \ |
| 45 | | SEVENSEG_DIGIT_F ) |
| 46 | #define SEVENSEG_DIGITS_1 ( SEVENSEG_DIGIT_B \ |
| 47 | | SEVENSEG_DIGIT_C ) |
| 48 | #define SEVENSEG_DIGITS_2 ( SEVENSEG_DIGIT_A \ |
| 49 | | SEVENSEG_DIGIT_B \ |
| 50 | | SEVENSEG_DIGIT_D \ |
| 51 | | SEVENSEG_DIGIT_E \ |
| 52 | | SEVENSEG_DIGIT_G ) |
| 53 | #define SEVENSEG_DIGITS_3 ( SEVENSEG_DIGIT_A \ |
| 54 | | SEVENSEG_DIGIT_B \ |
| 55 | | SEVENSEG_DIGIT_C \ |
| 56 | | SEVENSEG_DIGIT_D \ |
| 57 | | SEVENSEG_DIGIT_G ) |
| 58 | #define SEVENSEG_DIGITS_4 ( SEVENSEG_DIGIT_B \ |
| 59 | | SEVENSEG_DIGIT_C \ |
| 60 | | SEVENSEG_DIGIT_F \ |
| 61 | | SEVENSEG_DIGIT_G ) |
| 62 | #define SEVENSEG_DIGITS_5 ( SEVENSEG_DIGIT_A \ |
| 63 | | SEVENSEG_DIGIT_C \ |
| 64 | | SEVENSEG_DIGIT_D \ |
| 65 | | SEVENSEG_DIGIT_F \ |
| 66 | | SEVENSEG_DIGIT_G ) |
| 67 | #define SEVENSEG_DIGITS_6 ( SEVENSEG_DIGIT_A \ |
| 68 | | SEVENSEG_DIGIT_C \ |
| 69 | | SEVENSEG_DIGIT_D \ |
| 70 | | SEVENSEG_DIGIT_E \ |
| 71 | | SEVENSEG_DIGIT_F \ |
| 72 | | SEVENSEG_DIGIT_G ) |
| 73 | #define SEVENSEG_DIGITS_7 ( SEVENSEG_DIGIT_A \ |
| 74 | | SEVENSEG_DIGIT_B \ |
| 75 | | SEVENSEG_DIGIT_C ) |
| 76 | #define SEVENSEG_DIGITS_8 ( SEVENSEG_DIGIT_A \ |
| 77 | | SEVENSEG_DIGIT_B \ |
| 78 | | SEVENSEG_DIGIT_C \ |
| 79 | | SEVENSEG_DIGIT_D \ |
| 80 | | SEVENSEG_DIGIT_E \ |
| 81 | | SEVENSEG_DIGIT_F \ |
| 82 | | SEVENSEG_DIGIT_G ) |
| 83 | #define SEVENSEG_DIGITS_9 ( SEVENSEG_DIGIT_A \ |
| 84 | | SEVENSEG_DIGIT_B \ |
| 85 | | SEVENSEG_DIGIT_C \ |
| 86 | | SEVENSEG_DIGIT_D \ |
| 87 | | SEVENSEG_DIGIT_F \ |
| 88 | | SEVENSEG_DIGIT_G ) |
| 89 | #define SEVENSEG_DIGITS_A ( SEVENSEG_DIGIT_A \ |
| 90 | | SEVENSEG_DIGIT_B \ |
| 91 | | SEVENSEG_DIGIT_C \ |
| 92 | | SEVENSEG_DIGIT_E \ |
| 93 | | SEVENSEG_DIGIT_F \ |
| 94 | | SEVENSEG_DIGIT_G ) |
| 95 | #define SEVENSEG_DIGITS_B ( SEVENSEG_DIGIT_C \ |
| 96 | | SEVENSEG_DIGIT_D \ |
| 97 | | SEVENSEG_DIGIT_E \ |
| 98 | | SEVENSEG_DIGIT_F \ |
| 99 | | SEVENSEG_DIGIT_G ) |
| 100 | #define SEVENSEG_DIGITS_C ( SEVENSEG_DIGIT_D \ |
| 101 | | SEVENSEG_DIGIT_E \ |
| 102 | | SEVENSEG_DIGIT_G ) |
| 103 | #define SEVENSEG_DIGITS_D ( SEVENSEG_DIGIT_B \ |
| 104 | | SEVENSEG_DIGIT_C \ |
| 105 | | SEVENSEG_DIGIT_D \ |
| 106 | | SEVENSEG_DIGIT_E \ |
| 107 | | SEVENSEG_DIGIT_G ) |
| 108 | #define SEVENSEG_DIGITS_E ( SEVENSEG_DIGIT_A \ |
| 109 | | SEVENSEG_DIGIT_D \ |
| 110 | | SEVENSEG_DIGIT_E \ |
| 111 | | SEVENSEG_DIGIT_F \ |
| 112 | | SEVENSEG_DIGIT_G ) |
| 113 | #define SEVENSEG_DIGITS_F ( SEVENSEG_DIGIT_A \ |
| 114 | | SEVENSEG_DIGIT_E \ |
| 115 | | SEVENSEG_DIGIT_F \ |
| 116 | | SEVENSEG_DIGIT_G ) |
| 117 | |
| 118 | #else /* !SEVENSEG_DIGIT_HI_LO_EQUAL */ |
| 119 | #error SEVENSEG: different pin asssignments not supported |
| 120 | #endif |
| 121 | |
| 122 | void sevenseg_set(int value); |
| 123 | |
| 124 | #endif /* CONFIG_SEVENSEG */ |
| 125 | |
| 126 | #endif /* __DK1S10_SEVENSEG_H__ */ |