1    /*
     2     * Copyright (c) 2016, Texas Instruments Incorporated
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions
     7     * are met:
     8     *
     9     * *  Redistributions of source code must retain the above copyright
    10     *    notice, this list of conditions and the following disclaimer.
    11     *
    12     * *  Redistributions in binary form must reproduce the above copyright
    13     *    notice, this list of conditions and the following disclaimer in the
    14     *    documentation and/or other materials provided with the distribution.
    15     *
    16     * *  Neither the name of Texas Instruments Incorporated nor the names of
    17     *    its contributors may be used to endorse or promote products derived
    18     *    from this software without specific prior written permission.
    19     *
    20     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    22     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    23     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    27     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    28     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    29     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    30     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31     */
    32    
    33    import ti.catalog.msp430.peripherals.clock.IClock;
    34    
    35    /*!
    36     * Universal Serial Communication Interface B0 I2C 2xx
    37     */
    38    metaonly module USCI_B0_I2C_2xx inherits IUSCI_B0_I2C {
    39    
    40        /*
    41         *  ======== create ========
    42         */
    43        create(IClock.Instance clock);
    44    
    45        /*! Not-acknowledge interrupt enable */
    46        enum UCNACKIE_t {
    47            UCNACKIE_OFF = 0x00,    /*! Interrupt disabled */
    48            UCNACKIE = 0x80         /*! Interrupt enabled */
    49        };
    50    
    51        /*! Stop condition interrupt enable */
    52        enum UCSTPIE_t {
    53            UCSTPIE_OFF = 0x00,     /*! Interrupt disabled */
    54            UCSTPIE = 0x80          /*! Interrupt enabled */
    55        };
    56    
    57        /*! Start condition interrupt enable */
    58        enum UCSTTIE_t {
    59            UCSTTIE_OFF = 0x00,     /*! Interrupt disabled */
    60            UCSTTIE = 0x80          /*! Interrupt enabled */
    61        };
    62    
    63        /*! Arbitration lost interrupt enable */
    64        enum UCALIE_t {
    65            UCALIE_OFF = 0x00,      /*! Interrupt disabled */
    66            UCALIE = 0x80           /*! Interrupt enabled */
    67        };
    68    
    69        /*! USCI_Bx I2C Interrupt Enable Register */
    70        struct UCBxI2CIE_t {
    71            UCNACKIE_t  UCNACKIE;   /*! Not-acknowledge interrupt enable
    72                                     *  0  Interrupt disabled
    73                                     *  1  Interrupt enabled */
    74            UCSTPIE_t   UCSTPIE;    /*! Stop condition interrupt enable
    75                                     *  0  Interrupt disabled
    76                                     *  1  Interrupt enabled */
    77            UCSTTIE_t   UCSTTIE;    /*! Start condition interrupt enable
    78                                     *  0  Interrupt disabled
    79                                     *  1  Interrupt enabled */
    80            UCALIE_t    UCALIE;    /*! Arbitration lost interrupt enable
    81                                     *  0  Interrupt disabled
    82                                     *  1  Interrupt enabled */
    83        }
    84    
    85    instance:
    86        /*! @_nodoc */
    87        config IClock.Instance clock;
    88    
    89        /*! USCI_Bx I2C Interrupt Enable Register */
    90        config UCBxI2CIE_t UCB0I2CIE = {
    91            UCNACKIE    : UCNACKIE_OFF,
    92            UCSTPIE     : UCSTPIE_OFF,
    93            UCSTTIE     : UCSTTIE_OFF,
    94            UCALIE      : UCALIE_OFF,
    95        };
    96    
    97       /*!
    98        *  ======== setUCNACKIE ========
    99        *  Sets UCNACKIE bit
   100        *
   101        *  @see #setUCNACKIE
   102        */
   103        Bool setUCNACKIE(Bool set);
   104    
   105       /*!
   106        *  ======== getUCNACKIE ========
   107        *  Gets UCNACKIE bit
   108        *
   109        *  @see #getUCNACKIE
   110        */
   111        Bool getUCNACKIE();
   112    
   113       /*!
   114        *  ======== setUCSTPIE ========
   115        *  Sets UCSTPIE bit
   116        *
   117        *  @see #setUCSTPIE
   118        */
   119        Bool setUCSTPIE(Bool set);
   120    
   121       /*!
   122        *  ======== getUCSTPIE ========
   123        *  Gets UCSTPIE bit
   124        *
   125        *  @see #getUCSTPIE
   126        */
   127        Bool getUCSTPIE();
   128    
   129       /*!
   130        *  ======== setUCSTTIE ========
   131        *  Sets UCSTTIE bit
   132        *
   133        *  @see #setUCSTTIE
   134        */
   135        Bool setUCSTTIE(Bool set);
   136    
   137       /*!
   138        *  ======== getUCSTTIE ========
   139        *  Gets UCSTTIE bit
   140        *
   141        *  @see #getUCSTTIE
   142        */
   143        Bool getUCSTTIE();
   144    
   145       /*!
   146        *  ======== setUCALIE ========
   147        *  Sets UCALIE bit
   148        *
   149        *  @see #setUCALIE
   150        */
   151        Bool setUCALIE(Bool set);
   152    
   153       /*!
   154        *  ======== getUCALIE ========
   155        *  Gets UCALIE bit
   156        *
   157        *  @see #getUCALIE
   158        */
   159        Bool getUCALIE();
   160    
   161        /*! USCI_B0 I2C interrupt enables */
   162        config regIntVect_t interruptSource[4];
   163    
   164        /*! Determine if each Register needs to be forced set or not */
   165        readonly config ForceSetDefaultRegister_t forceSetDefaultRegister[] =
   166        [
   167            { register : "UCB0CTL0"   , regForceSet : false },
   168            { register : "UCB0CTL1"   , regForceSet : false },
   169            { register : "UCB0BR0"    , regForceSet : false },
   170            { register : "UCB0BR1"    , regForceSet : false },
   171            { register : "UCB0STAT"   , regForceSet : false },
   172            { register : "UCB0RXBUF"  , regForceSet : false },
   173            { register : "UCB0TXBUF"  , regForceSet : false },
   174            { register : "UCB0I2COA"  , regForceSet : false },
   175            { register : "UCB0I2CSA"  , regForceSet : false },
   176            { register : "UCB0I2CIE"  , regForceSet : false }
   177        ];
   178    }