3 Commits

Author SHA1 Message Date
hugo LAMY
41b5ec5e35 added test macro in readme 2025-03-06 02:01:04 +01:00
hugo LAMY
c650ff1157 trying to fiw devcontainer to works with 42 chips 2025-03-06 02:00:56 +01:00
hugo LAMY
8a28799aac added devcontainer 2025-03-06 00:30:38 +00:00
3 changed files with 70 additions and 0 deletions

24
.devcontainer/Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
# Use Ubuntu as the base image
FROM ubuntu:latest
# Update and install necessary dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
vim \
avr-libc gcc-avr binutils-avr \
avrdude \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory to /workspace (VSCode will mount your local folder here)
WORKDIR /workspace
# Set the default user as root for installing packages
USER root
# Expose any necessary ports (if needed)
# EXPOSE 3000
# Run bash as the default command when the container starts
CMD ["/bin/bash"]

View File

@@ -0,0 +1,11 @@
{
"name": "Ubuntu DevContainer",
"dockerFile": "Dockerfile", // Reference to your Dockerfile
"context": ".", // The context is the root of your project
"workspaceFolder": "/workspace", // Where VSCode will mount your current folder inside the container
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind",
"source=/dev/tty.usbserial-310,target=/dev/ttyUSB0,type=bind"
],
"postCreateCommand": "echo 'Devcontainer setup complete!'"
}

View File

@@ -79,3 +79,38 @@ avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done. Thank you.
```
## test macros
#include <stdio.h>
#include <avr/io.h>
// // stringify
#define STRINGIFY_HELPER(x) #x
#define STRINGIFY(x) STRINGIFY_HELPER(x)
#define CONCAT_HELPER(x, y) x ## y
#define CONCAT(x, y) CONCAT_HELPER(x, y)
// get argument at nth position
#define ARG_1(v1, v2) v1
#define ARG_2(v1, v2) v2
#define GET_PORT(args) ARG_1 args
#define GET_BIT(args) ARG_2 args
// actions on registers
#define SET(register, bit) register |= 1 << bit
// actions on ports
#define MODE_OUTPUT(elem) SET(CONCAT(DDR, GET_PORT(elem)), GET_BIT(elem))
// elements
#define LED1 (B, 0)
int main()
{
MODE_OUTPUT(LED1);
return 0;
}