summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c
diff options
context:
space:
mode:
authorFlorent Duchon2012-12-26 17:36:00 +0100
committerFlorent Duchon2013-02-13 21:21:12 +0100
commitb24866225a6301d3a663f874725e83c012dc25d3 (patch)
treeca527a2aab9abcdfbaf244c53ca63f0c531892b0 /digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c
parent2ba279f4eb2f23fa08a7c13465d16ae6ba5d0f96 (diff)
digital/beacon: add bitcloud stack into common directory digital/zigbit
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c
new file mode 100644
index 00000000..db417cdb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c
@@ -0,0 +1,59 @@
+/**************************************************************************//**
+\file sliders.h
+
+\brief Implementation of the sliders.
+
+\author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+\internal
+ History:
+ 29/06/07 E. Ivanov - Created
+******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <gpio.h>
+#include <sliders.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Reads the sliders.
+
+\return
+ state of 3 on­board DIP­switches.User can uses SLIDER0, SLIDER1, SLIDER2
+ defines to test state. Value 1 indicates that slider is on.
+******************************************************************************/
+uint8_t BSP_ReadSliders(void)
+{
+ uint8_t result;
+
+ GPIO_3_make_in(); GPIO_3_make_pullup();
+ GPIO_4_make_in(); GPIO_4_make_pullup();
+ GPIO_5_make_in(); GPIO_5_make_pullup();
+ /* NOP was added for correct work on 8 MHz frequency.
+ clck i\o is not equal clck cpu.
+ CPU must wait for I\O system 1 clock for synchronization. */
+ NOP;
+ result = GPIO_3_read() * SLIDER0;
+ result |= GPIO_4_read() * SLIDER1;
+ result |= GPIO_5_read() * SLIDER2;
+ GPIO_3_make_in();
+ GPIO_4_make_in();
+ GPIO_5_make_in();
+
+ return (~result) & 0x07;
+}
+
+#endif // APP_DISABLE_BSP != 1
+
+// end of sliders.c