Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * Display driver for HCMS29xx
0005  *
0006  * This file declares the SPI based driver for a HCMS29xx 4 digit
0007  * alphanumeric LED display
0008  */
0009 
0010 /*
0011  * Copyright (c) 2008 embedded brains GmbH & Co. KG
0012  *
0013  * Redistribution and use in source and binary forms, with or without
0014  * modification, are permitted provided that the following conditions
0015  * are met:
0016  * 1. Redistributions of source code must retain the above copyright
0017  *    notice, this list of conditions and the following disclaimer.
0018  * 2. Redistributions in binary form must reproduce the above copyright
0019  *    notice, this list of conditions and the following disclaimer in the
0020  *    documentation and/or other materials provided with the distribution.
0021  *
0022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0023  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0025  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0026  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0027  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0028  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0029  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0030  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0032  * POSSIBILITY OF SUCH DAMAGE.
0033  */
0034 
0035 #ifndef _DISP_HCMS29XX_H
0036 #define _DISP_HCMS29XX_H
0037 #include <rtems.h>
0038 #include <time.h>
0039 
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043 #define DISP_HCMS29XX_TEXT_CNT (128)
0044 
0045   typedef struct {
0046     rtems_device_minor_number minor;   /* minor device number            */
0047     /*
0048      * in the disp_buffer, the string to be displayed is placed
0049      */
0050     char disp_buffer[DISP_HCMS29XX_TEXT_CNT];
0051     int  disp_buf_cnt; /* number of valid chars in disp_buffer */
0052     /*
0053      * in the trns buffer the string is transfered to display task
0054      */
0055     char trns_buffer[DISP_HCMS29XX_TEXT_CNT];
0056     /*
0057      * in the dev_buffer, characters will be accumulated before display...
0058      */
0059     char dev_buffer[DISP_HCMS29XX_TEXT_CNT];
0060     int  dev_buf_cnt; /* number of valid chars in dev_buffer */
0061 
0062     rtems_id trns_sema_id;  /* ID of disp trns buffer sema   */
0063     rtems_id task_id;       /* ID of disp task               */
0064     bool rotate;            /* FLAG: display is upside down       */
0065   } spi_disp_hcms29xx_param_t;
0066 
0067   typedef struct {
0068     rtems_libi2c_drv_t        libi2c_drv_entry;
0069     spi_disp_hcms29xx_param_t disp_param;
0070   } disp_hcms29xx_drv_t;
0071   /*
0072    * pass this descriptor pointer to rtems_libi2c_register_drv
0073    */
0074   extern rtems_libi2c_drv_t *disp_hcms29xx_driver_descriptor;
0075 
0076 /*=========================================================================*\
0077 | Function:                                                                 |
0078 \*-------------------------------------------------------------------------*/
0079 rtems_device_driver disp_hcms29xx_dev_initialize
0080   (
0081 /*-------------------------------------------------------------------------*\
0082 | Purpose:                                                                  |
0083 |   prepare the display device driver to accept write calls                 |
0084 |   register device with its name                                           |
0085 +---------------------------------------------------------------------------+
0086 | Input Parameters:                                                         |
0087 \*-------------------------------------------------------------------------*/
0088   rtems_device_major_number  major,
0089   rtems_device_minor_number  minor,
0090   void                      *arg
0091    );
0092 /*-------------------------------------------------------------------------*\
0093 | Return Value:                                                             |
0094 |    rtems_status_code                                                      |
0095 \*=========================================================================*/
0096 
0097 /*=========================================================================*\
0098 | Function:                                                                 |
0099 \*-------------------------------------------------------------------------*/
0100 rtems_device_driver disp_hcms29xx_dev_open
0101 (
0102 /*-------------------------------------------------------------------------*\
0103 | Purpose:                                                                  |
0104 |   open the display device                                                 |
0105 +---------------------------------------------------------------------------+
0106 | Input Parameters:                                                         |
0107 \*-------------------------------------------------------------------------*/
0108   rtems_device_major_number  major,
0109   rtems_device_minor_number  minor,
0110   void                      *arg
0111  );
0112 /*-------------------------------------------------------------------------*\
0113 | Return Value:                                                             |
0114 |    rtems_status_code                                                      |
0115 \*=========================================================================*/
0116 
0117 /*=========================================================================*\
0118 | Function:                                                                 |
0119 \*-------------------------------------------------------------------------*/
0120 rtems_device_driver disp_hcms29xx_dev_write
0121 (
0122 /*-------------------------------------------------------------------------*\
0123 | Purpose:                                                                  |
0124 |   write to display device                                                 |
0125 +---------------------------------------------------------------------------+
0126 | Input Parameters:                                                         |
0127 \*-------------------------------------------------------------------------*/
0128   rtems_device_major_number  major,
0129   rtems_device_minor_number  minor,
0130   void                      *arg
0131  );
0132 /*-------------------------------------------------------------------------*\
0133 | Return Value:                                                             |
0134 |    rtems_status_code                                                      |
0135 \*=========================================================================*/
0136 
0137 /*=========================================================================*\
0138 | Function:                                                                 |
0139 \*-------------------------------------------------------------------------*/
0140 rtems_device_driver disp_hcms29xx_dev_close
0141 (
0142 /*-------------------------------------------------------------------------*\
0143 | Purpose:                                                                  |
0144 |   close the display device                                                |
0145 +---------------------------------------------------------------------------+
0146 | Input Parameters:                                                         |
0147 \*-------------------------------------------------------------------------*/
0148   rtems_device_major_number  major,
0149   rtems_device_minor_number  minor,
0150   void                      *arg
0151  );
0152 /*-------------------------------------------------------------------------*\
0153 | Return Value:                                                             |
0154 |    rtems_status_code                                                      |
0155 \*=========================================================================*/
0156 
0157 #define DISP_HCMS29XX_DRIVER {          \
0158     disp_hcms29xx_dev_initialize,       \
0159       disp_hcms29xx_dev_open,           \
0160       NULL,                 \
0161       disp_hcms29xx_dev_write,          \
0162       NULL,                 \
0163       disp_hcms29xx_dev_close}
0164   
0165     
0166 #ifdef __cplusplus
0167 }
0168 #endif
0169 
0170 #endif /* _DISP_HCMS29XX_H */