2021-02-28 02:18:39 +01:00
|
|
|
/* See the end of this file for copyright, license, and warranty information. */
|
2020-06-07 16:49:03 +02:00
|
|
|
|
2020-06-17 20:40:22 +02:00
|
|
|
#include <arch/hardware.h>
|
2020-12-01 23:36:31 +01:00
|
|
|
|
|
|
|
#include <ardix/io.h>
|
2021-03-01 16:09:30 +01:00
|
|
|
#include <ardix/kent.h>
|
2021-08-04 03:31:21 +02:00
|
|
|
#include <ardix/kevent.h>
|
2020-06-17 20:40:22 +02:00
|
|
|
#include <ardix/sched.h>
|
2020-12-01 23:36:31 +01:00
|
|
|
|
2021-03-01 16:09:30 +01:00
|
|
|
#include <stdbool.h>
|
2020-06-12 00:03:16 +02:00
|
|
|
#include <stddef.h>
|
2021-03-01 16:09:30 +01:00
|
|
|
#include <stdint.h>
|
2021-08-01 18:53:22 +02:00
|
|
|
#include <stdio.h>
|
2021-02-03 04:01:27 +01:00
|
|
|
#include <unistd.h>
|
2020-06-12 00:03:16 +02:00
|
|
|
|
2020-06-12 04:24:46 +02:00
|
|
|
#define REG_PIOB_PER (*(uint32_t *)0x400E1000U)
|
|
|
|
#define REG_PIOB_PDR (*(uint32_t *)0x400E1004U)
|
|
|
|
#define REG_PIOB_OER (*(uint32_t *)0x400E1010U)
|
|
|
|
#define REG_PIOB_ODR (*(uint32_t *)0x400E1014U)
|
|
|
|
#define REG_PIOB_SODR (*(uint32_t *)0x400E1030U)
|
|
|
|
#define REG_PIOB_CODR (*(uint32_t *)0x400E1034U)
|
|
|
|
|
2020-06-07 16:49:03 +02:00
|
|
|
/**
|
|
|
|
* Core init routine.
|
2020-06-12 00:03:16 +02:00
|
|
|
*
|
|
|
|
* This is invoked from the startup code (usually) located in
|
|
|
|
* arch/<architecture>/startup.c.
|
2020-06-07 16:49:03 +02:00
|
|
|
*/
|
2021-08-01 18:53:22 +02:00
|
|
|
int main(void)
|
2020-06-07 16:49:03 +02:00
|
|
|
{
|
2021-08-04 03:31:21 +02:00
|
|
|
volatile unsigned int print_count = 0;
|
2020-06-17 20:40:22 +02:00
|
|
|
|
2021-08-01 18:53:22 +02:00
|
|
|
int err = kent_root_init();
|
|
|
|
if (err != 0)
|
|
|
|
return err;
|
2021-03-01 16:09:30 +01:00
|
|
|
|
2021-08-04 03:31:21 +02:00
|
|
|
kevents_init();
|
|
|
|
|
2021-08-01 18:53:22 +02:00
|
|
|
err = sched_init();
|
|
|
|
if (err != 0)
|
|
|
|
return err;
|
2021-02-03 04:01:27 +01:00
|
|
|
|
2021-08-01 18:53:22 +02:00
|
|
|
err = devices_init();
|
|
|
|
if (err != 0)
|
|
|
|
return err;
|
2021-02-03 04:01:27 +01:00
|
|
|
|
2021-08-01 18:53:22 +02:00
|
|
|
err = io_init();
|
|
|
|
if (err != 0)
|
|
|
|
return err;
|
2020-06-17 20:40:22 +02:00
|
|
|
|
2021-08-04 03:31:21 +02:00
|
|
|
/* we should have a serial console now */
|
|
|
|
|
|
|
|
REG_PIOB_OER = 1 << 27;
|
|
|
|
REG_PIOB_PER = 1 << 27;
|
|
|
|
REG_PIOB_CODR = 1 << 27;
|
|
|
|
|
2020-06-14 03:41:07 +02:00
|
|
|
while (true) {
|
2021-08-04 03:31:21 +02:00
|
|
|
printf("hello, world (%u)\n", print_count);
|
2021-03-01 16:09:30 +01:00
|
|
|
|
2021-08-05 18:52:51 +02:00
|
|
|
msleep(1000);
|
|
|
|
|
2020-12-01 23:36:31 +01:00
|
|
|
print_count++;
|
|
|
|
if (print_count % 2)
|
|
|
|
REG_PIOB_CODR = 1 << 27;
|
|
|
|
else
|
|
|
|
REG_PIOB_SODR = 1 << 27;
|
2020-06-12 00:03:16 +02:00
|
|
|
}
|
2020-06-07 16:49:03 +02:00
|
|
|
}
|
2020-10-11 19:35:30 +02:00
|
|
|
|
|
|
|
/*
|
2021-02-28 02:18:39 +01:00
|
|
|
* This file is part of Ardix.
|
|
|
|
* Copyright (c) 2020, 2021 Felix Kopp <owo@fef.moe>.
|
2020-10-11 19:35:30 +02:00
|
|
|
*
|
2021-05-10 16:19:38 +02:00
|
|
|
* Ardix is non-violent software: you may only use, redistribute,
|
|
|
|
* and/or modify it under the terms of the CNPLv6+ as found in
|
|
|
|
* the LICENSE file in the source code root directory or at
|
|
|
|
* <https://git.pixie.town/thufie/CNPL>.
|
2020-10-11 19:35:30 +02:00
|
|
|
*
|
2021-05-10 16:19:38 +02:00
|
|
|
* Ardix comes with ABSOLUTELY NO WARRANTY, to the extent
|
|
|
|
* permitted by applicable law. See the CNPLv6+ for details.
|
2020-10-11 19:35:30 +02:00
|
|
|
*/
|