Skip to content

Commit

Permalink
ports/psoc6: Removing additional driver layer.
Browse files Browse the repository at this point in the history
Signed-off-by: NikhitaR-IFX <Nikhita.Rajasekhar@infineon.com>
  • Loading branch information
NikhitaR-IFX authored and jaenrig-ifx committed Jul 25, 2023
1 parent fc95866 commit 4fc94e8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 78 deletions.
1 change: 0 additions & 1 deletion ports/psoc6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ DRIVERS_SRC_C += $(addprefix drivers/,\
machine/psoc6_i2c.c \
machine/psoc6_pwm.c \
machine/psoc6_system.c \
machine/psoc6_adc.c \
)

MOD_SRC_C += $(addprefix modules/,\
Expand Down
47 changes: 0 additions & 47 deletions ports/psoc6/drivers/machine/psoc6_adc.c

This file was deleted.

21 changes: 0 additions & 21 deletions ports/psoc6/drivers/machine/psoc6_adc.h

This file was deleted.

13 changes: 8 additions & 5 deletions ports/psoc6/modules/machine/machine_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

// port-specific includes
#include "modmachine.h"
#include "drivers/machine/psoc6_adc.h"
#include "pins.h"
#include "machine_adc.h"

#include "cybsp.h"
#include "cyhal.h"
#include "cy_pdl.h"

#define DEFAULT_ADC_ACQ_NS 1000

#define IS_GPIO_VALID_ADC_PIN(gpio) ((gpio == CYHAL_NC_PIN_VALUE) || ((gpio >= 80) && (gpio <= 87)))
Expand Down Expand Up @@ -38,7 +41,7 @@ machine_adc_obj_t *adc_init_helper(uint32_t sampling_time, uint32_t pin, uint8_t
}
// Initialize the ADC block (required only once per execution)
if (!adc_init_flag) {
adc_init(&adc_obj, pin, NULL);
cyhal_adc_init(&adc_obj, pin, NULL);
adc_init_flag = true;
}

Expand All @@ -51,7 +54,7 @@ machine_adc_obj_t *adc_init_helper(uint32_t sampling_time, uint32_t pin, uint8_t
};

// Initialize channel
adc_ch_init(&adc_channel_obj, &adc_obj, pin, CYHAL_NC_PIN_VALUE, &channel_config);
cyhal_adc_channel_init_diff(&adc_channel_obj, &adc_obj, pin, CYHAL_ADC_VNEG, &channel_config);

// Create ADC Object
machine_adc_obj_t *o = mp_obj_malloc(machine_adc_obj_t, &machine_adc_type);
Expand Down Expand Up @@ -106,14 +109,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_block_obj, machine_adc_block);
// read_u16()
STATIC mp_obj_t machine_adc_read_u16(mp_obj_t self_in) {
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
return MP_OBJ_NEW_SMALL_INT(adc_read_u16(&self->block->adc_chan_obj));
return MP_OBJ_NEW_SMALL_INT(cyhal_adc_read_u16(&self->block->adc_chan_obj));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_u16_obj, machine_adc_read_u16);

// read_uv
STATIC mp_obj_t machine_adc_read_uv(mp_obj_t self_in) {
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
return MP_OBJ_NEW_SMALL_INT(adc_read_uv(&self->block->adc_chan_obj));
return MP_OBJ_NEW_SMALL_INT(cyhal_adc_read_uv(&self->block->adc_chan_obj));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_uv_obj, machine_adc_read_uv);

Expand Down
3 changes: 0 additions & 3 deletions ports/psoc6/modules/machine/machine_adcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ STATIC mp_obj_t machine_adcblock_connect(size_t n_pos_args, const mp_obj_t *pos_
if (mp_obj_is_int(pos_args[1])) {
channel = mp_obj_get_int(pos_args[1]);
if (channel <= 7) {
// adc_pin
// self->ch = mp_obj_get_int(pos_args[1]);
self->adc_pin = ch_pin_obj[channel].pin;
}
}
Expand All @@ -75,7 +73,6 @@ STATIC mp_obj_t machine_adcblock_connect(size_t n_pos_args, const mp_obj_t *pos_
for (int i = 0; i < MP_ARRAY_SIZE(ch_pin_obj); i++)
{
if (ch_pin_obj[i].pin == adc_pin_obj->pin_addr) {
// self->ch = ch_pin_obj[i].ch;
self->adc_pin = adc_pin_obj->pin_addr;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ports/psoc6/modules/machine/machine_adcblock.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef MICROPY_INCLUDED_MACHINE_ADCBLOCK_H
#define MICROPY_INCLUDED_MACHINE_ADCBLOCK_H

#include "drivers/machine/psoc6_adc.h"
// #include "drivers/machine/psoc6_adc.h"
#define DEFAULT_ADC_BITS 12

typedef struct _machine_adcblock_obj_t {
Expand Down

0 comments on commit 4fc94e8

Please sign in to comment.