Naze32 clone with Frysky receiver
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

gpio_object.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2006-2013 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_GPIO_OBJECT_H
  17. #define MBED_GPIO_OBJECT_H
  18. #include "mbed_assert.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef struct {
  23. PinName pin;
  24. uint32_t mask;
  25. __IO uint32_t *reg_dir;
  26. __IO uint32_t *reg_set;
  27. __IO uint32_t *reg_clr;
  28. __I uint32_t *reg_in;
  29. } gpio_t;
  30. static inline void gpio_write(gpio_t *obj, int value) {
  31. MBED_ASSERT(obj->pin != (PinName)NC);
  32. if (value)
  33. *obj->reg_set = obj->mask;
  34. else
  35. *obj->reg_clr = obj->mask;
  36. }
  37. static inline int gpio_read(gpio_t *obj) {
  38. MBED_ASSERT(obj->pin != (PinName)NC);
  39. return ((*obj->reg_in & obj->mask) ? 1 : 0);
  40. }
  41. static inline int gpio_is_connected(const gpio_t *obj) {
  42. return obj->pin != (PinName)NC;
  43. }
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif