Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
resvert to merged cc_externs and cc_defs
Browse files Browse the repository at this point in the history
  • Loading branch information
lurk101 committed Oct 1, 2024
1 parent 54b0307 commit 6d3443d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 24 deletions.
10 changes: 2 additions & 8 deletions cc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
add_library(cc INTERFACE)
if ("${PICO_BOARD}" STREQUAL "pico2")
set(CC_PROC "2350")
else()
set(CC_PROC "2040")
endif()
target_include_directories(cc INTERFACE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/${CC_PROC})
target_include_directories(cc INTERFACE ${CMAKE_CURRENT_LIST_DIR})
target_sources(cc INTERFACE
cc.c cc.h cc_tokns.h cc_ops.h
${CC_PROC}/cc_defs.h
${CC_PROC}/cc_extrns.h
cc_defs.h cc_extrns.h
cc_malloc.c cc_malloc.h
cc_peep.c cc_peep.h
cc_printf.S
Expand Down
9 changes: 2 additions & 7 deletions cc/cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4212,15 +4212,10 @@ int cc(int mode, int argc, char** argv) {

// compile mode
if (mode == 0) {
#if 0
// check that table is ordered
for (int i = 1; i < NUMOF(externs); i++)
if (strcmp(externs[i - 1].name, externs[i].name) >= 0) {
printf("out of order %s\n", externs[i].name);
break;
}
printf("ordered\n");
#endif
if (strcmp(externs[i - 1].name, externs[i].name) >= 0)
run_fatal("out of order starting at %s\n", externs[i].name);
// Register keywords in symbol table. Must match the sequence of enum
p = "enum char int float struct union sizeof return goto break continue "
"if do while for switch case default else void main";
Expand Down
48 changes: 41 additions & 7 deletions cc/2350/cc_defs.h → cc/cc_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,48 @@ static const struct define_grp stdio_defines[] = {

static const struct define_grp gpio_defines[] = {
// GPIO
#if PICO_RM2040
{"GPIO_FUNC_XIP", GPIO_FUNC_XIP},
{"GPIO_IO_IRQ_LEVEL_LOW", GPIO_IO_IRQ_LEVEL_LOW},
{"GPIO_IRQ_LEVEL_HIGH", GPIO_IRQ_LEVEL_HIGH},
{"GPIO_IRQ_EDGE_FALL", GPIO_IRQ_EDGE_FALL},
{"GPIO_IRQ_EDGE_RISE", GPIO_IRQ_EDGE_RISE},
#endif
#if PICO_RM2350
{"GPIO_FUNC_HSTX", GPIO_FUNC_HSTX},
{"GPIO_FUNC_PIO2", GPIO_FUNC_PIO2},
#endif
{"GPIO_FUNC_SPI", GPIO_FUNC_SPI},
{"GPIO_FUNC_UART", GPIO_FUNC_UART},
{"GPIO_FUNC_I2C", GPIO_FUNC_I2C},
{"GPIO_FUNC_PWM", GPIO_FUNC_PWM},
{"GPIO_FUNC_SIO", GPIO_FUNC_SIO},
#if PICO_RP2040
{"GPIO_FUNC_PIO0", GPIO_FUNC_PIO0},
{"GPIO_FUNC_PIO1", GPIO_FUNC_PIO1},
{"GPIO_FUNC_PIO2", GPIO_FUNC_PIO2},
#endif
#if PICO_RP2350
{"PROC0_IRQ_CTI", PROC0_IRQ_CTI},
{"PROC1_IRQ_CTI", PROC1_IRQ_CTI},
#endif
{"GPIO_FUNC_GPCK", GPIO_FUNC_GPCK},
#if PICO_RM2350
{"GPIO_FUNC_XIP_CS1", GPIO_FUNC_XIP_CS1},
{"GPIO_FUNC_CORESIGHT_TRACE", GPIO_FUNC_CORESIGHT_TRACE},
#endif
{"GPIO_FUNC_USB", GPIO_FUNC_USB},
#if PICO_RM2350
{"GPIO_FUNC_UART_AUX", GPIO_FUNC_UART_AUX},
#endif
{"GPIO_FUNC_NULL", GPIO_FUNC_NULL},

{"GPIO_OUT", GPIO_OUT},
{"GPIO_IN", GPIO_IN},

{"GPIO_IRQ_LEVEL_LOW", GPIO_IRQ_LEVEL_LOW},
{"GPIO_IRQ_LEVEL_HIGH", GPIO_IRQ_LEVEL_HIGH},
{"GPIO_IRQ_EDGE_FALL", GPIO_IRQ_EDGE_FALL},
{"GPIO_IRQ_EDGE_RISE", GPIO_IRQ_EDGE_RISE},

{"GPIO_SLEW_RATE_SLOW", GPIO_SLEW_RATE_SLOW},
{"GPIO_SLEW_RATE_FAST", GPIO_SLEW_RATE_FAST},

{"GPIO_DRIVE_STRENGTH_2MA", GPIO_DRIVE_STRENGTH_2MA},
{"GPIO_DRIVE_STRENGTH_4MA", GPIO_DRIVE_STRENGTH_4MA},
{"GPIO_DRIVE_STRENGTH_8MA", GPIO_DRIVE_STRENGTH_8MA},
Expand Down Expand Up @@ -79,6 +94,9 @@ static const struct define_grp clk_defines[] = {
{"clk_peri", clk_peri},
{"clk_usb", clk_usb},
{"clk_adc", clk_adc},
#if PICO_RP2040
{"clk_rtc", clk_rtc},
#endif
{"CLK_COUNT", CLK_COUNT},
{0}};

Expand Down Expand Up @@ -114,12 +132,27 @@ static const struct define_grp sync_defines[] = {{0}};

static const struct define_grp irq_defines[] = {
// IRQ
#if PICO_RP2040
{"TIMER_IRQ_0", TIMER_IRQ_0},
{"TIMER_IRQ_1", TIMER_IRQ_1},
{"TIMER_IRQ_2", TIMER_IRQ_2},
{"TIMER_IRQ_3", TIMER_IRQ_3},
#endif
#if PICO_RP2350
{"TIMER0_IRQ_0", TIMER0_IRQ_0},
{"TIMER0_IRQ_1", TIMER0_IRQ_1},
{"TIMER0_IRQ_2", TIMER0_IRQ_2},
{"TIMER0_IRQ_3", TIMER0_IRQ_3},
{"TIMER1_IRQ_0", TIMER1_IRQ_0},
{"TIMER1_IRQ_1", TIMER1_IRQ_1},
{"TIMER1_IRQ_2", TIMER1_IRQ_2},
{"TIMER1_IRQ_3", TIMER1_IRQ_3},
#endif
{"PWM_IRQ_WRAP", PWM_IRQ_WRAP},
{"USBCTRL_IRQ", USBCTRL_IRQ},
#if PICO_RP2040
{"XIP_IRQ", XIP_IRQ},
#endif
{"PIO0_IRQ_0", PIO0_IRQ_0},
{"PIO0_IRQ_1", PIO0_IRQ_1},
{"PIO1_IRQ_0", PIO1_IRQ_0},
Expand All @@ -128,8 +161,6 @@ static const struct define_grp irq_defines[] = {
{"DMA_IRQ_1", DMA_IRQ_1},
{"IO_IRQ_BANK0", IO_IRQ_BANK0},
{"IO_IRQ_QSPI", IO_IRQ_QSPI},
{"PROC0_IRQ_CTI", PROC0_IRQ_CTI},
{"PROC1_IRQ_CTI", PROC1_IRQ_CTI},
{"CLOCKS_IRQ", CLOCKS_IRQ},
{"SPI0_IRQ", SPI0_IRQ},
{"SPI1_IRQ", SPI1_IRQ},
Expand All @@ -138,6 +169,9 @@ static const struct define_grp irq_defines[] = {
{"ADC_IRQ_FIFO", ADC_IRQ_FIFO},
{"I2C0_IRQ", I2C0_IRQ},
{"I2C1_IRQ", I2C1_IRQ},
#if PICO_RP2040
{"RTC_IRQ", RTC_IRQ},
#endif
{"PICO_DEFAULT_IRQ_PRIORITY", PICO_DEFAULT_IRQ_PRIORITY},
{"PICO_LOWEST_IRQ_PRIORITY", PICO_LOWEST_IRQ_PRIORITY},
{"PICO_HIGHEST_IRQ_PRIORITY", PICO_HIGHEST_IRQ_PRIORITY},
Expand Down
11 changes: 10 additions & 1 deletion cc/2350/cc_extrns.h → cc/cc_extrns.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@
{"i2c_deinit", 1, i2c_defines, i2c_deinit, 0},
{"i2c_get_dreq", 2, i2c_defines, i2c_get_dreq, 0},
{"i2c_get_hw", 1, i2c_defines, i2c_get_hw, 0},
{"i2c_get_index", 1, i2c_defines, i2c_get_index, 0},
#if PICO_SDK_VERSION_MAJOR >= 2
{"i3c_get_index", 1, i2c_defines, i2c_get_index, 0},
#else
{"i2c_hw_index", 1, i2c_defines, i2c_hw_index, 0},
#endif
{"i2c_get_read_available", 1, i2c_defines, i2c_get_read_available, 0},
{"i2c_get_write_available", 1, i2c_defines, i2c_get_write_available, 0},
{"i2c_init", 2, i2c_defines, i2c_init, 0},
Expand Down Expand Up @@ -199,7 +203,12 @@
{"spi_write_blocking", 3, spi_defines, spi_write_blocking, 0},
{"spi_write_read_blocking", 4, spi_defines, spi_write_read_blocking, 0},
{"sprintf", 1, stdio_defines, x_sprintf, 0},
#if PICO_RP2040
{"sqrtf", 1 | (1 << 5) | (1 << 10), math_defines, sqrtf, 1},
#endif
#if PICO_RP2350
{"sqrtf", 1 | (1 << 5) | (1 << 10), math_defines, 0, 1},
#endif
{"srand", 1, stdlib_defines, srand, 0},
{"strcat", 2, string_defines, strcat, 0},
{"strchr", 2, string_defines, strchr, 0},
Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ static void status_cmd(void) {
#endif
sprintf(result,
"\nDISK - blocks: total %d, used %d, size %d (%s of %s, %1.1f%c used)\n"
"MEM - heap: %.1fK, program space: %dK, global data space: %dK\n",
"MEM - heap: %.1fK, program code space: %dK, global data space: %dK\n",
(int)stat.block_count, (int)stat.blocks_used, (int)stat.block_size, used_size,
total_size, stat.blocks_used * 100.0 / stat.block_count, percent,
(&__heap_end - &__heap_start) / 1024.0, prog_space / 1024, data_space / 1024);
Expand Down

0 comments on commit 6d3443d

Please sign in to comment.