Skip to content

Instantly share code, notes, and snippets.

@DanGdl
DanGdl / StageTasks
Last active October 30, 2022 07:29
You'll need to make tasks, code of every task must be uploaded to separate branch in private repository in github (preferred)
or any other, submit avery task as merge request/pull request. Don't use external libraries (if something else not specified).
Build system - cmake.
Additional files: https://drive.google.com/drive/folders/1_4O6m54hghNsXVJQs8KzJ7bW2ge_YWHQ?usp=sharing
Git with UI: SourceTree (Windows), Sublime Merge (Linux)
Task 1:
Write a console application that accepts 2 strings as an input from user (text for anagram and text with filtering symbols).
If text with filtering symbols is empty, than ignored symbols are digits and non alphabetic symbols.
@DanGdl
DanGdl / dma in xilinx
Created January 26, 2023 16:44
sources about work with dma in xilinx
Guide:
https://stackoverflow.com/questions/70277481/how-to-access-xilinx-axi-dma-from-linux
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/1027702787/Linux+DMA+From+User+Space+2.0
Non xilinx driver:
https://github.com/bperez77/xilinx_axidma
Driver: https://github.com/Xilinx/linux-xlnx/blob/master/drivers/dma/xilinx/xilinx_dma.c
DMA test:
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842337/Linux+Soft+DMA+Driver
@DanGdl
DanGdl / spi_reading.c
Created February 26, 2023 11:30
reading from spi
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/spi/spidev.h>
/*
To read data from an SPI (Serial Peripheral Interface) device in Linux, you can use the spidev driver. Here are the basic steps:
@DanGdl
DanGdl / I2C.c
Last active August 3, 2023 10:39
I2C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "i2c.h"
#include "usart.h"
#include "rtg_main.h"
@DanGdl
DanGdl / spi.c
Created August 3, 2023 13:27
SPI
void q1_SPI_ping_pong() {
printf("\r\n\r\n\r\nQ1 Ping pong on SPI\r\n");
char message[] = "That's a SPI message";
char buffer1[128] = { '\0' };
char buffer2[128] = { '\0' };
while(1) {
HAL_StatusTypeDef status = HAL_SPI_Receive_IT(SPI_S, (uint8_t*) buffer1, LEN_STR(message));
if (status != HAL_OK) {
printf("Failed to receiveIT on SPI_S: %d, error 0x%"PRIX32"\r\n", status, HAL_SPI_GetError(SPI_S));
}
@DanGdl
DanGdl / local.conf
Created August 9, 2023 16:11
local.conf for yocto
RM_OLD_IMAGE = "1"
INHERIT += "rm_work"
IMAGE_INSTALL:append = " git python3"
# Also you can specify an amount of threads to use for build (default value: BB_NUMBER_THREADS = "${@oe.utils.cpu_count()}"):
#BB_NUMBER_THREADS = "4"
#PARALLEL_MAKE - number of processes for -j option (for gcc)
@DanGdl
DanGdl / receive from console
Created November 9, 2023 16:11
receive from console
void get_console_message(char* const buffer, unsigned int len_max) {
uint32_t count_symbols = 0;
printf("Please enter a message (max size 1024 symbols):\r\n");
while (1) {
uint8_t c;
HAL_StatusTypeDef status = HAL_UART_Receive(&huart3, &c, 1, HAL_MAX_DELAY);
if (c == '\r') {
HAL_UART_Transmit(&huart3, &c, 1, HAL_MAX_DELAY);
c = '\n';
HAL_UART_Transmit(&huart3, &c, 1, HAL_MAX_DELAY);
@DanGdl
DanGdl / matrixes.h
Last active March 1, 2024 11:19
N-dimension matrixes example
#ifndef MATRIXN_H_
#define MATRIXN_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned long int dimen_t;
@DanGdl
DanGdl / Tasks.txt
Last active January 18, 2024 14:43
Embedded linux C
Tasks for C course.
Common requirements:
- don't use external libraries (if something else not specified)
- build system make/cmake (must be in every task)
- compilation with options '-O0 -g3 -Wall -Wextra -Wpedantic -std=c11'
- error handling
- all task must be checked with valgrind for memory leaks: 'valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose /path/to/your/executable' (or with log file: 'valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt /path/to/your/executable')
!!!!!
@DanGdl
DanGdl / listener.c
Created February 20, 2024 06:40 — forked from hostilefork/listener.c
Simple listener and sender for UDP multicast
//
// Simple listener.c program for UDP multicast
//
// Adapted from:
// http://ntrg.cs.tcd.ie/undergrad/4ba2/multicast/antony/example.html
//
// Changes:
// * Compiles for Windows as well as Linux
// * Takes the port and group on the command line
//