Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build libfoobar
name: Build arithmos-native

on:
push:
Expand All @@ -16,12 +16,12 @@ jobs:
- name: setup-toolchain
run: chmod +rwx ./launch-sandbox-setup.sh && ./launch-sandbox-setup.sh

- name: compile-link-assemble libfoobar
- name: compile-link-assemble libarithmos
run: chmod +rwx ./helper-scripts/project-impl/compile-all.sh && ./helper-scripts/project-impl/compile-all.sh

- name: compile-link-assemble hello_foobar.c
- name: compile-link-assemble hello_vector2d.c
run: |
chmod +rwx ./helper-scripts/project-impl/compile-examples.sh
./helper-scripts/project-impl/compile-examples.sh atmega32 hello_foobar.c
./helper-scripts/project-impl/compile-examples.sh atmega328p hello_foobar.c
./helper-scripts/project-impl/compile-examples.sh atmega32 hello_vector2d.c
./helper-scripts/project-impl/compile-examples.sh atmega328p hello_vector2d.c

43 changes: 23 additions & 20 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
This is free and unencumbered software released into the public domain.
Copyright (c) 2022, Arithmos Project, arithmos-native
All rights reserved.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

For more information, please refer to <https://unlicense.org>
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# cmake-template
# arithmos-native

A template for embedded C libraries development.
The native portion for arithmos, a high performance maths algorithmic library written purely in C.

This template consists of the following modules:
1) foobar-core: for core code, this module gets compiled to a static library.
2) foobar-examples: for library examples (or your final runnable target).

This template uses the avr toolchain, though you could edit it to use other toolchains, through editing the sandbox environment scripts.
## This project has 2 modules:
- [x] arithmos-core: for core API header and source files.
- [x] arithmos-examples: for examples and techdemos.
74 changes: 53 additions & 21 deletions arithmos-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,64 @@ cmake_minimum_required(VERSION 3.18.1)
project(arithmos VERSION 1.0)

message(STATUS "Project: arithmos")
message(STATUS "Toolchain: ${TOOLCHAIN_HOME}")
message(STATUS "Target Hardware: ${TARGET}")
message(STATUS "C compiler: ${C_COMPILER}")
message(STATUS "CXX compiler: ${CXX_COMPILER}")
message(STATUS "Toolchain headers: ${TOOLCHAIN_HEADERS}")
message(STATUS "Compiler Options: ${COMPILER_OPTIONS}")
message(STATUS "Build command: ${BUILD_COMMAND}")

# Cmake variables
set(library "arithmos")
set(CMAKE_C_COMPILER "${TOOLCHAIN_HOME}/bin/avr-gcc")
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_HOME}/bin/avr-g++")
set(COMPILER_OPTIONS "-mmcu=${TARGET} -O3")
set(CMAKE_C_COMPILER "${C_COMPILER}")
set(CMAKE_CXX_COMPILER "${CXX_COMPILER}")
set(COMPILER_OPTIONS "${COMPILER_OPTIONS}")

set(toolchain_headers "${TOOLCHAIN_HOME}/toolchain/include/")
set(libfoobar "${CMAKE_CURRENT_SOURCE_DIR}/src/libfoo/do_foo.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libfoo/init_foo.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libfoo/destroy_foo.c")

set(headers "${toolchain_headers}"
set(headers "${TOOLCHAIN_HEADERS}"
"${CMAKE_CURRENT_SOURCE_DIR}/src/include/")
set(sources ${libfoobar})

# add a library target
add_library(${library} STATIC ${sources})
########################### libvector2d START ###########################
function(build_vector2d)
set(vector2d "vector2d")
set(libvector2d "${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_add.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_angle.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_dot_product.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_product.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_subtract.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_distance.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_length.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_interpolate.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_extrapolate.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_are_parallel.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_are_perpendicular.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_normalize.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_polar.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_scalar_add.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_scalar_divide.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_scalar_multiply.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_scalar_subtract.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libvector2d/vector2d_scalar_moduluo.c")

# add a library target
add_library(${vector2d} STATIC ${libvector2d})

# set both COMPILE_FLAGS and LINK_FLAGS to the specified binary architecture
set_target_properties(${vector2d} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}")

# include headers for the target
target_include_directories(${vector2d} PUBLIC ${headers})

# set both COMPILE_FLAGS and LINK_FLAGS to the specified binary architecture
set_target_properties(${library} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}")
# Start building the target
target_sources(${vector2d} PUBLIC ${libvector2d})
endfunction()
########################### libvector2d END ###########################

# include headers for the target
target_include_directories(${library} PUBLIC ${headers})
function(build_all)
build_vector2d()
endfunction()

# Start building the target
target_sources(${library} PUBLIC ${sources})
########################### build process START ###########################
if(BUILD_COMMAND STREQUAL "vector2d")
build_vector2d()
else()
build_all()
endif()
########################### build process END ###########################
18 changes: 7 additions & 11 deletions arithmos-core/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# foobar-core
# arithmos-core

This is your core code module, it's compiled into a static library.
The Core of arithmos-native, this project consists of a couple of sub-projects:

To compile to a target mcu use the following script:
```bash
source "./helper-scripts/abstract/abstract-compile.sh"
source "./helper-scripts/project-impl/variables.sh"

compile ${TOOLCHAIN_HOME} ${mcu_atmega32A} ${source_dir}
```

Edit the variables at `variables.sh` to satisfy your needs, to get more out of this, add your chip compilation script to `compile-all.sh`.
- [x] libvector2d: A vector utility in the R(2) vector-space that provides powerful vector operations out of the box.
- [ ] libvector3d.
- [ ] libmatrix4x4.
- [ ] libgebra.
- [ ] libtrigo.
37 changes: 0 additions & 37 deletions arithmos-core/src/include/foobar.h

This file was deleted.

75 changes: 75 additions & 0 deletions arithmos-core/src/include/vectorspaces/coordinate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#if !(defined _vector2d_H_ || defined _vector3d_H_)
# error "Use vector2d or vector3d instead of this!"
#endif

#ifndef _COORDINATE_H_
#define _COORDINATE_H_

#include <inttypes.h>

#if defined (_VECTOR2D_USE_UINT8_)
# define coordinate uint8_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((uint8_t) powf(v, p))
# define vector2d_atan2(y, x) ((uint8_t) atan2f(y, x))
# define vector2d_acos(v) ((uint8_t) acosf(v))
#elif defined (_VECTOR2D_USE_INT8_)
# define coordinate int8_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((int8_t) powf(v, p))
# define vector2d_atan2(y, x) ((int8_t) atan2f(y, x))
# define vector2d_acos(v) ((int8_t) acosf(v))
#elif defined (_VECTOR2D_USE_UINT16_)
# define coordinate uint16_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((uint16_t) powf(v, p))
# define vector2d_atan2(y, x) ((uint16_t) atan2f(y, x))
# define vector2d_acos(v) ((uint16_t) acosf(v))
#elif defined (_VECTOR2D_USE_INT16_)
# define coordinate int16_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((int16_t) powf(v, p))
# define vector2d_atan2(y, x) ((int16_t) atan2f(y, x))
# define vector2d_acos(v) ((int16_t) acosf(v))
#elif defined (_VECTOR2D_USE_UINT32_)
# define coordinate uint32_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((uint32_t) powf(v, p))
# define vector2d_atan2(y, x) ((uint32_t) atan2f(y, x))
# define vector2d_acos(v) ((uint32_t) acosf(v))
#elif defined (_VECTOR2D_USE_INT32_)
# define coordinate int32_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((int32_t) powf(v, p))
# define vector2d_atan2(y, x) ((int32_t) atan2f(y, x))
# define vector2d_acos(v) ((int32_t) acosf(v))
#elif defined (_VECTOR2D_USE_UINT64_)
# define coordinate uint64_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((uint64_t) powl(v, p))
# define vector2d_atan2(y, x) ((uint64_t) atan2l(y, x))
# define vector2d_acos(v) ((uint64_t) acosl(v))
#elif defined (_VECTOR2D_USE_INT64_)
# define coordinate int64_t
# define mod_coordinate coordinate
# define vector2d_pow(v, p) ((int64_t) powl(v, p))
# define vector2d_atan2(y, x) ((int64_t) atan2l(y, x))
# define vector2d_acos(v) ((int64_t) acosl(v))
#elif defined (_VECTOR2D_USE_DOUBLE_)
# define coordinate double
# define mod_coordinate int64_t
# define vector2d_pow(v, p) ((double) powl(v, p))
# define vector2d_atan2(y, x) ((double) atan2l(y, x))
# define vector2d_acos(v) ((double) acosl(v))
#else
# define coordinate float
# define mod_coordinate int32_t
# define vector2d_pow(v, p) ((float) powf(v, p))
# define vector2d_atan2(y, x) ((float) atan2f(y, x))
# define vector2d_acos(v) ((float) acosf(v))
#endif

#define vector2d_sqrt(v) vector2d_pow(v, 0.5)
#define vector2d_abs(v) ((coordinate) vector2d_sqrt(vector2d_pow(v, 2)))

#endif // _COORDINATE_H_
Loading