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 m48t08 chip if accesses to the chip are as follows:
0006  *
0007  *    + registers are accessed as bytes
0008  *    + registers are only byte-aligned (no address gaps)
0009  *
0010  *  COPYRIGHT (c) 1989-1997.
0011  *  On-Line Applications Research Corporation (OAR).
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 #include <rtems.h>
0036 #include <libchip/rtc.h>
0037 #include <libchip/m48t08.h>
0038 
0039 #ifndef _M48T08_MULTIPLIER
0040 #define _M48T08_MULTIPLIER 1
0041 #define _M48T08_NAME(_X) _X
0042 #define _M48T08_TYPE uint8_t
0043 #endif
0044 
0045 #define CALCULATE_REGISTER_ADDRESS( _base, _reg ) \
0046   (_M48T08_TYPE *)((_base) + ((_reg) * _M48T08_MULTIPLIER ))
0047 
0048 /*
0049  *  M48T08 Get Register Routine
0050  */
0051 
0052 uint32_t   _M48T08_NAME(m48t08_get_register)(
0053   uintptr_t   ulCtrlPort,
0054   uint8_t     ucRegNum
0055 )
0056 {
0057   _M48T08_TYPE *port;
0058 
0059   port = CALCULATE_REGISTER_ADDRESS( ulCtrlPort, ucRegNum );
0060 
0061   return *port;
0062 }
0063 
0064 /*
0065  *  M48T08 Set Register Routine
0066  */
0067 
0068 void  _M48T08_NAME(m48t08_set_register)(
0069   uintptr_t   ulCtrlPort,
0070   uint8_t     ucRegNum,
0071   uint32_t    ucData
0072 )
0073 {
0074   _M48T08_TYPE *port;
0075 
0076   port = CALCULATE_REGISTER_ADDRESS( ulCtrlPort, ucRegNum );
0077 
0078   *port = ucData;
0079 }