t

Dependencies:   DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos

Fork of DMSupport by Embedded Artists

meas.h

Committer:
embeddedartists
Date:
2014-12-08
Revision:
4:6fdcdf7aff8d
Child:
31:d47cffcb0a3e

File content as of revision 4:6fdcdf7aff8d:

/*
 *  Copyright 2014 Embedded Artists AB
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef _MEAS_H_
#define _MEAS_H_

/******************************************************************************
 * Includes
 *****************************************************************************/

#include "mbed.h"
#include "dm_board_config.h"

/******************************************************************************
 * Typedefs and defines
 *****************************************************************************/

// Internal macros, don't use directly
#if defined(DM_BOARD_ENABLE_MEASSURING_PINS)
  #define _INTERNAL_SET_MEAS_PIN(__port, __pin)    ((LPC_GPIO ## __port)->SET = (1UL << (__pin)))
  #define _INTERNAL_CLR_MEAS_PIN(__port, __pin)    ((LPC_GPIO ## __port)->CLR = (1UL << (__pin)))
#else
  #define _INTERNAL_SET_MEAS_PIN(__port, __pin)    do {} while(0)
  #define _INTERNAL_CLR_MEAS_PIN(__port, __pin)    do {} while(0)
#endif

// Manipulates measurement pin 1 which is GPIO1[24], available on J10-7
#define SET_MEAS_PIN_1()     _INTERNAL_SET_MEAS_PIN(1, 24)
#define CLR_MEAS_PIN_1()     _INTERNAL_CLR_MEAS_PIN(1, 24)

// Manipulates measurement pin 2 which is GPIO1[23], available on J10-8
#define SET_MEAS_PIN_2()     _INTERNAL_SET_MEAS_PIN(1, 23)
#define CLR_MEAS_PIN_2()     _INTERNAL_CLR_MEAS_PIN(1, 23)

// Manipulates measurement pin 3 which is GPIO1[20], available on J10-9
#define SET_MEAS_PIN_3()     _INTERNAL_SET_MEAS_PIN(1, 20)
#define CLR_MEAS_PIN_3()     _INTERNAL_CLR_MEAS_PIN(1, 20)

// Manipulates measurement pin 4 which is GPIO1[19], available on J10-10
#define SET_MEAS_PIN_4()     _INTERNAL_SET_MEAS_PIN(1, 19)
#define CLR_MEAS_PIN_4()     _INTERNAL_CLR_MEAS_PIN(1, 19)


#if defined(DM_BOARD_ENABLE_MEASSURING_PINS)
  #define _INTERNAL_INIT_MEAS() do {\
      LPC_IOCON->P1_19 &= ~0x7; \
      LPC_IOCON->P1_20 &= ~0x7; \
      LPC_IOCON->P1_23 &= ~0x7; \
      LPC_IOCON->P1_24 &= ~0x7; \
      LPC_GPIO1->DIR |= (1<<19) | (1<<20) | (1<<23) | (1<<24); \
      CLR_MEAS_PIN_1(); \
      CLR_MEAS_PIN_2(); \
      CLR_MEAS_PIN_3(); \
      CLR_MEAS_PIN_4(); \
    } while(0)
#else
  #define _INTERNAL_INIT_MEAS()                    do {} while(0)
#endif

/******************************************************************************
 * Global Variables
 *****************************************************************************/

#endif /* end _MEAS_H_ */