]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - rpp/src/drv/hout.c
Merge port and gpio definitions into one file in the DRV layer
[pes-rpp/rpp-lib.git] / rpp / src / drv / hout.c
index 80bad2e4688998477a391ffabf31aa6d2dce83b5..ebf052531e850ddecae5174444a0bc03989da327 100644 (file)
 #define HOUT_PWM_INITIALIZED    0x1
 #define HOUT_PWM_RUNNING        0x100
 
-/** Map of hout_in pin descriptors to their index **/
-static uint32_t hout_pin_in_descs[] = {PIN_DSC_HOUT1IN, PIN_DSC_HOUT2IN, PIN_DSC_HOUT3IN, PIN_DSC_HOUT4IN, PIN_DSC_HOUT5IN, PIN_DSC_HOUT6IN};
-/** Map of hout_diag pin descriptors to their index **/
-static uint32_t hout_pin_diag_descs[] = {PIN_DSC_HOUT1DIAG, PIN_DSC_HOUT2DIAG, PIN_DSC_HOUT3DIAG, PIN_DSC_HOUT4DIAG, PIN_DSC_HOUT5DIAG, PIN_DSC_HOUT6DIAG};
 /** PWM modules from N2HET mapped to HOUT pin ID 0-5 **/
 static uint8_t hout_pwm_map[] = {pwm1, pwm2, pwm3, pwm4, pwm5, pwm6};
 /** Flag variable
@@ -143,8 +139,11 @@ int hout_fail(uint8_t hout_id)
        uint32_t i;
        uint16_t pwm_running;
        int err_cnt = 0;
+       dio_port_desc_t* hout_in_port = dio_port_get_dsc(DIO_PORT_NAME_HOUTIN, -1);
+       dio_port_desc_t* hout_diag_port = dio_port_get_dsc(DIO_PORT_NAME_HOUTDIAG, -1);
 
-       if (hout_id >= hal_port_get_val_cnt(hal_port_get_dsc(PORT_NAME_HOUTIN, -1)))
+
+       if (hout_id >= dio_port_get_val_cnt(dio_port_get_dsc(DIO_PORT_NAME_HOUTIN, -1)))
                return -1;   // Bad parameter
        pwm_running = hout_pwm_state & (HOUT_PWM_RUNNING << hout_id);
 
@@ -153,13 +152,13 @@ int hout_fail(uint8_t hout_id)
        else
                hout_pwm_stop(hout_id);
        vTaskDelay(1/portTICK_RATE_MS);
-       hal_gpio_pin_set_value(hout_pin_in_descs[hout_id], 1);
+       dio_gpio_pin_set_value(hout_in_port->config[hout_id], 1);
        for (i = 0; i < 4; i++) {
-               if (hal_gpio_pin_get_value(hout_pin_diag_descs[hout_id]) != 1)
+               if (dio_gpio_pin_get_value(hout_diag_port->config[hout_id]) != 1)
                        err_cnt++;  // Input value and output value are not equal
                vTaskDelay(1/portTICK_RATE_MS);
        }
-       hal_gpio_pin_set_value(hout_pin_in_descs[hout_id], 0);
+       dio_gpio_pin_set_value(hout_diag_port->config[hout_id], 0);
        if (pwm_running) hout_pwm_start(hout_id);
        return (err_cnt == 0) ? HOUT_OK : HOUT_FAILED;
 }