/Demo/CORTEX_STM32F103_GCC_Rowley/ParTest/ParTest_MCBSTM32.c

https://github.com/ammarkham/freertos-moo · C · 136 lines · 58 code · 14 blank · 64 comment · 5 complexity · 6cdc75d5705847ea72071ceaa41c466f MD5 · raw file

  1. /*
  2. FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd.
  3. ***************************************************************************
  4. * *
  5. * FreeRTOS tutorial books are available in pdf and paperback. *
  6. * Complete, revised, and edited pdf reference manuals are also *
  7. * available. *
  8. * *
  9. * Purchasing FreeRTOS documentation will not only help you, by *
  10. * ensuring you get running as quickly as possible and with an *
  11. * in-depth knowledge of how to use FreeRTOS, it will also help *
  12. * the FreeRTOS project to continue with its mission of providing *
  13. * professional grade, cross platform, de facto standard solutions *
  14. * for microcontrollers - completely free of charge! *
  15. * *
  16. * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
  17. * *
  18. * Thank you for using FreeRTOS, and thank you for your support! *
  19. * *
  20. ***************************************************************************
  21. This file is part of the FreeRTOS distribution.
  22. FreeRTOS is free software; you can redistribute it and/or modify it under
  23. the terms of the GNU General Public License (version 2) as published by the
  24. Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
  25. >>>NOTE<<< The modification to the GPL is included to allow you to
  26. distribute a combined work that includes FreeRTOS without being obliged to
  27. provide the source code for proprietary components outside of the FreeRTOS
  28. kernel. FreeRTOS is distributed in the hope that it will be useful, but
  29. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  30. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  31. more details. You should have received a copy of the GNU General Public
  32. License and the FreeRTOS license exception along with FreeRTOS; if not it
  33. can be viewed here: http://www.freertos.org/a00114.html and also obtained
  34. by writing to Richard Barry, contact details for whom are available on the
  35. FreeRTOS WEB site.
  36. 1 tab == 4 spaces!
  37. http://www.FreeRTOS.org - Documentation, latest information, license and
  38. contact details.
  39. http://www.SafeRTOS.com - A version that is certified for use in safety
  40. critical systems.
  41. http://www.OpenRTOS.com - Commercial support, development, porting,
  42. licensing and training services.
  43. */
  44. /*-----------------------------------------------------------
  45. * Simple parallel port IO routines.
  46. *-----------------------------------------------------------*/
  47. /* FreeRTOS.org includes. */
  48. #include "FreeRTOS.h"
  49. #include "task.h"
  50. #include "partest.h"
  51. /* Standard includes. */
  52. #include <string.h>
  53. /* Library includes. */
  54. #include "stm32f10x_lib.h"
  55. #define partstNUM_LEDs 8
  56. /* Holds the current output state for each of the LEDs. */
  57. static unsigned char ucBitStates[ partstNUM_LEDs ];
  58. /*-----------------------------------------------------------*/
  59. void vParTestInitialise( void )
  60. {
  61. GPIO_InitTypeDef GPIO_InitStructure;
  62. /* Configure PE14, PD13, PD3 and PD4 output push-pull */
  63. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
  64. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  65. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  66. GPIO_Init( GPIOB, &GPIO_InitStructure );
  67. memset( ucBitStates, 0x00, sizeof( ucBitStates ) );
  68. }
  69. /*-----------------------------------------------------------*/
  70. void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
  71. {
  72. if( uxLED < partstNUM_LEDs )
  73. {
  74. portENTER_CRITICAL();
  75. {
  76. if( xValue != pdFALSE )
  77. {
  78. ucBitStates[ uxLED ] = pdTRUE;
  79. }
  80. else
  81. {
  82. ucBitStates[ uxLED ] = pdFALSE;
  83. }
  84. GPIO_WriteBit( GPIOB, ( GPIO_Pin_8 << uxLED ), ucBitStates[ uxLED ] );
  85. }
  86. portEXIT_CRITICAL();
  87. }
  88. }
  89. /*-----------------------------------------------------------*/
  90. void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
  91. {
  92. if( uxLED < partstNUM_LEDs )
  93. {
  94. portENTER_CRITICAL();
  95. {
  96. ucBitStates[ uxLED ] = !ucBitStates[ uxLED ];
  97. GPIO_WriteBit( GPIOB, ( GPIO_Pin_8 << uxLED ), ucBitStates[ uxLED ] );
  98. }
  99. portEXIT_CRITICAL();
  100. }
  101. }
  102. /*-----------------------------------------------------------*/
  103. portBASE_TYPE xGetLEDState( unsigned portBASE_TYPE uxLED )
  104. {
  105. if( uxLED < partstNUM_LEDs )
  106. {
  107. return ( portBASE_TYPE ) ucBitStates[ uxLED ];
  108. }
  109. else
  110. {
  111. return 0;
  112. }
  113. }