SampleAppHw.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /******************************************************************************
  2. Filename: SampleAppHw.c
  3. Revised: $Date: 2010-11-15 18:17:40 -0800 (Mon, 15 Nov 2010) $
  4. Revision: $Revision: 24415 $
  5. Description: Hardware setup for SampleApp
  6. Copyright 2008-2010 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. ******************************************************************************/
  33. /******************************************************************************
  34. * INCLUDES
  35. */
  36. #include "ZComDef.h"
  37. #include "hal_mcu.h"
  38. #include "hal_defs.h"
  39. #include "SampleAppHw.h"
  40. /******************************************************************************
  41. * CONSTANTS
  42. */
  43. /* NOTE: A jumper on SmartRF05 header P18 is used to select device start-up as
  44. * a ZigBee Coordinator. The jumper connects GPIO pins P0.2 and P0.3:
  45. * On SmartRF05 Rev 1.3 or earlier: P0.2=P18 pin 7, P0.3=P18 pin 9
  46. * On SmartRF05 Rev 1.7 or later: P0.2=P18 pin 9, P0.3=P18 pin 11
  47. */
  48. #define JUMPERIN_BIT BV(2) //P0.2
  49. #define JUMPERIN_SEL P0SEL
  50. #define JUMPERIN_DIR P0DIR
  51. #define JUMPERIN P0
  52. #define JUMPEROUT_BIT BV(3) //P0.3
  53. #define JUMPEROUT_SEL P0SEL
  54. #define JUMPEROUT_DIR P0DIR
  55. #define JUMPEROUT P0
  56. /******************************************************************************
  57. * @fn readCoordinatorJumper
  58. *
  59. * @brief Checks for a jumper between 2 GPIO pins to determine if the device
  60. * should start-up as a ZigBee Coordinator
  61. *
  62. * @return TRUE if the jumper is there, FALSE if not
  63. */
  64. uint8 readCoordinatorJumper( void )
  65. {
  66. uint8 i,j;
  67. uint8 result;
  68. JUMPERIN_SEL &= ~(JUMPERIN_BIT);
  69. JUMPERIN_DIR &= ~(JUMPERIN_BIT);
  70. JUMPEROUT_SEL &= ~(JUMPEROUT_BIT);
  71. JUMPEROUT_DIR |= JUMPEROUT_BIT;
  72. // Start with output bit OFF
  73. JUMPEROUT &= ~(JUMPEROUT_BIT);
  74. for ( i = 0; i < 8; i++ )
  75. {
  76. for ( j = 0; j < 8; j++ )
  77. {
  78. // Burn time for input to see change
  79. result = JUMPERIN & JUMPERIN_BIT;
  80. }
  81. j = i & 0x01;
  82. if (((j == 0) && (result != 0)) ||
  83. ((j != 0) && (result != JUMPERIN_BIT)))
  84. {
  85. return ( FALSE );
  86. }
  87. // Toggle the output bit
  88. JUMPEROUT ^= JUMPEROUT_BIT;
  89. }
  90. return ( TRUE );
  91. }
  92. /******************************************************************************
  93. */