Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:05

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  This file contains a typical set of register access routines which may be
0005  *  used with the z85c30 chip if accesses to the chip are as follows:
0006  *
0007  *    + registers are accessed as bytes
0008  *
0009  *  COPYRIGHT (c) 1989-1997.
0010  *  On-Line Applications Research Corporation (OAR).
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 #include <rtems.h>
0035 
0036 #include <libchip/z85c30.h>
0037 
0038 #ifndef _Z85C30_MULTIPLIER
0039 #define _Z85C30_MULTIPLIER 1
0040 #define _Z85C30_NAME(_X) _X
0041 #define _Z85C30_TYPE uint8_t
0042 #endif
0043 
0044 /*
0045  *  Z85C30 Get Register Routine
0046  */
0047 
0048 uint8_t   _Z85C30_NAME(z85c30_get_register)(
0049   uintptr_t   ulCtrlPort,
0050   uint8_t     ucRegNum
0051 )
0052 {
0053   _Z85C30_TYPE          *port;
0054   uint8_t                data;
0055   rtems_interrupt_level  level;
0056 
0057   port = (_Z85C30_TYPE *)ulCtrlPort;
0058 
0059   rtems_interrupt_disable(level);
0060 
0061     if(ucRegNum) {
0062       *port = ucRegNum;
0063     }
0064     data = *port;
0065   rtems_interrupt_enable(level);
0066 
0067   return data;
0068 }
0069 
0070 /*
0071  *  Z85C30 Set Register Routine
0072  */
0073 
0074 void _Z85C30_NAME(z85c30_set_register)(
0075   uintptr_t   ulCtrlPort,
0076   uint8_t     ucRegNum,
0077   uint8_t     ucData
0078 )
0079 {
0080   _Z85C30_TYPE          *port;
0081   rtems_interrupt_level  level;
0082 
0083   port = (_Z85C30_TYPE *)ulCtrlPort;
0084 
0085   rtems_interrupt_disable(level);
0086     if(ucRegNum) {
0087       *port = ucRegNum;
0088     }
0089     *port = ucData;
0090   rtems_interrupt_enable(level);
0091 }