Added allocation failure chcks, enabled sleep gem.

Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
Yilin Sun 2023-03-18 10:16:33 +08:00
parent 6be5185d38
commit 309be9522b
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
3 changed files with 7 additions and 0 deletions

View File

@ -47,6 +47,7 @@ MRuby::CrossBuild.new("lpc55s69") do |conf|
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-numeric-ext"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-sleep"
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-string-ext"
conf.gem :core => "mruby-time"

View File

@ -40,6 +40,9 @@ static mrb_value mrb_adc_initialize(mrb_state *mrb, mrb_value self) {
}
mrb_adc_t *adc_ch = mrb_malloc(mrb, sizeof(mrb_adc_t));
if (adc_ch == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "Failed to allocate ADC struct");
}
adc_ch->channel = channel_id;
adc_ch->avg = avg;

View File

@ -66,6 +66,9 @@ static mrb_value mrb_gpio_initialize(mrb_state *mrb, mrb_value self) {
}
mrb_gpio_t *pin = mrb_malloc(mrb, sizeof(mrb_gpio_t));
if (pin == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "Failed to allocate GPIO struct");
}
pin->pin = pin_num;
pin->cfg.initial_value = init_value;