<commit_before>#define EXTERN

#ifdef STM32
#include "st_main.h"
#include "st_uart.h"
#include "st_adc.h"
#include "st_gpio.h"
#endif

#include "Hardware.h"
#include "Tasks.h"
#include "System.h"
#include "Schedule.h"
#include "Events.h"
#include "Stream.h"

#include "Tasks.h"
#include "Hardware.h"
#include "GPIO.h"

#include "Schedule.h"
#include "Strategy.h"
#include "Codes.h"
#include "Encoder.h"
#include "Timers.h"

#include "Epoch.h"
#include "Stream.h"

#include "Display.h"
#include "Vehicle.h"
#include "Bus.h"

#ifndef NDEBUG
#define MYNAME(x)	F(#x)
#else
#define MYNAME(x)	0
#endif

#include "efi_pins.h"

static void initPins(ZoneId zone) {
	for (uint8_t i = 0; i < MaxPins; i++) {
		GPIO::PinDef *pd = pins + i;
		pd->ext = getPinExt(zone, (PinId)i);
	}

	gpio.init(pins, MaxPins);
}

#ifdef ARDUINO
void Hardware::flush() {
	Buffer &send = hardware.send();
	Buffer &recv = hardware.recv();

	while (Serial.available())
	recv.myputch(Serial.read());

	char buf[32];
	size_t n = 0;

	if ((n = send.read(buf, sizeof(buf))) > 0)
	Serial.write(buf, n);
}

void GPIO::init(PinDef *pd) const {
}
#endif

#ifdef STM32

void toggleled(uint8_t id) {
#ifdef __STM32F4_DISCOVERY_H
	static Led_TypeDef leds[] = {
		LED3,
		LED4,
		LED5,
		LED6,
	};

	BSP_LED_Toggle(leds[id & 0x3]);
#endif
}

#define IRQNONE	((IRQn_Type)0)

static IRQn_Type getIRQ(PinId pt) {
	switch(pt) {
#ifdef STM32L1
		//return EXTI9_5_IRQn;
		//return EXTI4_IRQn;
		//case IN_BUTTON:
		//return EXTI15_10_IRQn;
#endif
		default:
		return IRQNONE;
	}
}

void GPIO::init(PinDef *pd) const {
	STGPIO::getPortName(pd->ext, pd->info);

	GPIO_InitTypeDef gpio = {0};
	gpio.Pull = GPIO_NOPULL;
	gpio.Speed = GPIO_SPEED_FREQ_MEDIUM;

	if (pd->mode & PinModeOutput) {
		gpio.Mode = GPIO_MODE_OUTPUT_PP;
		STGPIO::init(pd->ext, &gpio);
	} else if (pd->mode & PinModeInput) {
		IRQn_Type irq = getIRQ(pd->getId());

		if (irq == IRQNONE) {
			gpio.Mode = GPIO_MODE_INPUT;
			STGPIO::init(pd->ext, &gpio);
		} else {
		}
	}
}

void Hardware::flush() {
	for (uint8_t i = 0; i < nchannels(); i++) {
		if (i < ARRSIZE(uarts)) {
			if (uarts[i].isValid()) {
				uarts[i].send(send(i));
				uarts[i].recv(recv(i));
			} else
				ch[i].send.clear();
		}
	}
}

int main(void) {
	stmicro.init();

	initPins(ZoneFront);

	//stled.setPin(OUT_LED2);

	if (!uarts[0].init(0, 3, PinShellRX, PinShellTX))
		myerror();

	//stled.toggle();
	//stadc.init();
	//stadc.start();
	//stled.setLoHi(100, 500);

	initSystem(false);
<commit_msg>stml1<commit_after>#define EXTERN

#ifdef STM32
#include "st_main.h"
#include "st_uart.h"
#include "st_adc.h"
#include "st_gpio.h"
#endif

#include "Hardware.h"
#include "Tasks.h"
#include "System.h"
#include "Schedule.h"
#include "Events.h"
#include "Stream.h"

#include "Tasks.h"
#include "Hardware.h"
#include "GPIO.h"

#include "Schedule.h"
#include "Strategy.h"
#include "Codes.h"
#include "Encoder.h"
#include "Timers.h"

#include "Epoch.h"
#include "Stream.h"

#include "Display.h"
#include "Vehicle.h"
#include "Bus.h"

#ifndef NDEBUG
#define MYNAME(x)	F(#x)
#else
#define MYNAME(x)	0
#endif

#include "efi_pins.h"

static void initPins(ZoneId zone) {
	for (uint8_t i = 0; i < MaxPins; i++) {
		GPIO::PinDef *pd = pins + i;
		pd->ext = getPinExt(zone, (PinId)i);
	}

	gpio.init(pins, MaxPins);
}

#ifdef ARDUINO
void Hardware::flush() {
	Buffer &send = hardware.send();
	Buffer &recv = hardware.recv();

	while (Serial.available())
	recv.myputch(Serial.read());

	char buf[32];
	size_t n = 0;

	if ((n = send.read(buf, sizeof(buf))) > 0)
	Serial.write(buf, n);
}

void GPIO::init(PinDef *pd) const {
}
#endif

#ifdef STM32

void toggleled(uint8_t id) {
#ifdef __STM32F4_DISCOVERY_H
	static Led_TypeDef leds[] = {
		LED3,
		LED4,
		LED5,
		LED6,
	};

	BSP_LED_Toggle(leds[id & 0x3]);
#endif
}

#define IRQNONE	((IRQn_Type)0)

static IRQn_Type getIRQ(PinId pt) {
	switch(pt) {
#ifdef STM32L1
		//return EXTI9_5_IRQn;
		//return EXTI4_IRQn;
		//case IN_BUTTON:
		//return EXTI15_10_IRQn;
#endif
		default:
		return IRQNONE;
	}
}

void GPIO::init(PinDef *pd) const {
	STGPIO::getPortName(pd->ext, pd->info);

	GPIO_InitTypeDef gpio = {0};
	gpio.Pull = GPIO_NOPULL;
	gpio.Speed = GPIO_SPEED_FREQ_MEDIUM;

	if (pd->mode & PinModeOutput) {
		gpio.Mode = GPIO_MODE_OUTPUT_PP;
		STGPIO::init(pd->ext, &gpio);
	} else if (pd->mode & PinModeInput) {
		IRQn_Type irq = getIRQ(pd->getId());

		if (irq == IRQNONE) {
			gpio.Mode = GPIO_MODE_INPUT;
			STGPIO::init(pd->ext, &gpio);
		} else {
		}
	}
}

void Hardware::flush() {
	for (uint8_t i = 0; i < nchannels(); i++) {
		if (i < ARRSIZE(uarts)) {
			if (uarts[i].isValid()) {
				uarts[i].send(send(i));
				uarts[i].recv(recv(i));
			} else
				ch[i].send.clear();
		}
	}
}

int main(void) {
	stmicro.init();

	initPins(ZoneFront);

	//stled.setPin(OUT_LED2);

	if (!uarts[0].init(0, 3, PinShellRX, PinShellTX))
		myerror();

	//stled.toggle();
	//stadc.init();
	//stadc.start();
	//stled.setLoHi(100, 500);

	initSystem(true);

{'fraction_non_alphanumeric': 0.1841628047551884, 'fraction_numerical': 0.018335684062059238, 'mean_word_length': 4.10174717368962, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7096599', 'n_tokens_mistral': 2327, 'n_tokens_neox': 2182, 'n_words': 444}