Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Aug 14, 2024
1 parent f12994e commit 2410921
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ else()
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(C3_BUILD_TYPE "-g0")
set(C3_BUILD_TYPE "-g")
else()
set(C3_BUILD_TYPE "-Oz")
endif()
Expand Down
25 changes: 17 additions & 8 deletions main/app.c3
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@ fn void main() @export("app_main")
{
newlib::printf("Hello, world from C3!\nIDF version: %s\n", idf::esp_get_idf_version());

defer idf::heap_caps_dump_all();

newlib::printf("Malloc test:\n");
void* ptr = idf::heap_caps_malloc(100, idf::MALLOC_CAP_DEFAULT);
newlib::printf("Allocated 100 bytes at %p\n", ptr);
idf::heap_caps_free(ptr);
newlib::printf("Freeing memory...\n");

newlib::printf("Malloc dump all\n");
defer
{
idf::heap_caps_free(ptr);
newlib::printf("Freeing memory...\n");
newlib::printf("Malloc dump all\n");
idf::heap_caps_dump_all();
}

if(idf::xTaskCreate(&taskSample, "taskSample", 10000, null, 1, null) != idf::ESP_OK){
if(idf::xTaskCreate(&taskSample, "myTask", 10000, null, 1, null) != idf::ESP_OK){
// TODO: Handle error
newlib::printf("TaskSample cannot be run!!\n");
}
}

fn void taskSample(void* arg) @export("taskSample") {
newlib::printf("TaskSample started\n");
fn void taskSample(void* arg) @export("myTask") {
while(true){
newlib::printf("TaskSample running, %d\n", counter);
if(counter == 10)
{
newlib::printf("TaskSample finished\n");
break;
} else
{
newlib::printf("TaskSample running, %d\n", counter);
}
idf::vTaskDelay(1000 / idf::TICK_PERIOD_MS);
counter++;
}
Expand Down

0 comments on commit 2410921

Please sign in to comment.