Revision bbeeceaf

View differences:

include/TLC5947/v1/alld_TLC5947_v1.h
48 48
#define TLC5947_LLD_BLANK_ACTIVE_STATE          APAL_GPIO_ACTIVE_HIGH
49 49

  
50 50
/**
51
 * @brief   Active state of the XLAT signal.
51
 * @brief   Signal edge of the XLAT signal, which causes the SPI registers to be latched to the output.
52 52
 */
53
#define TLC5947_LLD_XLAT_ACTIVE_STATE           APAL_GPIO_ACTIVE_HIGH
53
#define TLC5947_LLD_XLAT_UPDATE_EDGE            APAL_GPIO_EDGE_RISING
54 54

  
55 55
/**
56 56
 * @brief   Number of PWM channels.
......
84 84
 */
85 85
typedef struct {
86 86
  apalSPIDriver_t* spi_driver;    /**< @brief The SPI Driver.                           */
87
  const apalControlGpio_t* blank_gpio;  /**< @brief The identifier of the BLANK signal GPIO.  */
88
  const apalControlGpio_t* xlat_gpio;   /**< @brief The identifier of the XLAT signal GPIO.   */
87
  const apalControlGpio_t* blank_gpio;  /**< @brief The identifier of the BLANK signal GPIO (may be @p NULL).  */
88
  const apalControlGpio_t* xlat_gpio;   /**< @brief The identifier of the XLAT signal GPIO (may be @p NULL).   */
89 89
} TLC5947Driver;
90 90

  
91 91
/**
source/TLC5947/v1/alld_TLC5947_v1.c
62 62
{
63 63
  apalDbgAssert(tlc5947 != NULL);
64 64

  
65
  // set the output value of the GPIO pin depending on the activation property
66
  return apalControlGpioSet(tlc5947->blank_gpio, blank == TLC5947_LLD_BLANK_ENABLE ? APAL_GPIO_ON : APAL_GPIO_OFF);
65
  // BLANK signal is optional
66
  if (tlc5947->blank_gpio == NULL) {
67
    return APAL_STATUS_WARNING;
68
  } else {
69
    // set the output value of the GPIO pin depending on the activation property
70
    return apalControlGpioSet(tlc5947->blank_gpio, blank == TLC5947_LLD_BLANK_ENABLE ? APAL_GPIO_ON : APAL_GPIO_OFF);
71
  }
67 72
}
68 73

  
69 74
/**
......
77 82
  apalDbgAssert(tlc5947 != NULL);
78 83
  apalDbgAssert(blank != NULL);
79 84

  
80
  apalControlGpioState_t gpio_state;
81
  apalExitStatus_t status = apalControlGpioGet(tlc5947->blank_gpio, &gpio_state);
82
  *blank = gpio_state == APAL_GPIO_ON ? TLC5947_LLD_BLANK_ENABLE : TLC5947_LLD_BLANK_DISABLE;
83
  return status;
85
  // BLANK signal is optional
86
  if (tlc5947->blank_gpio == NULL) {
87
    return APAL_STATUS_WARNING;
88
  } else {
89
    apalControlGpioState_t gpio_state;
90
    apalExitStatus_t status = apalControlGpioGet(tlc5947->blank_gpio, &gpio_state);
91
    *blank = gpio_state == APAL_GPIO_ON ? TLC5947_LLD_BLANK_ENABLE : TLC5947_LLD_BLANK_DISABLE;
92
    return status;
93
  }
84 94
}
85 95

  
86 96
/**
......
93 103
{
94 104
  apalDbgAssert(tlc5947 != NULL);
95 105

  
96
  apalExitStatus_t status = apalControlGpioSet(tlc5947->xlat_gpio, APAL_GPIO_ON);
97
  // The XLAT signal has to be active for at least 30 ns.
98
  // It is assumed that that these function calls satisfy this requirement even without explicit delay.
99
  if (apalControlGpioSet(tlc5947->xlat_gpio, APAL_GPIO_OFF) == APAL_STATUS_OK && status == APAL_STATUS_OK) {
100
    return APAL_STATUS_OK;
106
  // XLAT signal GPIO is optional
107
  if (tlc5947->xlat_gpio == NULL) {
108
    return APAL_STATUS_WARNING;
101 109
  } else {
102
    return APAL_STATUS_ERROR;
110
    apalExitStatus_t status = apalGpioWrite(tlc5947->xlat_gpio->gpio, (tlc5947->xlat_gpio->meta.edge == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_LOW : APAL_GPIO_HIGH);
111
    // The XLAT signal has to be active for at least 30 ns.
112
    // It is assumed that that these function calls satisfy this requirement even without explicit delay.
113
    status |= apalGpioWrite(tlc5947->xlat_gpio->gpio, (tlc5947->xlat_gpio->meta.edge == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_HIGH : APAL_GPIO_LOW);
114
    return status;
103 115
  }
104 116
}
105 117

  

Also available in: Unified diff