Skip to content

Commit

Permalink
ports/psoc6: Clock WIP.
Browse files Browse the repository at this point in the history
Signed-off-by: IFX-Anusha <[email protected]>
  • Loading branch information
IFX-Anusha committed Oct 7, 2024
1 parent 79e501d commit 3002000
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 27 additions & 1 deletion ports/psoc6/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,36 @@ static mp_obj_t mp_machine_get_freq(void) {
return MP_OBJ_NEW_SMALL_INT(system_get_cpu_freq());
}

void cm4_set_frequency() {
mp_printf(&mp_plat_print, "Here set the cm4 fz");
}

void audio_set_frequency() {
mp_printf(&mp_plat_print, "Here set the audio fz");
}

void peripheral_set_frequency() {
mp_printf(&mp_plat_print, "Here set the peripheral fz");
}


static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
mp_raise_NotImplementedError(MP_ERROR_TEXT("Not implemented!!!\n"));
mp_int_t freq = mp_obj_get_int(args[0]);
if (n_args == 1) {
cm4_set_frequency(freq);
} else if (n_args > 1) {
const char *freq_peri = mp_obj_str_get_str(args[1]);
if (strcmp(freq_peri, "Audio") == 0) {
audio_set_frequency(freq); // audio fz
} else if (strcmp(freq_peri, "Peripheral") == 0) {
peripheral_set_frequency(freq); // cm4 fz
} else {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Invalid frequency type %s"), freq_peri);
}
}
}


// Sleep Modes Not working. Might be because of the REPL always running in background. Need to evaluate
static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
// cy_rslt_t result;
Expand Down
1 change: 1 addition & 0 deletions ports/psoc6/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1)
#define MICROPY_PY_TIME_TIME_TIME_NS (1)
#define MICROPY_PY_TIME_INCLUDEFILE "ports/psoc6/modtime.c"
#define MICROPY_PY_MACHINE_FREQ_NUM_ARGS_MAX (2)

#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_RESET (1)
Expand Down

0 comments on commit 3002000

Please sign in to comment.