You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/01/26 00:40:34 UTC

[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2167: LIS2DH12 Sem Time

apache-mynewt-bot commented on issue #2167: LIS2DH12 Sem Time
URL: https://github.com/apache/mynewt-core/pull/2167#issuecomment-578457330
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### hw/drivers/sensors/lis2dh12/src/lis2dh12.c
   <details>
   
   ```diff
   @@ -190,9 +190,9 @@
    
    /* Exports for the sensor API */
    static int lis2dh12_sensor_read(struct sensor *, sensor_type_t,
   -        sensor_data_func_t, void *, uint32_t);
   +                                sensor_data_func_t, void *, uint32_t);
    static int lis2dh12_sensor_get_config(struct sensor *, sensor_type_t,
   -        struct sensor_cfg *);
   +                                      struct sensor_cfg *);
    static int lis2dh12_sensor_set_config(struct sensor *, void *);
    static int
    lis2dh12_sensor_set_trigger_thresh(struct sensor *, sensor_type_t,
   @@ -219,9 +219,9 @@
        .sd_set_trigger_thresh = lis2dh12_sensor_set_trigger_thresh,
        .sd_clear_low_trigger_thresh = lis2dh12_sensor_clear_low_thresh,
        .sd_clear_high_trigger_thresh = lis2dh12_sensor_clear_high_thresh,
   -    .sd_set_notification   = lis2dh12_sensor_set_notification,
   +    .sd_set_notification = lis2dh12_sensor_set_notification,
        .sd_unset_notification = lis2dh12_sensor_unset_notification,
   -    .sd_handle_interrupt   = lis2dh12_sensor_handle_interrupt
   +    .sd_handle_interrupt = lis2dh12_sensor_handle_interrupt
    };
    
    #if !MYNEWT_VAL(BUS_DRIVER_PRESENT)
   @@ -240,14 +240,13 @@
                         uint8_t len)
    {
        int rc;
   -    if (len > 1)
   -    {
   +    if (len > 1) {
            addr |= LIS2DH12_I2C_ADDR_INC;
        }
    
        uint8_t payload[20] = { addr, 0, 0, 0, 0, 0, 0, 0,
   -                              0, 0, 0, 0, 0, 0, 0, 0,
   -                              0, 0, 0, 0};
   +                            0, 0, 0, 0, 0, 0, 0, 0,
   +                            0, 0, 0, 0};
    
        struct hal_i2c_master_data data_struct = {
            .address = itf->si_addr,
   @@ -371,8 +370,8 @@
    {
        int rc;
        uint8_t payload[20] = { addr, 0, 0, 0, 0, 0, 0, 0,
   -                               0, 0, 0, 0, 0, 0, 0, 0,
   -                               0, 0, 0, 0};
   +                            0, 0, 0, 0, 0, 0, 0, 0,
   +                            0, 0, 0, 0};
    
        struct hal_i2c_master_data data_struct = {
            .address = itf->si_addr,
   @@ -1191,7 +1190,7 @@
    
        /* Check if we did not missed interrupt */
        if (hal_gpio_read(interrupt->ints[int_num].host_pin) ==
   -                                            interrupt->ints[int_num].active) {
   +        interrupt->ints[int_num].active) {
            OS_EXIT_CRITICAL(interrupt->lock);
            return OS_OK;
        }
   @@ -1301,7 +1300,7 @@
    
        /* Add the light driver */
        rc = sensor_set_driver(sensor, SENSOR_TYPE_ACCELEROMETER,
   -            (struct sensor_driver *) &g_lis2dh12_sensor_driver);
   +                           (struct sensor_driver *) &g_lis2dh12_sensor_driver);
        if (rc) {
            goto err;
        }
   @@ -1510,7 +1509,8 @@
        return rc;
    }
    
   -int lis2dh12_run_self_test(struct sensor_itf *itf, int *result)
   +int
   +lis2dh12_run_self_test(struct sensor_itf *itf, int *result)
    {
        int rc, rc2;
        int i;
   @@ -1751,8 +1751,8 @@
    {
        struct sensor_accel_data sad;
        struct sensor_itf *itf;
   -    int16_t x, y ,z;
   -    float fx, fy ,fz;
   +    int16_t x, y,z;
   +    float fx, fy,fz;
        int rc;
    
        itf = SENSOR_GET_ITF(sensor);
   @@ -1947,7 +1947,7 @@
    
    static int
    lis2dh12_sensor_read(struct sensor *sensor, sensor_type_t type,
   -        sensor_data_func_t data_func, void *data_arg, uint32_t timeout)
   +                     sensor_data_func_t data_func, void *data_arg, uint32_t timeout)
    {
        int rc;
        const struct lis2dh12_cfg *cfg;
   @@ -2021,10 +2021,10 @@
        }
    
        if (i == cfg->max_num_notif) {
   -       /* here if type is set to a non valid event or more than one event
   -        * we do not currently support registering for more than one event
   -        * per notification
   -        */
   +        /* here if type is set to a non valid event or more than one event
   +         * we do not currently support registering for more than one event
   +         * per notification
   +         */
            goto err;
        }
    
   @@ -2069,7 +2069,7 @@
    
        lis2dh12 = (struct lis2dh12 *)SENSOR_GET_DEVICE(sensor);
    
   -    return lis2dh12_config(lis2dh12, (struct lis2dh12_cfg*)cfg);
   +    return lis2dh12_config(lis2dh12, (struct lis2dh12_cfg *)cfg);
    }
    
    static int
   @@ -2101,47 +2101,47 @@
    
    #if MYNEWT_VAL(LIS2DH12_NOTIF_STATS)
        switch (event) {
   -        case SENSOR_EVENT_TYPE_SLEEP:
   -            STATS_INC(g_lis2dh12stats, sleep_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_SINGLE_TAP:
   -            STATS_INC(g_lis2dh12stats, single_tap_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_DOUBLE_TAP:
   -            STATS_INC(g_lis2dh12stats, double_tap_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_ORIENT_CHANGE:
   -            STATS_INC(g_lis2dh12stats, orient_chg_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_ORIENT_X_L_CHANGE:
   -            STATS_INC(g_lis2dh12stats, orient_chg_x_l_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_ORIENT_X_H_CHANGE:
   -            STATS_INC(g_lis2dh12stats, orient_chg_x_h_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_ORIENT_Y_L_CHANGE:
   -            STATS_INC(g_lis2dh12stats, orient_chg_y_l_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_ORIENT_Y_H_CHANGE:
   -            STATS_INC(g_lis2dh12stats, orient_chg_y_h_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_ORIENT_Z_L_CHANGE:
   -            STATS_INC(g_lis2dh12stats, orient_chg_z_l_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_ORIENT_Z_H_CHANGE:
   -            STATS_INC(g_lis2dh12stats, orient_chg_z_h_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_SLEEP_CHANGE:
   -            STATS_INC(g_lis2dh12stats, sleep_chg_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_WAKEUP:
   -            STATS_INC(g_lis2dh12stats, wakeup_notify);
   -            break;
   -        case SENSOR_EVENT_TYPE_FREE_FALL:
   -            STATS_INC(g_lis2dh12stats, free_fall_notify);
   -            break;
   -        default:
   -            break;
   +    case SENSOR_EVENT_TYPE_SLEEP:
   +        STATS_INC(g_lis2dh12stats, sleep_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_SINGLE_TAP:
   +        STATS_INC(g_lis2dh12stats, single_tap_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_DOUBLE_TAP:
   +        STATS_INC(g_lis2dh12stats, double_tap_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_ORIENT_CHANGE:
   +        STATS_INC(g_lis2dh12stats, orient_chg_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_ORIENT_X_L_CHANGE:
   +        STATS_INC(g_lis2dh12stats, orient_chg_x_l_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_ORIENT_X_H_CHANGE:
   +        STATS_INC(g_lis2dh12stats, orient_chg_x_h_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_ORIENT_Y_L_CHANGE:
   +        STATS_INC(g_lis2dh12stats, orient_chg_y_l_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_ORIENT_Y_H_CHANGE:
   +        STATS_INC(g_lis2dh12stats, orient_chg_y_h_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_ORIENT_Z_L_CHANGE:
   +        STATS_INC(g_lis2dh12stats, orient_chg_z_l_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_ORIENT_Z_H_CHANGE:
   +        STATS_INC(g_lis2dh12stats, orient_chg_z_h_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_SLEEP_CHANGE:
   +        STATS_INC(g_lis2dh12stats, sleep_chg_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_WAKEUP:
   +        STATS_INC(g_lis2dh12stats, wakeup_notify);
   +        break;
   +    case SENSOR_EVENT_TYPE_FREE_FALL:
   +        STATS_INC(g_lis2dh12stats, free_fall_notify);
   +        break;
   +    default:
   +        break;
        }
    #endif
    
   @@ -2150,7 +2150,7 @@
    
    static int
    lis2dh12_notify(struct lis2dh12 *lis2dh12, uint16_t src,
   -                    sensor_event_type_t event_type)
   +                sensor_event_type_t event_type)
    {
        struct lis2dh12_notif_cfg *notif_cfg;
    
   @@ -2265,7 +2265,7 @@
         * did not happened and there is no need to query device about it
         */
        if ((pdd->notify_ctx.snec_evtype &
   -            (SENSOR_EVENT_TYPE_DOUBLE_TAP | SENSOR_EVENT_TYPE_DOUBLE_TAP)) != 0) {
   +         (SENSOR_EVENT_TYPE_DOUBLE_TAP | SENSOR_EVENT_TYPE_DOUBLE_TAP)) != 0) {
            /* Read click interrupt state from device */
            rc = lis2dh12_clear_click(itf, &click_src);
            if (rc) {
   @@ -2274,7 +2274,7 @@
            }
    
            if ((pdd->notify_ctx.snec_evtype & SENSOR_EVENT_TYPE_SINGLE_TAP) &&
   -                (click_src & LIS2DH12_CLICK_SRC_SCLICK)) {
   +            (click_src & LIS2DH12_CLICK_SRC_SCLICK)) {
                rc = lis2dh12_notify(lis2dh12, click_src, SENSOR_EVENT_TYPE_SINGLE_TAP);
                if (rc) {
                    goto err;
   @@ -2283,7 +2283,7 @@
            }
    
            if ((pdd->notify_ctx.snec_evtype & SENSOR_EVENT_TYPE_DOUBLE_TAP) &&
   -                (click_src & LIS2DH12_CLICK_SRC_DCLICK)) {
   +            (click_src & LIS2DH12_CLICK_SRC_DCLICK)) {
                rc = lis2dh12_notify(lis2dh12, click_src, SENSOR_EVENT_TYPE_DOUBLE_TAP);
                if (rc) {
                    goto err;
   @@ -2331,14 +2331,13 @@
                    sensor_mgr_put_notify_evt(&lis2dh12->pdd.notify_ctx,
                                               SENSOR_EVENT_TYPE_SLEEP);
                    lis2dh12_inc_notif_stats(SENSOR_EVENT_TYPE_SLEEP);
   -            } else{
   +            } else {
                    notif_cfg = lis2dh12_find_notif_cfg_by_event(SENSOR_EVENT_TYPE_SLEEP_CHANGE,
                                                                 &lis2dh12->cfg);
                    /* Sleep change interrupt must be configured for int2 */
                    if ((notif_cfg && int2_pin_state && itf->si_ints[1].active == HAL_GPIO_TRIG_RISING) ||
   -                        (notif_cfg && !int2_pin_state && itf->si_ints[1].active == HAL_GPIO_TRIG_FALLING) ||
   -                        (notif_cfg && itf->si_ints[1].active == HAL_GPIO_TRIG_BOTH))
   -                {
   +                    (notif_cfg && !int2_pin_state && itf->si_ints[1].active == HAL_GPIO_TRIG_FALLING) ||
   +                    (notif_cfg && itf->si_ints[1].active == HAL_GPIO_TRIG_BOTH)) {
                        /* Sleep change detected, either wake-up or sleep */
                        sensor_mgr_put_notify_evt(&lis2dh12->pdd.notify_ctx,
                                                  SENSOR_EVENT_TYPE_SLEEP_CHANGE);
   @@ -2355,7 +2354,7 @@
    
    static int
    lis2dh12_sensor_get_config(struct sensor *sensor, sensor_type_t type,
   -        struct sensor_cfg *cfg)
   +                           struct sensor_cfg *cfg)
    {
        int rc;
    
   @@ -2783,7 +2782,7 @@
                goto err;
            }
    
   -        reg  = low_thresh.sad->sad_x_is_valid ? LIS2DH12_INT2_CFG_XLIE : 0;
   +        reg = low_thresh.sad->sad_x_is_valid ? LIS2DH12_INT2_CFG_XLIE : 0;
            reg |= low_thresh.sad->sad_y_is_valid ? LIS2DH12_INT2_CFG_YLIE : 0;
            reg |= low_thresh.sad->sad_z_is_valid ? LIS2DH12_INT2_CFG_ZLIE : 0;
    
   @@ -2869,7 +2868,7 @@
                goto err;
            }
    
   -        reg  = high_thresh.sad->sad_x_is_valid ? LIS2DH12_INT2_CFG_XHIE : 0;
   +        reg = high_thresh.sad->sad_x_is_valid ? LIS2DH12_INT2_CFG_XHIE : 0;
            reg |= high_thresh.sad->sad_y_is_valid ? LIS2DH12_INT2_CFG_YHIE : 0;
            reg |= high_thresh.sad->sad_z_is_valid ? LIS2DH12_INT2_CFG_ZHIE : 0;
    
   @@ -2965,7 +2964,8 @@
     * @param the tap settings
     * @return 0 on success, non-zero on failure
     */
   -int lis2dh12_set_tap_cfg(struct sensor_itf *itf, struct lis2dh12_tap_settings *cfg)
   +int
   +lis2dh12_set_tap_cfg(struct sensor_itf *itf, struct lis2dh12_tap_settings *cfg)
    {
        int rc;
        uint8_t reg;
   @@ -3074,8 +3074,8 @@
        lis2dh12->cfg.lc_pull_up_disc = cfg->lc_pull_up_disc;
    
        rc = lis2dh12_hpf_cfg(itf, (cfg->hp_mode << 6) | (cfg->hp_cut_off << 4) |
   -                               (cfg->hp_fds << 3) | (cfg->hp_click << 2) |
   -                               (cfg->hp_ia2 << 1) | cfg->hp_ia1);
   +                          (cfg->hp_fds << 3) | (cfg->hp_click << 2) |
   +                          (cfg->hp_ia2 << 1) | cfg->hp_ia1);
        if (rc) {
            goto err;
        }
   @@ -3118,8 +3118,7 @@
        }
    
        rc = lis2dh12_set_ref_thresh(itf, cfg->reference);
   -    if (rc)
   -    {
   +    if (rc) {
            goto err;
        }
    
   @@ -3183,7 +3182,7 @@
        if (rc) {
            goto err;
        }
   -//    lis2dh12_shell_init();
   +/*    lis2dh12_shell_init(); */
        lis2dh12->cfg.read_mode.int_cfg = cfg->read_mode.int_cfg;
        lis2dh12->cfg.read_mode.int_num = cfg->read_mode.int_num;
        lis2dh12->cfg.read_mode.mode = cfg->read_mode.mode;
   ```
   
   </details>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services