aboutsummaryrefslogtreecommitdiff
path: root/libhal/Makefile
blob: 9274dd9ad3f53f027fa1a310d21a9a5cfb2b1cce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
ifndef CRYPTECH_ROOT
  CRYPTECH_ROOT := $(abspath ../../..)
endif

LIBHAL_SRC   ?= ${CRYPTECH_ROOT}/sw/libhal
LIBTFM_BLD   ?= $(abspath ../libtfm)

CFLAGS += -I${LIBHAL_SRC}

vpath %.c ${LIBHAL_SRC}
vpath %.h ${LIBHAL_SRC}:${LIBTFM_BLD}

include ${LIBHAL_SRC}/Makefile
ng.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
#include "cmsis_os.h"

#include "stm-init.h"
#include "stm-uart.h"

osSemaphoreId two_slots;
osSemaphoreDef(two_slots);

void test_thread(void const *name) {
    while (1) {
        osSemaphoreWait(two_slots, osWaitForever);
        //printf("%s\n\r", (const char*)name);
        uart_send_string((const char*)name);
        uart_send_string("\r\n");
        osDelay(1000);
        osSemaphoreRelease(two_slots);
    }
}

void t2(void const *argument) {test_thread("Th 2");}
osThreadDef(t2, osPriorityNormal, DEFAULT_STACK_SIZE);

void t3(void const *argument) {test_thread("Th 3");}
osThreadDef(t3, osPriorityNormal, DEFAULT_STACK_SIZE);

int main (void) {
    stm_init();
    two_slots = osSemaphoreCreate(osSemaphore(two_slots), 2);

    osThreadCreate(osThread(t2), NULL);
    osThreadCreate(osThread(t3), NULL);

    test_thread((void *)"Th 1");
}