Skip to content

Instantly share code, notes, and snippets.

View denizzzka's full-sized avatar

Denis Feklushkin denizzzka

View GitHub Profile
@denizzzka
denizzzka / main.d
Created August 27, 2024 10:37
ESP32c3 and ILI9341 display using Dlang: wrong colors
module main;
import esp_idf_binding;
enum CONFIG_FREERTOS_HZ = 1000;
enum portTICK_PERIOD_MS = 1000 / CONFIG_FREERTOS_HZ;
void ledBlink(gpio_num_t gpio, int delayMs) nothrow
{
gpio_reset_pin(gpio);
diff --git a/runtime/druntime/src/core/atomic.d b/runtime/druntime/src/core/atomic.d
index b2a2ff28d..d12989b5d 100644
--- a/runtime/druntime/src/core/atomic.d
+++ b/runtime/druntime/src/core/atomic.d
@@ -90,6 +90,11 @@ enum MemoryOrder
T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(auto ref return scope const T val) pure nothrow @nogc @trusted
if (!is(T == shared U, U) && !is(T == shared inout U, U) && !is(T == shared const U, U))
{
+ version (Druntime_FakeAtomic)
+ {
/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
$ ninja -j1 -k0
[1/16] Building CXX object CMakeFiles/LDCShared.dir/gen/functions.cpp.o
FAILED: CMakeFiles/LDCShared.dir/gen/functions.cpp.o
/usr/bin/clang++ -DLDC_DYNAMIC_COMPILE -DLDC_DYNAMIC_COMPILE_API_VERSION=3 -DLDC_ENABLE_PLUGINS -DLDC_LLVM_SUPPORTED_TARGET_AArch64=1 -DLDC_LLVM_SUPPORTED_TARGET_ARM=1 -DLDC_LLVM_SUPPORTED_TARGET_X86=1 -I../. -I../dmd -DDMDV2 -DHAVE_SC_ARG_MAX -O3 -DNDEBUG -I/home/denizzz/Dev/llvm-project/install-llvm/include -std=c++14 -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-non-virtual-dtor -Wno-gnu-anonymous-struct -Wno-nested-anon-types -Wno-gnu-redeclared-enum -Wno-unused-private-field -Wno-undefined-var-template -fvisibility-inlines-hidden -DLDC_POSIX -DIN_LLVM -DOPAQUE_VTBLS "-DLDC_INSTALL_PREFIX=R\"(/home/denizzz/Dev/ldc/install-ldc)\"" -DLDC_LLVM_VER=1100 "-DLDC_LIBDIR_SUFFIX=R\"()\"" -DLDC_HOST_LDMD=1 -DLDC_HOST_FE_VER=2090 -MD
build d/18ac3e7@@D$ code$ part@sta/gpio.d: CUSTOM_COMMAND /home/denizzz/Dev/d_c_arm_test/d/source/bindings/gpio.dpp | /home/denizzz/Dev/d_c_arm_test/subprojects/dpp/dpp_helper.sh
DESC = Generating$ 'd/18ac3e7@@D$ code$ part@sta/gpio.d'.
COMMAND = /home/denizzz/Dev/d_c_arm_test/subprojects/dpp/dpp_helper.sh /home/denizzz/Dev/d_c_arm_test/d/source/bindings/gpio.dpp 'd/18ac3e7@@D$ code$ part@sta/gpio.dpp' --preprocess-only --include-path=/home/denizzz/Dev/d_c_arm_test/subprojects/libopencm3/include/ --define=STM32F1
build d/18ac3e7@@D$ code$ part@sta/freertos.d: CUSTOM_COMMAND /home/denizzz/Dev/d_c_arm_test/d/source/bindings/freertos.dpp | /home/denizzz/Dev/d_c_arm_test/subprojects/dpp/dpp_helper.sh
DESC = Generating$ 'd/18ac3e7@@D$ code$ part@sta/freertos.d'.
COMMAND = /home/denizzz/Dev/d_c_arm_test/subprojects/dpp/dpp_helper.sh /home/denizzz/Dev/d_c_arm_test/d/source/bindings/freertos.dpp 'd/18ac3e7@@D$ code$ part@sta/freertos.dpp' --preprocess-only --include-path=/home/denizzz/Dev/d_c_arm_test/subproject
project(
'test project',
['c'],
version: 'v0.0.1',
)
e = executable(
'some prog',
[
'source/app.c',
d_dep = library(
'D code part',
[
'source/app.d',
'source/bindings/types.d',
],
include_directories: [
'source',
],
)
@denizzzka
denizzzka / blinker.d
Last active January 23, 2020 12:04
Bare metal Dlang ARM
// https://github.com/ldc-developers/ldc/issues/3290
import ldc.attributes;
@llvmAttr("nounwind"):
import ldc.llvmasm;
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
static void gpio_setup()
{
import ldc.llvmasm;
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
void main() {
// Enable clock GPIOC
rcc_periph_clock_enable(RCC_GPIOC);
// Configure GPIO13
gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);