dat-31r5-sp.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /****************************************************************************
  2. * include/nuttx/rf/dat-31r5-sp.h
  3. * Character driver for the Mini-Circuits DAT-31R5-SP+ digital step
  4. * attenuator.
  5. *
  6. * Copyright (C) 2019, Augusto Fraga Giachero. All rights reserved.
  7. * Author: Augusto Fraga Giachero <afg@augustofg.net>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. * 3. Neither the name NuttX nor the names of its contributors may be
  20. * used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  30. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  31. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. * POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ****************************************************************************/
  37. #ifndef __INCLUDE_NUTTX_RF_DAT_31R5_SP_H_
  38. #define __INCLUDE_NUTTX_RF_DAT_31R5_SP_H_
  39. /****************************************************************************
  40. * Included Files
  41. ****************************************************************************/
  42. #include <nuttx/irq.h>
  43. #include <nuttx/config.h>
  44. #include <nuttx/rf/ioctl.h>
  45. #include <nuttx/spi/spi.h>
  46. /****************************************************************************
  47. * Public Function Prototypes
  48. ****************************************************************************/
  49. #ifdef __cplusplus
  50. #define EXTERN extern "C"
  51. extern "C"
  52. {
  53. #else
  54. #define EXTERN extern
  55. #endif
  56. /****************************************************************************
  57. * Name: dat31r5sp_register
  58. *
  59. * Description:
  60. * Register the dat31r5sp character device as 'devpath'. WARNING:
  61. * the DAT-31R5-SP+ is not spi compatible because it hasn't a proper
  62. * chip-select input, but it can coexist with other devices on the
  63. * spi bus assuming that the LE (Latch Enable) is always 0 when the
  64. * device isn't selected. With LE=0 the internal shift-register will
  65. * store the last 6 bits sent through the bus, but it will only
  66. * change the attenuation level when LE=1. This driver sends the
  67. * attenuation bitstream and gives a small positive pulse to LE.
  68. *
  69. * Remember when implementing the corresponding spi select function
  70. * when selected == true LE should be 1, and when selected == false
  71. * LE should be 0.
  72. *
  73. * Input Parameters:
  74. * devpath - The full path to the driver to register. E.g., "/dev/att0"
  75. * spi - An instance of the SPI interface to use to communicate with
  76. * spidev - Number of the spi device (used to drive the Latch Enable pin).
  77. *
  78. *
  79. * Returned Value:
  80. * Zero (OK) on success; a negated errno value on failure.
  81. *
  82. ****************************************************************************/
  83. int dat31r5sp_register(FAR const char *devpath,
  84. FAR struct spi_dev_s *spi,
  85. int spidev);
  86. #undef EXTERN
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif /* __INCLUDE_NUTTX_RF_DAT_31R5_SP_H_ */