projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
SEC: Add AES implementation.
[bertos.git]
/
bertos
/
cpu
/
cortex-m3
/
drv
/
gpio_lm3s.c
diff --git
a/bertos/cpu/cortex-m3/drv/gpio_lm3s.c
b/bertos/cpu/cortex-m3/drv/gpio_lm3s.c
index 653fd1e99e18676d9198507ffbf7fcd0630607bc..6ed16e47340010be936bb36b20bbb2b1f2ba10b8 100644
(file)
--- a/
bertos/cpu/cortex-m3/drv/gpio_lm3s.c
+++ b/
bertos/cpu/cortex-m3/drv/gpio_lm3s.c
@@
-35,29
+35,35
@@
* \author Andrea Righi <arighi@develer.com>
*/
* \author Andrea Righi <arighi@develer.com>
*/
+
+#include "gpio_lm3s.h"
+
#include <cfg/compiler.h>
#include <cfg/debug.h>
#include <cfg/compiler.h>
#include <cfg/debug.h>
+
#include <io/lm3s.h>
#include <io/lm3s.h>
-#include "gpio_lm3s.h"
+
/* Set the pin(s) direction and mode */
INLINE int lm3s_gpioPinConfigMode(uint32_t port, uint8_t pins, uint32_t mode)
{
/* Set the pin(s) direction and mode */
INLINE int lm3s_gpioPinConfigMode(uint32_t port, uint8_t pins, uint32_t mode)
{
-
switch (mode
)
+
if (mode == GPIO_DIR_MODE_IN
)
{
{
- case GPIO_DIR_MODE_IN:
HWREG(port + GPIO_O_DIR) &= ~pins;
HWREG(port + GPIO_O_AFSEL) &= ~pins;
HWREG(port + GPIO_O_DIR) &= ~pins;
HWREG(port + GPIO_O_AFSEL) &= ~pins;
- break;
- case GPIO_DIR_MODE_OUT:
+ }
+ else if (mode == GPIO_DIR_MODE_OUT)
+ {
HWREG(port + GPIO_O_DIR) |= pins;
HWREG(port + GPIO_O_AFSEL) &= ~pins;
HWREG(port + GPIO_O_DIR) |= pins;
HWREG(port + GPIO_O_AFSEL) &= ~pins;
- break;
- case GPIO_DIR_MODE_HW:
+ }
+ else if (mode == GPIO_DIR_MODE_HW)
+ {
HWREG(port + GPIO_O_DIR) &= ~pins;
HWREG(port + GPIO_O_AFSEL) |= pins;
HWREG(port + GPIO_O_DIR) &= ~pins;
HWREG(port + GPIO_O_AFSEL) |= pins;
- break;
- default:
+ }
+ else
+ {
ASSERT(0);
return -1;
}
ASSERT(0);
return -1;
}
@@
-68,33
+74,36
@@
INLINE int lm3s_gpioPinConfigMode(uint32_t port, uint8_t pins, uint32_t mode)
INLINE int
lm3s_gpioPinConfigStrength(uint32_t port, uint8_t pins, uint32_t strength)
{
INLINE int
lm3s_gpioPinConfigStrength(uint32_t port, uint8_t pins, uint32_t strength)
{
-
switch (strength
)
+
if (strength == GPIO_STRENGTH_2MA
)
{
{
- case GPIO_STRENGTH_2MA:
HWREG(port + GPIO_O_DR2R) |= pins;
HWREG(port + GPIO_O_DR4R) &= ~pins;
HWREG(port + GPIO_O_DR8R) &= ~pins;
HWREG(port + GPIO_O_SLR) &= ~pins;
HWREG(port + GPIO_O_DR2R) |= pins;
HWREG(port + GPIO_O_DR4R) &= ~pins;
HWREG(port + GPIO_O_DR8R) &= ~pins;
HWREG(port + GPIO_O_SLR) &= ~pins;
- break;
- case GPIO_STRENGTH_4MA:
+ }
+ else if (strength == GPIO_STRENGTH_4MA)
+ {
HWREG(port + GPIO_O_DR2R) &= ~pins;
HWREG(port + GPIO_O_DR4R) |= pins;
HWREG(port + GPIO_O_DR8R) &= ~pins;
HWREG(port + GPIO_O_SLR) &= ~pins;
HWREG(port + GPIO_O_DR2R) &= ~pins;
HWREG(port + GPIO_O_DR4R) |= pins;
HWREG(port + GPIO_O_DR8R) &= ~pins;
HWREG(port + GPIO_O_SLR) &= ~pins;
- break;
- case GPIO_STRENGTH_8MA:
+ }
+ else if (strength == GPIO_STRENGTH_8MA)
+ {
HWREG(port + GPIO_O_DR2R) &= ~pins;
HWREG(port + GPIO_O_DR4R) &= ~pins;
HWREG(port + GPIO_O_DR8R) |= pins;
HWREG(port + GPIO_O_SLR) &= ~pins;
HWREG(port + GPIO_O_DR2R) &= ~pins;
HWREG(port + GPIO_O_DR4R) &= ~pins;
HWREG(port + GPIO_O_DR8R) |= pins;
HWREG(port + GPIO_O_SLR) &= ~pins;
- break;
- case GPIO_STRENGTH_8MA_SC:
+ }
+ else if (strength == GPIO_STRENGTH_8MA_SC)
+ {
HWREG(port + GPIO_O_DR2R) &= ~pins;
HWREG(port + GPIO_O_DR4R) &= ~pins;
HWREG(port + GPIO_O_DR8R) |= pins;
HWREG(port + GPIO_O_SLR) |= pins;
HWREG(port + GPIO_O_DR2R) &= ~pins;
HWREG(port + GPIO_O_DR4R) &= ~pins;
HWREG(port + GPIO_O_DR8R) |= pins;
HWREG(port + GPIO_O_SLR) |= pins;
- break;
- default:
+ }
+ else
+ {
ASSERT(0);
return -1;
}
ASSERT(0);
return -1;
}
@@
-104,58
+113,64
@@
lm3s_gpioPinConfigStrength(uint32_t port, uint8_t pins, uint32_t strength)
/* Set the pin(s) type */
INLINE int lm3s_gpioPinConfigType(uint32_t port, uint8_t pins, uint32_t type)
{
/* Set the pin(s) type */
INLINE int lm3s_gpioPinConfigType(uint32_t port, uint8_t pins, uint32_t type)
{
-
switch (type
)
+
if (type == GPIO_PIN_TYPE_STD
)
{
{
- case GPIO_PIN_TYPE_ANALOG:
- HWREG(port + GPIO_O_ODR) &= ~pins;
- HWREG(port + GPIO_O_PUR) &= ~pins;
- HWREG(port + GPIO_O_PDR) &= ~pins;
- HWREG(port + GPIO_O_DEN) &= ~pins;
- HWREG(port + GPIO_O_AMSEL) |= pins;
- break;
- case GPIO_PIN_TYPE_STD:
HWREG(port + GPIO_O_ODR) &= ~pins;
HWREG(port + GPIO_O_PUR) &= ~pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
HWREG(port + GPIO_O_ODR) &= ~pins;
HWREG(port + GPIO_O_PUR) &= ~pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
- break;
- case GPIO_PIN_TYPE_STD_WPU:
+ }
+ else if (type == GPIO_PIN_TYPE_STD_WPU)
+ {
HWREG(port + GPIO_O_ODR) &= ~pins;
HWREG(port + GPIO_O_PUR) |= pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
HWREG(port + GPIO_O_ODR) &= ~pins;
HWREG(port + GPIO_O_PUR) |= pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
- break;
- case GPIO_PIN_TYPE_STD_WPD:
+ }
+ else if (type == GPIO_PIN_TYPE_STD_WPD)
+ {
HWREG(port + GPIO_O_ODR) &= ~pins;
HWREG(port + GPIO_O_PUR) &= ~pins;
HWREG(port + GPIO_O_PDR) |= pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
HWREG(port + GPIO_O_ODR) &= ~pins;
HWREG(port + GPIO_O_PUR) &= ~pins;
HWREG(port + GPIO_O_PDR) |= pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
- break;
- case GPIO_PIN_TYPE_OD:
+ }
+ else if (type == GPIO_PIN_TYPE_OD)
+ {
HWREG(port + GPIO_O_ODR) |= pins;
HWREG(port + GPIO_O_PUR) &= ~pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
HWREG(port + GPIO_O_ODR) |= pins;
HWREG(port + GPIO_O_PUR) &= ~pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
- break;
- case GPIO_PIN_TYPE_OD_WPU:
+ }
+ else if (type == GPIO_PIN_TYPE_OD_WPU)
+ {
HWREG(port + GPIO_O_ODR) |= pins;
HWREG(port + GPIO_O_PUR) |= pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
HWREG(port + GPIO_O_ODR) |= pins;
HWREG(port + GPIO_O_PUR) |= pins;
HWREG(port + GPIO_O_PDR) &= ~pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
- break;
- case GPIO_PIN_TYPE_OD_WPD:
+ }
+ else if (type == GPIO_PIN_TYPE_OD_WPD)
+ {
HWREG(port + GPIO_O_ODR) |= pins;
HWREG(port + GPIO_O_PUR) &= pins;
HWREG(port + GPIO_O_PDR) |= pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
HWREG(port + GPIO_O_ODR) |= pins;
HWREG(port + GPIO_O_PUR) &= pins;
HWREG(port + GPIO_O_PDR) |= pins;
HWREG(port + GPIO_O_DEN) |= pins;
HWREG(port + GPIO_O_AMSEL) &= ~pins;
- break;
- default:
+ }
+ else if (type == GPIO_PIN_TYPE_ANALOG)
+ {
+ HWREG(port + GPIO_O_ODR) &= ~pins;
+ HWREG(port + GPIO_O_PUR) &= ~pins;
+ HWREG(port + GPIO_O_PDR) &= ~pins;
+ HWREG(port + GPIO_O_DEN) &= ~pins;
+ HWREG(port + GPIO_O_AMSEL) |= pins;
+ }
+ else
+ {
ASSERT(0);
return -1;
}
ASSERT(0);
return -1;
}