OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [MSP430X_MSP430F5438_IAR/] [MSP-EXP430F5438_HAL/] [hal_buttons.c] - Blame information for rev 611

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 584 jeremybenn
/**
2
 * @file  hal_buttons.c
3
 *
4
 * Copyright 2010 Texas Instruments, Inc.
5
***************************************************************************/
6
#include "msp430.h"
7
#include "hal_MSP-EXP430F5438.h"
8
 
9
/**********************************************************************//**
10
 * @brief  Initializes the GPIO ports to act as buttons.
11
 *
12
 * @param  buttonsMask The mask that specifies the button pins.
13
 *
14
 * @return none
15
 *************************************************************************/
16
void halButtonsInit(unsigned char buttonsMask)
17
{
18
  BUTTON_PORT_OUT |= buttonsMask;
19
  BUTTON_PORT_DIR &= ~buttonsMask;
20
  BUTTON_PORT_REN |= buttonsMask;
21
  BUTTON_PORT_SEL &= ~buttonsMask;
22
}
23
 
24
/**********************************************************************//**
25
 * @brief  Returns LOW for the buttons pressed.
26
 *
27
 * @param  none
28
 *
29
 * @return The buttons that have been pressed, identified by a bit = 0.
30
 *************************************************************************/
31
unsigned char halButtonsPressed(void)
32
{
33
  unsigned char value;
34
  value = BUTTON_PORT_IN;
35
  return (0xFF - value);                    //Low==ButtonPressed
36
}
37
 
38
/**********************************************************************//**
39
 * @brief  Enables button interrupt(s) with low to high transitions.
40
 *
41
 * @param  buttonIntEnableMask The button pin(s) for which the interrupt(s)
42
 *                             should be enabled.
43
 *
44
 * @return none
45
 *************************************************************************/
46
void halButtonsInterruptEnable(unsigned char buttonIntEnableMask)
47
{
48
  BUTTON_PORT_IES &= ~buttonIntEnableMask;
49
  BUTTON_PORT_IFG &= ~buttonIntEnableMask;
50
  BUTTON_PORT_IE |= buttonIntEnableMask;
51
}
52
 
53
/**********************************************************************//**
54
 * @brief  Disables button interrupts
55
 *
56
 * @param  buttonIntEnableMask The button pin(s) for which the interrupt(s)
57
 *                             should be disabled.
58
 *
59
 * @return none
60
 *************************************************************************/
61
void halButtonsInterruptDisable(unsigned char buttonIntEnableMask)
62
{
63
  BUTTON_PORT_IE &= ~buttonIntEnableMask;
64
}
65
 
66
/**********************************************************************//**
67
 * @brief  Clears the button GPIO settings, disables the buttons.
68
 *
69
 * @param  none
70
 *************************************************************************/
71
void halButtonsShutDown()
72
{
73
  //All output, outputting 0s
74
  BUTTON_PORT_OUT &= ~(BUTTON_ALL);
75
  BUTTON_PORT_DIR |= BUTTON_ALL;
76
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.