diff options
-rw-r--r-- | asm.h | 24 | ||||
-rw-r--r-- | crt0.s | 18 | ||||
-rw-r--r-- | layout.ld | 18 | ||||
-rw-r--r-- | lib/arrlen.h | 6 | ||||
-rw-r--r-- | lib/cm4.h | 24 | ||||
-rw-r--r-- | lib/le.c | 24 | ||||
-rw-r--r-- | lib/le.h | 24 | ||||
-rw-r--r-- | setup.c | 18 | ||||
-rw-r--r-- | uart/uart.c | 18 | ||||
-rw-r--r-- | uart/uart.h | 24 | ||||
-rw-r--r-- | usb/bdt.h | 24 | ||||
-rw-r--r-- | usb/descriptors.h | 24 | ||||
-rw-r--r-- | usb/endpt0.c | 18 | ||||
-rw-r--r-- | usb/endpt0.h | 24 | ||||
-rw-r--r-- | usb/endpt1.c | 18 | ||||
-rw-r--r-- | usb/endpt1.h | 24 | ||||
-rw-r--r-- | usb/hid.h | 24 | ||||
-rw-r--r-- | usb/usb.c | 18 | ||||
-rw-r--r-- | usb/usb.h | 24 | ||||
-rw-r--r-- | vectors.s | 18 |
20 files changed, 369 insertions, 45 deletions
@@ -1,5 +1,23 @@ -#ifndef ASM_H -#define ASM_H +/* + * asm.h -- ARM thumb assembly instructions + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_ASM_H +#define FMK_ASM_H #include <stdint.h> @@ -21,4 +39,4 @@ static inline void set_BASEPRI(uint32_t p) __asm__ volatile ("msr basepri, %0" ::"r"(p)); } -#endif /* ASM_H */ +#endif /* FMK_ASM_H */ @@ -1,3 +1,21 @@ +/* + * crt0.s -- MK20DX256 initialisation + * + * Copyright (C) 2016 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ .syntax unified .extern setup @@ -1,3 +1,21 @@ +/* + * layout.ld -- MK20DX256 memory layout + * + * Copyright (C) 2016 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ MEMORY { flash : ORIGIN = 0x00000000, LENGTH = 256K ram : ORIGIN = 0x1FFF8000, LENGTH = 64K diff --git a/lib/arrlen.h b/lib/arrlen.h index fdc5532..a687902 100644 --- a/lib/arrlen.h +++ b/lib/arrlen.h @@ -1,6 +1,6 @@ -#ifndef LIB_ARRLEN_H -#define LIB_ARRLEN_H +#ifndef FMK_LIB_ARRLEN_H +#define FMK_LIB_ARRLEN_H #define ARRLEN(a) (sizeof (a) / sizeof (a)[0]) -#endif /* LIB_ARRLEN_H */ +#endif /* FMK_LIB_ARRLEN_H */ @@ -1,5 +1,23 @@ -#ifndef LIB_CM4_H -#define LIB_CM4_H +/* + * lib/cm4.h -- Cortex M4 register definitions + * + * Copyright (C) 2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_LIB_CM4_H +#define FMK_LIB_CM4_H #define CLRPEND(n) REG_32(0xE000E280 + 4 * (n)) #define ISR_CLRPEND(i) CLRPEND((i) / 32) = BV((i) % 32); @@ -9,4 +27,4 @@ #define INTPRI(n) REG_8(0xE000E400 + (n)) -#endif /* LIB_CM4_H */ +#endif /* FMK_LIB_CM4_H */ @@ -1,20 +1,20 @@ -/* lib/le.c -- Basic little endian byte order functions +/* + * lib/le.c -- Basic little endian byte order functions * * Copyright (C) 2016 Tomasz Kramkowski <tk@the-tk.com> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdint.h> @@ -1,5 +1,23 @@ -#ifndef LIB_LE_H -#define LIB_LE_H +/* + * lib/le.h -- Basic little endian byte order functions + * + * Copyright (C) 2016 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_LIB_LE_H +#define FMK_LIB_LE_H #include <stdint.h> @@ -9,4 +27,4 @@ uint32_t le32toh(const void *data); void htole16(void *data, uint16_t value); void htole32(void *data, uint32_t value); -#endif /* LIB_LE_H */ +#endif /* FMK_LIB_LE_H */ @@ -1,3 +1,21 @@ +/* + * setup.c -- fmk setup + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #include <reg.h> #include <stddef.h> #include <string.h> diff --git a/uart/uart.c b/uart/uart.c index a5fd352..ff467eb 100644 --- a/uart/uart.c +++ b/uart/uart.c @@ -1,3 +1,21 @@ +/* + * uart/uart.c -- hardware UART interface + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #include <cm4.h> #include <reg/gpio.h> #include <reg/port.h> diff --git a/uart/uart.h b/uart/uart.h index 2733bb7..bb5c6f7 100644 --- a/uart/uart.h +++ b/uart/uart.h @@ -1,5 +1,23 @@ -#ifndef UART_UART_H -#define UART_UART_H +/* + * uart/uart.h -- hardware UART interface + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_UART_UART_H +#define FMK_UART_UART_H void uart_setup(void); void uart_putchar(int c); @@ -7,4 +25,4 @@ void uart_printf(const char *fmt, ...); void uart_puts(const char *s); void uart0_isr(void); -#endif /* UART_UART_H */ +#endif /* FMK_UART_UART_H */ @@ -1,5 +1,23 @@ -#ifndef USB_BDT_H -#define USB_BDT_H +/* + * usb/bdt.h -- USB BDT + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_USB_BDT_H +#define FMK_USB_BDT_H #include <reg/usbotg.h> @@ -10,4 +28,4 @@ extern volatile struct usb0_bd usb_bdt[2][2][2]; #define BDT_EVEN 0 #define BDT_ODD 1 -#endif /* USB_BDT_H */ +#endif /* FMK_USB_BDT_H */ diff --git a/usb/descriptors.h b/usb/descriptors.h index 6ebfded..122ba5c 100644 --- a/usb/descriptors.h +++ b/usb/descriptors.h @@ -1,5 +1,23 @@ -#ifndef USB_DESCRIPTORS_H -#define USB_DESCRIPTORS_H +/* + * usb/descriptors.h -- USB Descriptors + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_USB_DESCRIPTORS_H +#define FMK_USB_DESCRIPTORS_H #include "hid.h" @@ -130,4 +148,4 @@ unsigned char ds_str1[] = { }; _Static_assert(sizeof ds_str1 == DS_STR1_SIZE, "sizeof ds_str1 != DS_STR1_SIZE"); -#endif /* USB_DESCRIPTORS_H */ +#endif /* FMK_USB_DESCRIPTORS_H */ diff --git a/usb/endpt0.c b/usb/endpt0.c index c4c3360..57c994e 100644 --- a/usb/endpt0.c +++ b/usb/endpt0.c @@ -1,3 +1,21 @@ +/* + * usb/endpt0.c -- USB endpoint 0 (control) handling + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #include <arrlen.h> #include <le.h> #include <reg/usbotg.h> diff --git a/usb/endpt0.h b/usb/endpt0.h index 4ba89ed..706b9f5 100644 --- a/usb/endpt0.h +++ b/usb/endpt0.h @@ -1,5 +1,23 @@ -#ifndef USB_ENDPT0_H -#define USB_ENDPT0_H +/* + * usb/endpt0.h -- USB endpoint 0 (control) handling + * + * Copyright (C) 2016 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_USB_ENDPT0_H +#define FMK_USB_ENDPT0_H #include <stdint.h> @@ -7,4 +25,4 @@ void usb_endpt0_disable(void); void usb_endpt0_enable(void); void usb_endpt0_token(uint8_t state); -#endif /* USB_ENDPT0_H */ +#endif /* FMK_USB_ENDPT0_H */ diff --git a/usb/endpt1.c b/usb/endpt1.c index 65684b5..3139104 100644 --- a/usb/endpt1.c +++ b/usb/endpt1.c @@ -1,3 +1,21 @@ +/* + * usb/endpt1.c -- USB endpoit 1 (HID) handling + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #include <reg/usbotg.h> #include <stddef.h> #include <stdint.h> diff --git a/usb/endpt1.h b/usb/endpt1.h index 9be7522..fa26bd9 100644 --- a/usb/endpt1.h +++ b/usb/endpt1.h @@ -1,8 +1,26 @@ -#ifndef USB_ENDPT1_H -#define USB_ENDPT1_H +/* + * usb/endpt1.h -- USB endpoit 1 (HID) handling + * + * Copyright (C) 2016 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_USB_ENDPT1_H +#define FMK_USB_ENDPT1_H void usb_endpt1_enable(void); void usb_endpt1_disable(void); void usb_endpt1_token(uint8_t state); -#endif /* USB_ENDPT1_H */ +#endif /* FMK_USB_ENDPT1_H */ @@ -1,5 +1,23 @@ -#ifndef USB_HID_H -#define USB_HID_H +/* + * usb/hid.h -- USB HID definitions + * + * Copyright (C) 2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_USB_HID_H +#define FMK_USB_HID_H #define SHORT_ITEM(tag, type, size) (((tag) & 0xf) << 4 | \ ((type) & 0x3) << 2 | \ @@ -84,4 +102,4 @@ #define HR_BIT_FIELD (0) #define HR_BUFFERED_BYTES (1 << 8) -#endif /* USB_HID_H */ +#endif /* FMK_USB_HID_H */ @@ -1,3 +1,21 @@ +/* + * usb/usb.c -- USB 2.0 implementation + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #include <cm4.h> #include <reg/gpio.h> #include <reg/sim.h> @@ -1,7 +1,25 @@ -#ifndef USB_H -#define USB_H +/* + * usb/usb.h -- USB 2.0 implementation + * + * Copyright (C) 2016 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef FMK_USB_H +#define FMK_USB_H void usb_setup(void); void usb_isr(void); -#endif /* USB_H */ +#endif /* FMK_USB_H */ @@ -1,3 +1,21 @@ +/* + * vectors.s -- fmk interrupt vector table + * + * Copyright (C) 2016-2017 Tomasz Kramkowski <tk@the-tk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ .syntax unified .section ".vectors" |