Skip to content

Instantly share code, notes, and snippets.

View farrrb's full-sized avatar

Fabian Zahn - 0xFAB farrrb

  • Danfoss Power Solutions
  • Hamburg, Germany
View GitHub Profile
@farrrb
farrrb / log2.c
Created March 9, 2018 17:05
Fast and efficient log2 function with gcc builtin
#include <stdio.h>
#include <stdint.h>
// log 2 - with ceil rounding
int32_t log2_uint32 (uint32_t u)
{
if (u == 0) { return INT32_MIN; }
return ((int32_t)31 - (int32_t)__builtin_clz(u));
}
@farrrb
farrrb / toolchain_c2000.cmake
Last active May 21, 2024 09:41
C2000 Compiler Toolchain File for CMake (TMS320x2xxx Microcontroller)
###############################################################################
# cl2000 - Toolchain File
# F. Zahn - 2018
###############################################################################
#set this path according to your needs
set(CGT_TOOLCHAIN_DIR "C:/your/path/to/the/toolchain")
# set target system
set(CMAKE_SYSTEM_NAME Generic)
@farrrb
farrrb / toolchain-ti-c2000.cmake
Created February 16, 2018 14:10 — forked from 0xjairo/toolchain-ti-c2000.cmake
TI C2000 (F2807x) CMake toolchain file
# Create a file named options.cmake and populate with valid paths assigned to the following:
#
# set(CG_TOOL_ROOT "/opt/ti/ccsv7/tools/compiler/ti-cgt-c2000_16.9.1.LTS")
# set(DEVICE_SUPPORT_ROOT "/home/asdf/controlSUITE/device_support/F2807x/v210")
#
# Then do:
# mkdir build && cd build
# cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-ti-c2000.cmake ..
# make