diff --git a/Makefile b/Makefile index 0063f9b..f6f3dce 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,6 @@ CFLAGS += -D$(DEVICE_DEFINE) # Includes CFLAGS += -I./lib/stm32/$(DEVICE_LINE)/Include CFLAGS += -I./lib/CMSIS/Core/Include - CFLAGS += -I./lib/fonts/ # Startup Definitions @@ -100,7 +99,7 @@ build: $(OUTPUT_BIN) %.o: %.c @echo "CC $@" - @$(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) -c $< -o $@ %.o: %.S @echo "AS $@" diff --git a/display.c b/display.c new file mode 100644 index 0000000..a786b73 --- /dev/null +++ b/display.c @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2019 Max Regan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 OR COPYRIGHT HOLDERS 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. + */ + + +#include "display.h" +#include "macros.h" + +static void display_buffer_init(struct display_buffer *buffer) +{ + for (size_t i = 0; i < ARRAY_SIZE(buffer->lines); i++) { + struct display_line *line = &buffer->lines[i]; + line->mode = 1; // Update display + line->line = i; + for (size_t j = 0; j < ARRAY_SIZE(line->data); j++) { + line->data[j] = 0xFF; + } + } + + buffer->dummy = 0; +} + + +static void display_spi_init(struct display *display) +{ + // TODO: Not all of this should be in here, probably + + RCC->APB2ENR = RCC_APB2ENR_SPI1EN; + + GPIOB->OSPEEDR = ~0; + + /* Assign SPI_MOSI to PA12 (AFRH5), since PA7 is taken by LPTIM_OUT */ + GPIOA->AFR[1] &= ~GPIO_AFRH_AFRH4; + + SET_TO(GPIOA->MODER, GPIO_MODER_MODE12, 2u << GPIO_MODER_MODE12_Pos); + + GPIOA->OTYPER &= ~GPIO_OTYPER_OT_12; + GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD12; + + // SPI1 NSS (PA4) + GPIOA->AFR[0] &= ~GPIO_AFRL_AFRL4; + + SET_TO(GPIOA->MODER, GPIO_MODER_MODE4, 2u << GPIO_MODER_MODE4_Pos); + + GPIOA->OTYPER &= ~GPIO_OTYPER_OT_4; + GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD4; + // enable pullup, since the pin doesn't seem to stay up + GPIOA->PUPDR |= 2u << GPIO_PUPDR_PUPD4_Pos; + + // SPI1 SCK (PA5) + GPIOA->AFR[0] &= ~GPIO_AFRL_AFRL5; + + SET_TO(GPIOA->MODER, GPIO_MODER_MODE5, 2u << GPIO_MODER_MODE5_Pos); + + GPIOA->OTYPER &= ~GPIO_OTYPER_OT_5; + GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD5; + + // SPI1 MISO (PA6) + GPIOA->AFR[0] &= ~GPIO_AFRL_AFRL6; + + SET_TO(GPIOA->MODER, GPIO_MODER_MODE6, 2u << GPIO_MODER_MODE6_Pos); + + GPIOA->OTYPER &= ~GPIO_OTYPER_OT_6; + GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD6; + + // Enable Master mode and half the baud rate, so it's set to ~1MHz + display->spi->CR1 |= SPI_CR1_MSTR | SPI_CR1_LSBFIRST; + display->spi->CR1 |= 1u << SPI_CR1_BR_Pos; + display->spi->CR2 |= SPI_CR2_SSOE; +} + +void display_init(struct display *display, SPI_TypeDef* spi) +{ + display->spi = spi; + display_buffer_init(&display->buffer); + display_spi_init(display); +} + +void display_set_bit(struct display *display, unsigned int x, unsigned int y, uint8_t val) +{ + if (x >= DISPLAY_WIDTH || y >= DISPLAY_HEIGHT) { + return; + } + + struct display_line *line = &display->buffer.lines[y]; + uint8_t *byte = &line->data[x >> 3]; + if (val) { + CLR_POS(*byte, x & 7); + } else { + SET_POS(*byte, x & 7); + } +} + +void display_set_byte(struct display *display, unsigned int x, unsigned int y, uint8_t val) +{ + if (x >= DISPLAY_WIDTH || y >= DISPLAY_HEIGHT) { + return; + } + + if (x & 7) { + return; + } + + struct display_line *line = &display->buffer.lines[y]; + line->data[x >> 3] = val; +} + +void display_char_at(struct display *display, int *x_off, int y_off, char c, const struct font *font) +{ + const struct glyph *g = glyph_for_char(font, c); + if (g == NULL) { + return; + } + + int byte_cols = 1; // TODO: Don't hardcode this + for (size_t x = 0; x < g->cols; x++) { + for (size_t y = 0; y < g->rows; y++) { + int byte_x = x >> 3; + int byte_y = y; + uint8_t bit = (g->bitmap[byte_y * byte_cols + byte_x] >> (7 - (x & 7))) & 1; + /* 16 is font max height */ + display_set_bit(display, g->left + *x_off + x, y_off + y + 16 - g->top, bit); + } + } + *x_off += g->advance; +} + +void display_string_at(struct display *display, int x_off, int y_off, const char *string, const struct font *font) +{ + int i = 0; + while (string[i]) { + display_char_at(display, &x_off, y_off, string[i], font); + i++; + } +} + +void display_refresh(struct display *display) +{ + spi_send_blocking(display->spi, (uint8_t *) &display->buffer, sizeof(display->buffer)); +} + +void display_clear(struct display *display) +{ + display_buffer_init(&display->buffer); +} diff --git a/display.h b/display.h new file mode 100644 index 0000000..2958c46 --- /dev/null +++ b/display.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2019 Max Regan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 OR COPYRIGHT HOLDERS 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. + */ + +#ifndef _DISPLAY_H_ +#define _DISPLAY_H_ + +#include +#include +#include + +#include "spi.h" +#include "font.h" + +#define DISPLAY_WIDTH 144 +#define DISPLAY_HEIGHT 168 + +struct display_line +{ + uint8_t mode; + uint8_t line; + uint8_t data[DISPLAY_WIDTH / 8]; +}; + +struct display_buffer +{ + struct display_line lines[DISPLAY_HEIGHT]; + uint16_t dummy; +}; + +static_assert(sizeof(struct display_buffer) == (DISPLAY_WIDTH / 8 + 2) * DISPLAY_HEIGHT + 2, + "The display buffer structure must be packed"); + +struct display +{ + SPI_TypeDef *spi; + struct display_buffer buffer; +}; + + +void display_init(struct display *display, SPI_TypeDef *spi); + +void display_set_bit(struct display *display, unsigned int x, unsigned int y, uint8_t val); + +void display_set_byte(struct display *display, unsigned int x, unsigned int y, uint8_t val); + +void display_char_at(struct display *display, int *x_off, int y_off, char c, const struct font *font); + +void display_string_at(struct display *display, int x_off, int y_off, const char *string, const struct font *font); + +void display_refresh(struct display *display); + +// TODO +void display_clear(struct display *display); + +#endif diff --git a/font.c b/font.c new file mode 100644 index 0000000..7edd712 --- /dev/null +++ b/font.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Max Regan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 OR COPYRIGHT HOLDERS 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. + */ + +#include "font.h" + +const struct glyph *glyph_for_char(const struct font *font, char c) +{ + // TODO: This is almost the least efficient way imaginable to implement this + for (int i = 0; i < font->max; i++) { + const struct glyph *g = font->glyphs[i]; + if (g == NULL) { + continue; + } + + if (g->glyph == c) { + return g; + } + } + + return NULL; +} diff --git a/font.h b/font.h new file mode 100644 index 0000000..bb7aae5 --- /dev/null +++ b/font.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 Max Regan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 OR COPYRIGHT HOLDERS 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. + */ + +#ifndef _FONT_H_ +#define _FONT_H_ + +#include "fontem.h" + +const struct glyph *glyph_for_char(const struct font *font, char c); + +#endif diff --git a/lib/fonts/font-notomono-10.c b/lib/fonts/font-notomono-10.c index 3048130..fe9c439 100644 --- a/lib/fonts/font-notomono-10.c +++ b/lib/fonts/font-notomono-10.c @@ -1,4 +1,5 @@ -/* AUTOMATICALLY GENERATED FILE! EDITING NOT RECOMMENDED! +/* This generated file was hand-edited to remove the unnecesarry + * second byte for each row. * * This file is distributed under the terms of the MIT License. * See the LICENSE file at the top of this tree, or if it is missing a copy can @@ -26,16 +27,16 @@ static const struct glyph glyph_notomono_10_0020 = { /** Bitmap definition for character '!'. */ static const uint8_t bitmap_notomono_10_0021[] = { - 0xc0, 0x00, - 0xc0, 0x00, - 0xc0, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x00, 0x00, - 0xc0, 0x00, - 0xc0, 0x00, + 0xc0, + 0xc0, + 0xc0, + 0x80, + 0x80, + 0x80, + 0x80, + 0x00, + 0xc0, + 0xc0, }; /** Glyph definition for character '!'. */ @@ -52,16 +53,16 @@ static const struct glyph glyph_notomono_10_0021 = { /** Bitmap definition for character '#'. */ static const uint8_t bitmap_notomono_10_0023[] = { - 0x12, 0x00, - 0x12, 0x00, - 0x36, 0x00, - 0x7f, 0x00, - 0x24, 0x00, - 0x24, 0x00, - 0xfe, 0x00, - 0x6c, 0x00, - 0x48, 0x00, - 0x48, 0x00, + 0x12, + 0x12, + 0x36, + 0x7f, + 0x24, + 0x24, + 0xfe, + 0x6c, + 0x48, + 0x48, }; /** Glyph definition for character '#'. */ @@ -78,20 +79,20 @@ static const struct glyph glyph_notomono_10_0023 = { /** Bitmap definition for character '$'. */ static const uint8_t bitmap_notomono_10_0024[] = { - 0x20, 0x00, - 0x20, 0x00, - 0x78, 0x00, - 0xa0, 0x00, - 0xa0, 0x00, - 0xa0, 0x00, - 0x60, 0x00, - 0x30, 0x00, - 0x28, 0x00, - 0x28, 0x00, - 0x28, 0x00, - 0xf0, 0x00, - 0x20, 0x00, - 0x20, 0x00, + 0x20, + 0x20, + 0x78, + 0xa0, + 0xa0, + 0xa0, + 0x60, + 0x30, + 0x28, + 0x28, + 0x28, + 0xf0, + 0x20, + 0x20, }; /** Glyph definition for character '$'. */ @@ -108,16 +109,16 @@ static const struct glyph glyph_notomono_10_0024 = { /** Bitmap definition for character '%'. */ static const uint8_t bitmap_notomono_10_0025[] = { - 0x62, 0x00, - 0x94, 0x00, - 0x94, 0x00, - 0x98, 0x00, - 0x68, 0x00, - 0x16, 0x00, - 0x19, 0x00, - 0x29, 0x00, - 0x29, 0x00, - 0x46, 0x00, + 0x62, + 0x94, + 0x94, + 0x98, + 0x68, + 0x16, + 0x19, + 0x29, + 0x29, + 0x46, }; /** Glyph definition for character '%'. */ @@ -134,16 +135,16 @@ static const struct glyph glyph_notomono_10_0025 = { /** Bitmap definition for character '&'. */ static const uint8_t bitmap_notomono_10_0026[] = { - 0x30, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x58, 0x00, - 0x30, 0x00, - 0x54, 0x00, - 0x94, 0x00, - 0x8c, 0x00, - 0xcc, 0x00, - 0x76, 0x00, + 0x30, + 0x48, + 0x48, + 0x58, + 0x30, + 0x54, + 0x94, + 0x8c, + 0xcc, + 0x76, }; /** Glyph definition for character '&'. */ @@ -160,9 +161,9 @@ static const struct glyph glyph_notomono_10_0026 = { /** Bitmap definition for character '''. */ static const uint8_t bitmap_notomono_10_0027[] = { - 0xc0, 0x00, - 0x80, 0x00, - 0x80, 0x00, + 0xc0, + 0x80, + 0x80, }; /** Glyph definition for character '''. */ @@ -179,18 +180,18 @@ static const struct glyph glyph_notomono_10_0027 = { /** Bitmap definition for character '('. */ static const uint8_t bitmap_notomono_10_0028[] = { - 0x20, 0x00, - 0x60, 0x00, - 0x40, 0x00, - 0xc0, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xc0, 0x00, - 0x40, 0x00, - 0x60, 0x00, - 0x20, 0x00, + 0x20, + 0x60, + 0x40, + 0xc0, + 0x80, + 0x80, + 0x80, + 0x80, + 0xc0, + 0x40, + 0x60, + 0x20, }; /** Glyph definition for character '('. */ @@ -207,18 +208,18 @@ static const struct glyph glyph_notomono_10_0028 = { /** Bitmap definition for character ')'. */ static const uint8_t bitmap_notomono_10_0029[] = { - 0x40, 0x00, - 0x60, 0x00, - 0x20, 0x00, - 0x30, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x30, 0x00, - 0x20, 0x00, - 0x60, 0x00, - 0x40, 0x00, + 0x40, + 0x60, + 0x20, + 0x30, + 0x10, + 0x10, + 0x10, + 0x10, + 0x30, + 0x20, + 0x60, + 0x40, }; /** Glyph definition for character ')'. */ @@ -235,12 +236,12 @@ static const struct glyph glyph_notomono_10_0029 = { /** Bitmap definition for character '*'. */ static const uint8_t bitmap_notomono_10_002a[] = { - 0x10, 0x00, - 0x10, 0x00, - 0xfe, 0x00, - 0x10, 0x00, - 0x28, 0x00, - 0x6c, 0x00, + 0x10, + 0x10, + 0xfe, + 0x10, + 0x28, + 0x6c, }; /** Glyph definition for character '*'. */ @@ -257,13 +258,13 @@ static const struct glyph glyph_notomono_10_002a = { /** Bitmap definition for character '+'. */ static const uint8_t bitmap_notomono_10_002b[] = { - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0xfe, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, + 0x10, + 0x10, + 0x10, + 0xfe, + 0x10, + 0x10, + 0x10, }; /** Glyph definition for character '+'. */ @@ -280,9 +281,9 @@ static const struct glyph glyph_notomono_10_002b = { /** Bitmap definition for character ','. */ static const uint8_t bitmap_notomono_10_002c[] = { - 0xc0, 0x00, - 0xc0, 0x00, - 0x80, 0x00, + 0xc0, + 0xc0, + 0x80, }; /** Glyph definition for character ','. */ @@ -299,7 +300,7 @@ static const struct glyph glyph_notomono_10_002c = { /** Bitmap definition for character '-'. */ static const uint8_t bitmap_notomono_10_002d[] = { - 0xf0, 0x00, + 0xf0, }; /** Glyph definition for character '-'. */ @@ -316,8 +317,8 @@ static const struct glyph glyph_notomono_10_002d = { /** Bitmap definition for character '.'. */ static const uint8_t bitmap_notomono_10_002e[] = { - 0xc0, 0x00, - 0xc0, 0x00, + 0xc0, + 0xc0, }; /** Glyph definition for character '.'. */ @@ -334,16 +335,16 @@ static const struct glyph glyph_notomono_10_002e = { /** Bitmap definition for character '/'. */ static const uint8_t bitmap_notomono_10_002f[] = { - 0x04, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x40, 0x00, - 0x40, 0x00, - 0x80, 0x00, + 0x04, + 0x08, + 0x08, + 0x10, + 0x10, + 0x20, + 0x20, + 0x40, + 0x40, + 0x80, }; /** Glyph definition for character '/'. */ @@ -360,16 +361,16 @@ static const struct glyph glyph_notomono_10_002f = { /** Bitmap definition for character '0'. */ static const uint8_t bitmap_notomono_10_0030[] = { - 0x78, 0x00, - 0x48, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x48, 0x00, - 0x78, 0x00, + 0x78, + 0x48, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0x48, + 0x78, }; /** Glyph definition for character '0'. */ @@ -386,16 +387,16 @@ static const struct glyph glyph_notomono_10_0030 = { /** Bitmap definition for character '1'. */ static const uint8_t bitmap_notomono_10_0031[] = { - 0x20, 0x00, - 0x60, 0x00, - 0xa0, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, + 0x20, + 0x60, + 0xa0, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, }; /** Glyph definition for character '1'. */ @@ -412,16 +413,16 @@ static const struct glyph glyph_notomono_10_0031 = { /** Bitmap definition for character '2'. */ static const uint8_t bitmap_notomono_10_0032[] = { - 0x78, 0x00, - 0x8c, 0x00, - 0x04, 0x00, - 0x04, 0x00, - 0x08, 0x00, - 0x18, 0x00, - 0x30, 0x00, - 0x60, 0x00, - 0x40, 0x00, - 0xfc, 0x00, + 0x78, + 0x8c, + 0x04, + 0x04, + 0x08, + 0x18, + 0x30, + 0x60, + 0x40, + 0xfc, }; /** Glyph definition for character '2'. */ @@ -438,16 +439,16 @@ static const struct glyph glyph_notomono_10_0032 = { /** Bitmap definition for character '3'. */ static const uint8_t bitmap_notomono_10_0033[] = { - 0x78, 0x00, - 0x8c, 0x00, - 0x04, 0x00, - 0x0c, 0x00, - 0x30, 0x00, - 0x0c, 0x00, - 0x04, 0x00, - 0x04, 0x00, - 0x0c, 0x00, - 0xf8, 0x00, + 0x78, + 0x8c, + 0x04, + 0x0c, + 0x30, + 0x0c, + 0x04, + 0x04, + 0x0c, + 0xf8, }; /** Glyph definition for character '3'. */ @@ -464,16 +465,16 @@ static const struct glyph glyph_notomono_10_0033 = { /** Bitmap definition for character '4'. */ static const uint8_t bitmap_notomono_10_0034[] = { - 0x08, 0x00, - 0x18, 0x00, - 0x28, 0x00, - 0x28, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x88, 0x00, - 0xfc, 0x00, - 0x08, 0x00, - 0x08, 0x00, + 0x08, + 0x18, + 0x28, + 0x28, + 0x48, + 0x48, + 0x88, + 0xfc, + 0x08, + 0x08, }; /** Glyph definition for character '4'. */ @@ -490,16 +491,16 @@ static const struct glyph glyph_notomono_10_0034 = { /** Bitmap definition for character '5'. */ static const uint8_t bitmap_notomono_10_0035[] = { - 0xfc, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xf8, 0x00, - 0x0c, 0x00, - 0x04, 0x00, - 0x04, 0x00, - 0x0c, 0x00, - 0xf8, 0x00, + 0xfc, + 0x80, + 0x80, + 0x80, + 0xf8, + 0x0c, + 0x04, + 0x04, + 0x0c, + 0xf8, }; /** Glyph definition for character '5'. */ @@ -516,16 +517,16 @@ static const struct glyph glyph_notomono_10_0035 = { /** Bitmap definition for character '6'. */ static const uint8_t bitmap_notomono_10_0036[] = { - 0x3c, 0x00, - 0x60, 0x00, - 0x40, 0x00, - 0xc0, 0x00, - 0xb8, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x4c, 0x00, - 0x78, 0x00, + 0x3c, + 0x60, + 0x40, + 0xc0, + 0xb8, + 0xcc, + 0x84, + 0x84, + 0x4c, + 0x78, }; /** Glyph definition for character '6'. */ @@ -542,16 +543,16 @@ static const struct glyph glyph_notomono_10_0036 = { /** Bitmap definition for character '7'. */ static const uint8_t bitmap_notomono_10_0037[] = { - 0xfc, 0x00, - 0x04, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x30, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x40, 0x00, + 0xfc, + 0x04, + 0x08, + 0x08, + 0x10, + 0x10, + 0x30, + 0x20, + 0x20, + 0x40, }; /** Glyph definition for character '7'. */ @@ -568,16 +569,16 @@ static const struct glyph glyph_notomono_10_0037 = { /** Bitmap definition for character '8'. */ static const uint8_t bitmap_notomono_10_0038[] = { - 0x78, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x70, 0x00, - 0x48, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x78, 0x00, + 0x78, + 0xcc, + 0x84, + 0xcc, + 0x70, + 0x48, + 0x84, + 0x84, + 0xcc, + 0x78, }; /** Glyph definition for character '8'. */ @@ -594,16 +595,16 @@ static const struct glyph glyph_notomono_10_0038 = { /** Bitmap definition for character '9'. */ static const uint8_t bitmap_notomono_10_0039[] = { - 0x78, 0x00, - 0xc8, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x74, 0x00, - 0x0c, 0x00, - 0x08, 0x00, - 0x18, 0x00, - 0xf0, 0x00, + 0x78, + 0xc8, + 0x84, + 0x84, + 0xcc, + 0x74, + 0x0c, + 0x08, + 0x18, + 0xf0, }; /** Glyph definition for character '9'. */ @@ -620,14 +621,14 @@ static const struct glyph glyph_notomono_10_0039 = { /** Bitmap definition for character ':'. */ static const uint8_t bitmap_notomono_10_003a[] = { - 0xc0, 0x00, - 0xc0, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0xc0, 0x00, - 0xc0, 0x00, + 0xc0, + 0xc0, + 0x00, + 0x00, + 0x00, + 0x00, + 0xc0, + 0xc0, }; /** Glyph definition for character ':'. */ @@ -644,15 +645,15 @@ static const struct glyph glyph_notomono_10_003a = { /** Bitmap definition for character ';'. */ static const uint8_t bitmap_notomono_10_003b[] = { - 0xc0, 0x00, - 0xc0, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0xc0, 0x00, - 0xc0, 0x00, - 0x80, 0x00, + 0xc0, + 0xc0, + 0x00, + 0x00, + 0x00, + 0x00, + 0xc0, + 0xc0, + 0x80, }; /** Glyph definition for character ';'. */ @@ -669,13 +670,13 @@ static const struct glyph glyph_notomono_10_003b = { /** Bitmap definition for character '<'. */ static const uint8_t bitmap_notomono_10_003c[] = { - 0x04, 0x00, - 0x18, 0x00, - 0x60, 0x00, - 0x80, 0x00, - 0x60, 0x00, - 0x18, 0x00, - 0x04, 0x00, + 0x04, + 0x18, + 0x60, + 0x80, + 0x60, + 0x18, + 0x04, }; /** Glyph definition for character '<'. */ @@ -692,9 +693,9 @@ static const struct glyph glyph_notomono_10_003c = { /** Bitmap definition for character '='. */ static const uint8_t bitmap_notomono_10_003d[] = { - 0xfc, 0x00, - 0x00, 0x00, - 0xfc, 0x00, + 0xfc, + 0x00, + 0xfc, }; /** Glyph definition for character '='. */ @@ -711,13 +712,13 @@ static const struct glyph glyph_notomono_10_003d = { /** Bitmap definition for character '>'. */ static const uint8_t bitmap_notomono_10_003e[] = { - 0x80, 0x00, - 0x60, 0x00, - 0x18, 0x00, - 0x04, 0x00, - 0x18, 0x00, - 0x60, 0x00, - 0x80, 0x00, + 0x80, + 0x60, + 0x18, + 0x04, + 0x18, + 0x60, + 0x80, }; /** Glyph definition for character '>'. */ @@ -734,16 +735,16 @@ static const struct glyph glyph_notomono_10_003e = { /** Bitmap definition for character '?'. */ static const uint8_t bitmap_notomono_10_003f[] = { - 0xf8, 0x00, - 0x8c, 0x00, - 0x04, 0x00, - 0x0c, 0x00, - 0x18, 0x00, - 0x10, 0x00, - 0x20, 0x00, - 0x00, 0x00, - 0x30, 0x00, - 0x30, 0x00, + 0xf8, + 0x8c, + 0x04, + 0x0c, + 0x18, + 0x10, + 0x20, + 0x00, + 0x30, + 0x30, }; /** Glyph definition for character '?'. */ @@ -760,17 +761,17 @@ static const struct glyph glyph_notomono_10_003f = { /** Bitmap definition for character '@'. */ static const uint8_t bitmap_notomono_10_0040[] = { - 0x3c, 0x00, - 0x42, 0x00, - 0x41, 0x00, - 0x9d, 0x00, - 0xa5, 0x00, - 0xa5, 0x00, - 0xa5, 0x00, - 0x9a, 0x00, - 0xc0, 0x00, - 0x40, 0x00, - 0x3e, 0x00, + 0x3c, + 0x42, + 0x41, + 0x9d, + 0xa5, + 0xa5, + 0xa5, + 0x9a, + 0xc0, + 0x40, + 0x3e, }; /** Glyph definition for character '@'. */ @@ -787,16 +788,16 @@ static const struct glyph glyph_notomono_10_0040 = { /** Bitmap definition for character 'A'. */ static const uint8_t bitmap_notomono_10_0041[] = { - 0x18, 0x00, - 0x18, 0x00, - 0x18, 0x00, - 0x24, 0x00, - 0x24, 0x00, - 0x24, 0x00, - 0x7e, 0x00, - 0x42, 0x00, - 0x42, 0x00, - 0x81, 0x00, + 0x18, + 0x18, + 0x18, + 0x24, + 0x24, + 0x24, + 0x7e, + 0x42, + 0x42, + 0x81, }; /** Glyph definition for character 'A'. */ @@ -813,16 +814,16 @@ static const struct glyph glyph_notomono_10_0041 = { /** Bitmap definition for character 'B'. */ static const uint8_t bitmap_notomono_10_0042[] = { - 0xf8, 0x00, - 0x8c, 0x00, - 0x84, 0x00, - 0x8c, 0x00, - 0xf0, 0x00, - 0x8c, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x8c, 0x00, - 0xf8, 0x00, + 0xf8, + 0x8c, + 0x84, + 0x8c, + 0xf0, + 0x8c, + 0x84, + 0x84, + 0x8c, + 0xf8, }; /** Glyph definition for character 'B'. */ @@ -839,16 +840,16 @@ static const struct glyph glyph_notomono_10_0042 = { /** Bitmap definition for character 'C'. */ static const uint8_t bitmap_notomono_10_0043[] = { - 0x3c, 0x00, - 0x64, 0x00, - 0xc0, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xc0, 0x00, - 0x60, 0x00, - 0x3c, 0x00, + 0x3c, + 0x64, + 0xc0, + 0x80, + 0x80, + 0x80, + 0x80, + 0xc0, + 0x60, + 0x3c, }; /** Glyph definition for character 'C'. */ @@ -865,16 +866,16 @@ static const struct glyph glyph_notomono_10_0043 = { /** Bitmap definition for character 'D'. */ static const uint8_t bitmap_notomono_10_0044[] = { - 0xf0, 0x00, - 0x98, 0x00, - 0x8c, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x8c, 0x00, - 0x98, 0x00, - 0xf0, 0x00, + 0xf0, + 0x98, + 0x8c, + 0x84, + 0x84, + 0x84, + 0x84, + 0x8c, + 0x98, + 0xf0, }; /** Glyph definition for character 'D'. */ @@ -891,16 +892,16 @@ static const struct glyph glyph_notomono_10_0044 = { /** Bitmap definition for character 'E'. */ static const uint8_t bitmap_notomono_10_0045[] = { - 0xfc, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xfc, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xfc, 0x00, + 0xfc, + 0x80, + 0x80, + 0x80, + 0xfc, + 0x80, + 0x80, + 0x80, + 0x80, + 0xfc, }; /** Glyph definition for character 'E'. */ @@ -917,16 +918,16 @@ static const struct glyph glyph_notomono_10_0045 = { /** Bitmap definition for character 'F'. */ static const uint8_t bitmap_notomono_10_0046[] = { - 0xfc, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xfc, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, + 0xfc, + 0x80, + 0x80, + 0x80, + 0xfc, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, }; /** Glyph definition for character 'F'. */ @@ -943,16 +944,16 @@ static const struct glyph glyph_notomono_10_0046 = { /** Bitmap definition for character 'G'. */ static const uint8_t bitmap_notomono_10_0047[] = { - 0x3c, 0x00, - 0x60, 0x00, - 0xc0, 0x00, - 0x80, 0x00, - 0x9c, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xc4, 0x00, - 0x44, 0x00, - 0x3c, 0x00, + 0x3c, + 0x60, + 0xc0, + 0x80, + 0x9c, + 0x84, + 0x84, + 0xc4, + 0x44, + 0x3c, }; /** Glyph definition for character 'G'. */ @@ -969,16 +970,16 @@ static const struct glyph glyph_notomono_10_0047 = { /** Bitmap definition for character 'H'. */ static const uint8_t bitmap_notomono_10_0048[] = { - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xfc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, + 0x84, + 0x84, + 0x84, + 0x84, + 0xfc, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, }; /** Glyph definition for character 'H'. */ @@ -995,16 +996,16 @@ static const struct glyph glyph_notomono_10_0048 = { /** Bitmap definition for character 'I'. */ static const uint8_t bitmap_notomono_10_0049[] = { - 0xf8, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0xf8, 0x00, + 0xf8, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0xf8, }; /** Glyph definition for character 'I'. */ @@ -1021,16 +1022,16 @@ static const struct glyph glyph_notomono_10_0049 = { /** Bitmap definition for character 'J'. */ static const uint8_t bitmap_notomono_10_004a[] = { - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x18, 0x00, - 0xf0, 0x00, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x18, + 0xf0, }; /** Glyph definition for character 'J'. */ @@ -1047,16 +1048,16 @@ static const struct glyph glyph_notomono_10_004a = { /** Bitmap definition for character 'K'. */ static const uint8_t bitmap_notomono_10_004b[] = { - 0x86, 0x00, - 0x8c, 0x00, - 0x88, 0x00, - 0x90, 0x00, - 0xa0, 0x00, - 0xd0, 0x00, - 0x98, 0x00, - 0x88, 0x00, - 0x84, 0x00, - 0x86, 0x00, + 0x86, + 0x8c, + 0x88, + 0x90, + 0xa0, + 0xd0, + 0x98, + 0x88, + 0x84, + 0x86, }; /** Glyph definition for character 'K'. */ @@ -1073,16 +1074,16 @@ static const struct glyph glyph_notomono_10_004b = { /** Bitmap definition for character 'L'. */ static const uint8_t bitmap_notomono_10_004c[] = { - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xfc, 0x00, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0xfc, }; /** Glyph definition for character 'L'. */ @@ -1099,16 +1100,16 @@ static const struct glyph glyph_notomono_10_004c = { /** Bitmap definition for character 'M'. */ static const uint8_t bitmap_notomono_10_004d[] = { - 0x82, 0x00, - 0xc6, 0x00, - 0xc6, 0x00, - 0xc6, 0x00, - 0xaa, 0x00, - 0xaa, 0x00, - 0xaa, 0x00, - 0xb2, 0x00, - 0x92, 0x00, - 0x92, 0x00, + 0x82, + 0xc6, + 0xc6, + 0xc6, + 0xaa, + 0xaa, + 0xaa, + 0xb2, + 0x92, + 0x92, }; /** Glyph definition for character 'M'. */ @@ -1125,16 +1126,16 @@ static const struct glyph glyph_notomono_10_004d = { /** Bitmap definition for character 'N'. */ static const uint8_t bitmap_notomono_10_004e[] = { - 0x84, 0x00, - 0xc4, 0x00, - 0xc4, 0x00, - 0xa4, 0x00, - 0xa4, 0x00, - 0x94, 0x00, - 0x94, 0x00, - 0x8c, 0x00, - 0x8c, 0x00, - 0x84, 0x00, + 0x84, + 0xc4, + 0xc4, + 0xa4, + 0xa4, + 0x94, + 0x94, + 0x8c, + 0x8c, + 0x84, }; /** Glyph definition for character 'N'. */ @@ -1151,16 +1152,16 @@ static const struct glyph glyph_notomono_10_004e = { /** Bitmap definition for character 'O'. */ static const uint8_t bitmap_notomono_10_004f[] = { - 0x78, 0x00, - 0x48, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x48, 0x00, - 0x78, 0x00, + 0x78, + 0x48, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0x48, + 0x78, }; /** Glyph definition for character 'O'. */ @@ -1177,16 +1178,16 @@ static const struct glyph glyph_notomono_10_004f = { /** Bitmap definition for character 'P'. */ static const uint8_t bitmap_notomono_10_0050[] = { - 0xf8, 0x00, - 0x8c, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x8c, 0x00, - 0xf8, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, + 0xf8, + 0x8c, + 0x84, + 0x84, + 0x8c, + 0xf8, + 0x80, + 0x80, + 0x80, + 0x80, }; /** Glyph definition for character 'P'. */ @@ -1203,19 +1204,19 @@ static const struct glyph glyph_notomono_10_0050 = { /** Bitmap definition for character 'Q'. */ static const uint8_t bitmap_notomono_10_0051[] = { - 0x78, 0x00, - 0x48, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x48, 0x00, - 0x70, 0x00, - 0x08, 0x00, - 0x0c, 0x00, - 0x04, 0x00, + 0x78, + 0x48, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0x48, + 0x70, + 0x08, + 0x0c, + 0x04, }; /** Glyph definition for character 'Q'. */ @@ -1232,16 +1233,16 @@ static const struct glyph glyph_notomono_10_0051 = { /** Bitmap definition for character 'R'. */ static const uint8_t bitmap_notomono_10_0052[] = { - 0xf8, 0x00, - 0x8c, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x8c, 0x00, - 0xf8, 0x00, - 0x98, 0x00, - 0x88, 0x00, - 0x84, 0x00, - 0x86, 0x00, + 0xf8, + 0x8c, + 0x84, + 0x84, + 0x8c, + 0xf8, + 0x98, + 0x88, + 0x84, + 0x86, }; /** Glyph definition for character 'R'. */ @@ -1258,16 +1259,16 @@ static const struct glyph glyph_notomono_10_0052 = { /** Bitmap definition for character 'S'. */ static const uint8_t bitmap_notomono_10_0053[] = { - 0x7c, 0x00, - 0xc4, 0x00, - 0x80, 0x00, - 0xc0, 0x00, - 0x70, 0x00, - 0x18, 0x00, - 0x04, 0x00, - 0x04, 0x00, - 0x0c, 0x00, - 0xf8, 0x00, + 0x7c, + 0xc4, + 0x80, + 0xc0, + 0x70, + 0x18, + 0x04, + 0x04, + 0x0c, + 0xf8, }; /** Glyph definition for character 'S'. */ @@ -1284,16 +1285,16 @@ static const struct glyph glyph_notomono_10_0053 = { /** Bitmap definition for character 'T'. */ static const uint8_t bitmap_notomono_10_0054[] = { - 0xfe, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, + 0xfe, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, }; /** Glyph definition for character 'T'. */ @@ -1310,16 +1311,16 @@ static const struct glyph glyph_notomono_10_0054 = { /** Bitmap definition for character 'U'. */ static const uint8_t bitmap_notomono_10_0055[] = { - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x78, 0x00, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0x78, }; /** Glyph definition for character 'U'. */ @@ -1336,16 +1337,16 @@ static const struct glyph glyph_notomono_10_0055 = { /** Bitmap definition for character 'V'. */ static const uint8_t bitmap_notomono_10_0056[] = { - 0x81, 0x00, - 0x42, 0x00, - 0x42, 0x00, - 0x42, 0x00, - 0x24, 0x00, - 0x24, 0x00, - 0x24, 0x00, - 0x18, 0x00, - 0x18, 0x00, - 0x18, 0x00, + 0x81, + 0x42, + 0x42, + 0x42, + 0x24, + 0x24, + 0x24, + 0x18, + 0x18, + 0x18, }; /** Glyph definition for character 'V'. */ @@ -1362,16 +1363,16 @@ static const struct glyph glyph_notomono_10_0056 = { /** Bitmap definition for character 'W'. */ static const uint8_t bitmap_notomono_10_0057[] = { - 0x81, 0x00, - 0x81, 0x00, - 0x81, 0x00, - 0xd1, 0x00, - 0x5a, 0x00, - 0x5a, 0x00, - 0x66, 0x00, - 0x66, 0x00, - 0x62, 0x00, - 0x42, 0x00, + 0x81, + 0x81, + 0x81, + 0xd1, + 0x5a, + 0x5a, + 0x66, + 0x66, + 0x62, + 0x42, }; /** Glyph definition for character 'W'. */ @@ -1388,16 +1389,16 @@ static const struct glyph glyph_notomono_10_0057 = { /** Bitmap definition for character 'X'. */ static const uint8_t bitmap_notomono_10_0058[] = { - 0xc3, 0x00, - 0x42, 0x00, - 0x24, 0x00, - 0x3c, 0x00, - 0x18, 0x00, - 0x18, 0x00, - 0x2c, 0x00, - 0x24, 0x00, - 0x42, 0x00, - 0x83, 0x00, + 0xc3, + 0x42, + 0x24, + 0x3c, + 0x18, + 0x18, + 0x2c, + 0x24, + 0x42, + 0x83, }; /** Glyph definition for character 'X'. */ @@ -1414,16 +1415,16 @@ static const struct glyph glyph_notomono_10_0058 = { /** Bitmap definition for character 'Y'. */ static const uint8_t bitmap_notomono_10_0059[] = { - 0xc2, 0x00, - 0x44, 0x00, - 0x64, 0x00, - 0x28, 0x00, - 0x28, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, + 0xc2, + 0x44, + 0x64, + 0x28, + 0x28, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, }; /** Glyph definition for character 'Y'. */ @@ -1440,16 +1441,16 @@ static const struct glyph glyph_notomono_10_0059 = { /** Bitmap definition for character 'Z'. */ static const uint8_t bitmap_notomono_10_005a[] = { - 0xfc, 0x00, - 0x0c, 0x00, - 0x08, 0x00, - 0x18, 0x00, - 0x10, 0x00, - 0x20, 0x00, - 0x60, 0x00, - 0x40, 0x00, - 0xc0, 0x00, - 0xfc, 0x00, + 0xfc, + 0x0c, + 0x08, + 0x18, + 0x10, + 0x20, + 0x60, + 0x40, + 0xc0, + 0xfc, }; /** Glyph definition for character 'Z'. */ @@ -1466,18 +1467,18 @@ static const struct glyph glyph_notomono_10_005a = { /** Bitmap definition for character '['. */ static const uint8_t bitmap_notomono_10_005b[] = { - 0xe0, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xe0, 0x00, + 0xe0, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0xe0, }; /** Glyph definition for character '['. */ @@ -1494,16 +1495,16 @@ static const struct glyph glyph_notomono_10_005b = { /** Bitmap definition for character '\'. */ static const uint8_t bitmap_notomono_10_005c[] = { - 0x80, 0x00, - 0x40, 0x00, - 0x40, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x04, 0x00, + 0x80, + 0x40, + 0x40, + 0x20, + 0x20, + 0x10, + 0x10, + 0x08, + 0x08, + 0x04, }; /** Glyph definition for character '\'. */ @@ -1520,18 +1521,18 @@ static const struct glyph glyph_notomono_10_005c = { /** Bitmap definition for character ']'. */ static const uint8_t bitmap_notomono_10_005d[] = { - 0xe0, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0xe0, 0x00, + 0xe0, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0xe0, }; /** Glyph definition for character ']'. */ @@ -1548,12 +1549,12 @@ static const struct glyph glyph_notomono_10_005d = { /** Bitmap definition for character '^'. */ static const uint8_t bitmap_notomono_10_005e[] = { - 0x30, 0x00, - 0x30, 0x00, - 0x30, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x84, 0x00, + 0x30, + 0x30, + 0x30, + 0x48, + 0x48, + 0x84, }; /** Glyph definition for character '^'. */ @@ -1570,7 +1571,7 @@ static const struct glyph glyph_notomono_10_005e = { /** Bitmap definition for character '_'. */ static const uint8_t bitmap_notomono_10_005f[] = { - 0xff, 0x00, + 0xff, }; /** Glyph definition for character '_'. */ @@ -1587,14 +1588,14 @@ static const struct glyph glyph_notomono_10_005f = { /** Bitmap definition for character 'a'. */ static const uint8_t bitmap_notomono_10_0061[] = { - 0x78, 0x00, - 0x0c, 0x00, - 0x04, 0x00, - 0x7c, 0x00, - 0xc4, 0x00, - 0x84, 0x00, - 0x8c, 0x00, - 0x74, 0x00, + 0x78, + 0x0c, + 0x04, + 0x7c, + 0xc4, + 0x84, + 0x8c, + 0x74, }; /** Glyph definition for character 'a'. */ @@ -1611,17 +1612,17 @@ static const struct glyph glyph_notomono_10_0061 = { /** Bitmap definition for character 'b'. */ static const uint8_t bitmap_notomono_10_0062[] = { - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xb8, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0xb8, 0x00, + 0x80, + 0x80, + 0x80, + 0xb8, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0xb8, }; /** Glyph definition for character 'b'. */ @@ -1638,14 +1639,14 @@ static const struct glyph glyph_notomono_10_0062 = { /** Bitmap definition for character 'c'. */ static const uint8_t bitmap_notomono_10_0063[] = { - 0x3c, 0x00, - 0x40, 0x00, - 0xc0, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x40, 0x00, - 0x3c, 0x00, + 0x3c, + 0x40, + 0xc0, + 0x80, + 0x80, + 0x80, + 0x40, + 0x3c, }; /** Glyph definition for character 'c'. */ @@ -1662,17 +1663,17 @@ static const struct glyph glyph_notomono_10_0063 = { /** Bitmap definition for character 'd'. */ static const uint8_t bitmap_notomono_10_0064[] = { - 0x04, 0x00, - 0x04, 0x00, - 0x04, 0x00, - 0x74, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x74, 0x00, + 0x04, + 0x04, + 0x04, + 0x74, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0x74, }; /** Glyph definition for character 'd'. */ @@ -1689,14 +1690,14 @@ static const struct glyph glyph_notomono_10_0064 = { /** Bitmap definition for character 'e'. */ static const uint8_t bitmap_notomono_10_0065[] = { - 0x78, 0x00, - 0x4c, 0x00, - 0x84, 0x00, - 0xfc, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x44, 0x00, - 0x3c, 0x00, + 0x78, + 0x4c, + 0x84, + 0xfc, + 0x80, + 0x80, + 0x44, + 0x3c, }; /** Glyph definition for character 'e'. */ @@ -1713,17 +1714,17 @@ static const struct glyph glyph_notomono_10_0065 = { /** Bitmap definition for character 'f'. */ static const uint8_t bitmap_notomono_10_0066[] = { - 0x1c, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0xfc, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, + 0x1c, + 0x20, + 0x20, + 0xfc, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, }; /** Glyph definition for character 'f'. */ @@ -1740,17 +1741,17 @@ static const struct glyph glyph_notomono_10_0066 = { /** Bitmap definition for character 'g'. */ static const uint8_t bitmap_notomono_10_0067[] = { - 0x7e, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x78, 0x00, - 0x80, 0x00, - 0xfc, 0x00, - 0xc2, 0x00, - 0x82, 0x00, - 0x86, 0x00, - 0x7c, 0x00, + 0x7e, + 0x84, + 0x84, + 0x84, + 0x78, + 0x80, + 0xfc, + 0xc2, + 0x82, + 0x86, + 0x7c, }; /** Glyph definition for character 'g'. */ @@ -1767,17 +1768,17 @@ static const struct glyph glyph_notomono_10_0067 = { /** Bitmap definition for character 'h'. */ static const uint8_t bitmap_notomono_10_0068[] = { - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0xb8, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, + 0x80, + 0x80, + 0x80, + 0xb8, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, }; /** Glyph definition for character 'h'. */ @@ -1794,17 +1795,17 @@ static const struct glyph glyph_notomono_10_0068 = { /** Bitmap definition for character 'i'. */ static const uint8_t bitmap_notomono_10_0069[] = { - 0x10, 0x00, - 0x10, 0x00, - 0x00, 0x00, - 0x70, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0xfc, 0x00, + 0x10, + 0x10, + 0x00, + 0x70, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0xfc, }; /** Glyph definition for character 'i'. */ @@ -1821,20 +1822,20 @@ static const struct glyph glyph_notomono_10_0069 = { /** Bitmap definition for character 'j'. */ static const uint8_t bitmap_notomono_10_006a[] = { - 0x08, 0x00, - 0x08, 0x00, - 0x00, 0x00, - 0x78, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x08, 0x00, - 0x18, 0x00, - 0xf0, 0x00, + 0x08, + 0x08, + 0x00, + 0x78, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x18, + 0xf0, }; /** Glyph definition for character 'j'. */ @@ -1851,17 +1852,17 @@ static const struct glyph glyph_notomono_10_006a = { /** Bitmap definition for character 'k'. */ static const uint8_t bitmap_notomono_10_006b[] = { - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x84, 0x00, - 0x88, 0x00, - 0x90, 0x00, - 0xa0, 0x00, - 0xf0, 0x00, - 0x98, 0x00, - 0x8c, 0x00, - 0x86, 0x00, + 0x80, + 0x80, + 0x80, + 0x84, + 0x88, + 0x90, + 0xa0, + 0xf0, + 0x98, + 0x8c, + 0x86, }; /** Glyph definition for character 'k'. */ @@ -1878,17 +1879,17 @@ static const struct glyph glyph_notomono_10_006b = { /** Bitmap definition for character 'l'. */ static const uint8_t bitmap_notomono_10_006c[] = { - 0x70, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0x10, 0x00, - 0xfc, 0x00, + 0x70, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0xfc, }; /** Glyph definition for character 'l'. */ @@ -1905,14 +1906,14 @@ static const struct glyph glyph_notomono_10_006c = { /** Bitmap definition for character 'm'. */ static const uint8_t bitmap_notomono_10_006d[] = { - 0xac, 0x00, - 0xd2, 0x00, - 0x92, 0x00, - 0x92, 0x00, - 0x92, 0x00, - 0x92, 0x00, - 0x92, 0x00, - 0x92, 0x00, + 0xac, + 0xd2, + 0x92, + 0x92, + 0x92, + 0x92, + 0x92, + 0x92, }; /** Glyph definition for character 'm'. */ @@ -1929,14 +1930,14 @@ static const struct glyph glyph_notomono_10_006d = { /** Bitmap definition for character 'n'. */ static const uint8_t bitmap_notomono_10_006e[] = { - 0xb8, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, + 0xb8, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, }; /** Glyph definition for character 'n'. */ @@ -1953,14 +1954,14 @@ static const struct glyph glyph_notomono_10_006e = { /** Bitmap definition for character 'o'. */ static const uint8_t bitmap_notomono_10_006f[] = { - 0x78, 0x00, - 0x48, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x48, 0x00, - 0x78, 0x00, + 0x78, + 0x48, + 0x84, + 0x84, + 0x84, + 0x84, + 0x48, + 0x78, }; /** Glyph definition for character 'o'. */ @@ -1977,17 +1978,17 @@ static const struct glyph glyph_notomono_10_006f = { /** Bitmap definition for character 'p'. */ static const uint8_t bitmap_notomono_10_0070[] = { - 0xb8, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0xb8, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, + 0xb8, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0xb8, + 0x80, + 0x80, + 0x80, }; /** Glyph definition for character 'p'. */ @@ -2004,17 +2005,17 @@ static const struct glyph glyph_notomono_10_0070 = { /** Bitmap definition for character 'q'. */ static const uint8_t bitmap_notomono_10_0071[] = { - 0x74, 0x00, - 0xcc, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x74, 0x00, - 0x04, 0x00, - 0x04, 0x00, - 0x04, 0x00, + 0x74, + 0xcc, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0x74, + 0x04, + 0x04, + 0x04, }; /** Glyph definition for character 'q'. */ @@ -2031,14 +2032,14 @@ static const struct glyph glyph_notomono_10_0071 = { /** Bitmap definition for character 'r'. */ static const uint8_t bitmap_notomono_10_0072[] = { - 0xb8, 0x00, - 0xc0, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, + 0xb8, + 0xc0, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, }; /** Glyph definition for character 'r'. */ @@ -2055,14 +2056,14 @@ static const struct glyph glyph_notomono_10_0072 = { /** Bitmap definition for character 's'. */ static const uint8_t bitmap_notomono_10_0073[] = { - 0x7c, 0x00, - 0x84, 0x00, - 0x80, 0x00, - 0x70, 0x00, - 0x1c, 0x00, - 0x04, 0x00, - 0x04, 0x00, - 0xf8, 0x00, + 0x7c, + 0x84, + 0x80, + 0x70, + 0x1c, + 0x04, + 0x04, + 0xf8, }; /** Glyph definition for character 's'. */ @@ -2079,16 +2080,16 @@ static const struct glyph glyph_notomono_10_0073 = { /** Bitmap definition for character 't'. */ static const uint8_t bitmap_notomono_10_0074[] = { - 0x20, 0x00, - 0x20, 0x00, - 0xfc, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x1c, 0x00, + 0x20, + 0x20, + 0xfc, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x1c, }; /** Glyph definition for character 't'. */ @@ -2105,14 +2106,14 @@ static const struct glyph glyph_notomono_10_0074 = { /** Bitmap definition for character 'u'. */ static const uint8_t bitmap_notomono_10_0075[] = { - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0x84, 0x00, - 0xcc, 0x00, - 0x74, 0x00, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0x84, + 0xcc, + 0x74, }; /** Glyph definition for character 'u'. */ @@ -2129,14 +2130,14 @@ static const struct glyph glyph_notomono_10_0075 = { /** Bitmap definition for character 'v'. */ static const uint8_t bitmap_notomono_10_0076[] = { - 0x84, 0x00, - 0xcc, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x30, 0x00, - 0x30, 0x00, - 0x30, 0x00, + 0x84, + 0xcc, + 0x48, + 0x48, + 0x48, + 0x30, + 0x30, + 0x30, }; /** Glyph definition for character 'v'. */ @@ -2153,14 +2154,14 @@ static const struct glyph glyph_notomono_10_0076 = { /** Bitmap definition for character 'w'. */ static const uint8_t bitmap_notomono_10_0077[] = { - 0x99, 0x00, - 0x99, 0x00, - 0x99, 0x00, - 0xa5, 0x00, - 0xa5, 0x00, - 0x66, 0x00, - 0x46, 0x00, - 0x42, 0x00, + 0x99, + 0x99, + 0x99, + 0xa5, + 0xa5, + 0x66, + 0x46, + 0x42, }; /** Glyph definition for character 'w'. */ @@ -2177,14 +2178,14 @@ static const struct glyph glyph_notomono_10_0077 = { /** Bitmap definition for character 'x'. */ static const uint8_t bitmap_notomono_10_0078[] = { - 0xcc, 0x00, - 0x48, 0x00, - 0x30, 0x00, - 0x30, 0x00, - 0x30, 0x00, - 0x78, 0x00, - 0x48, 0x00, - 0x84, 0x00, + 0xcc, + 0x48, + 0x30, + 0x30, + 0x30, + 0x78, + 0x48, + 0x84, }; /** Glyph definition for character 'x'. */ @@ -2201,17 +2202,17 @@ static const struct glyph glyph_notomono_10_0078 = { /** Bitmap definition for character 'y'. */ static const uint8_t bitmap_notomono_10_0079[] = { - 0x84, 0x00, - 0xcc, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x48, 0x00, - 0x30, 0x00, - 0x30, 0x00, - 0x30, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0xc0, 0x00, + 0x84, + 0xcc, + 0x48, + 0x48, + 0x48, + 0x30, + 0x30, + 0x30, + 0x20, + 0x20, + 0xc0, }; /** Glyph definition for character 'y'. */ @@ -2228,14 +2229,14 @@ static const struct glyph glyph_notomono_10_0079 = { /** Bitmap definition for character 'z'. */ static const uint8_t bitmap_notomono_10_007a[] = { - 0xfc, 0x00, - 0x0c, 0x00, - 0x08, 0x00, - 0x10, 0x00, - 0x20, 0x00, - 0x60, 0x00, - 0xc0, 0x00, - 0xfc, 0x00, + 0xfc, + 0x0c, + 0x08, + 0x10, + 0x20, + 0x60, + 0xc0, + 0xfc, }; /** Glyph definition for character 'z'. */ @@ -2252,18 +2253,18 @@ static const struct glyph glyph_notomono_10_007a = { /** Bitmap definition for character '{'. */ static const uint8_t bitmap_notomono_10_007b[] = { - 0x18, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0xc0, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x18, 0x00, + 0x18, + 0x20, + 0x20, + 0x20, + 0x20, + 0xc0, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0x18, }; /** Glyph definition for character '{'. */ @@ -2280,20 +2281,20 @@ static const struct glyph glyph_notomono_10_007b = { /** Bitmap definition for character '|'. */ static const uint8_t bitmap_notomono_10_007c[] = { - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, - 0x80, 0x00, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, + 0x80, }; /** Glyph definition for character '|'. */ @@ -2310,18 +2311,18 @@ static const struct glyph glyph_notomono_10_007c = { /** Bitmap definition for character '}'. */ static const uint8_t bitmap_notomono_10_007d[] = { - 0xc0, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x18, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0x20, 0x00, - 0xc0, 0x00, + 0xc0, + 0x20, + 0x20, + 0x20, + 0x20, + 0x18, + 0x20, + 0x20, + 0x20, + 0x20, + 0x20, + 0xc0, }; /** Glyph definition for character '}'. */ @@ -2338,8 +2339,8 @@ static const struct glyph glyph_notomono_10_007d = { /** Bitmap definition for character '~'. */ static const uint8_t bitmap_notomono_10_007e[] = { - 0xe0, 0x00, - 0x1c, 0x00, + 0xe0, + 0x1c, }; /** Glyph definition for character '~'. */ diff --git a/macros.h b/macros.h index 711b921..67ac6e0 100644 --- a/macros.h +++ b/macros.h @@ -43,12 +43,12 @@ (x) |= 1u << (y); \ } while (0) -#define CLEAR(x, y) \ +#define CLR(x, y) \ do { \ (x) &= ~(y); \ } while (0) -#define CLEAR_POS(x, y) \ +#define CLR_POS(x, y) \ do { \ (x) &= ~(1u << (y)); \ } while (0) @@ -67,7 +67,7 @@ static_assert((clear_mask & val) == val, \ "'value' in SET_TO() has bits set that are not in clear_mask"); \ do { \ - CLEAR(x, clear_mask); \ + CLR(x, clear_mask); \ SET(x, val); \ } while (0) diff --git a/spi.c b/spi.c new file mode 100644 index 0000000..e67a51a --- /dev/null +++ b/spi.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2019 Max Regan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 OR COPYRIGHT HOLDERS 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. + */ + +#include "spi.h" + +#include "stm32l0xx.h" +#include "macros.h" + +void spi_send_blocking(SPI_TypeDef *spi, const uint8_t *data, size_t len) +{ + if (len <= 0) { + return; + } + + spi->CR1 |= SPI_CR1_SPE; + + for (size_t i = 0; i < len; i++) { + while (!(spi->SR & SPI_SR_TXE)) {} + spi->DR = data[i]; + } + + while (!(spi->SR & SPI_SR_TXE)) {} + + // Ensure that NSS is held for long enough to meet the display's thSCS + for (int i = 0; i < 4; i++); + + spi->CR1 &= ~SPI_CR1_SPE; +} diff --git a/spi.h b/spi.h new file mode 100644 index 0000000..199c858 --- /dev/null +++ b/spi.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2019 Max Regan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 OR COPYRIGHT HOLDERS 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. + */ + +#ifndef _SPI_H_ +#define _SPI_H_ + +#include +#include + +// TODO: Include something more general (only needed for SPI typedef) +#include "stm32l0xx.h" + +void spi_send_blocking(SPI_TypeDef *spi, const uint8_t *data, size_t len); + +void spi_send_dma(SPI_TypeDef *spi); + +#endif diff --git a/test.c b/test.c index b872c6e..b13ae20 100644 --- a/test.c +++ b/test.c @@ -1,32 +1,33 @@ -/** - Copyright 2019, Max Regan - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - 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 OR COPYRIGHT HOLDERS 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. -**/ +/* + * Copyright (C) 2019 Max Regan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 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 OR COPYRIGHT HOLDERS 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. + */ #include #include #include -#include "macros.h" #include "stm32l0xx.h" + +#include "macros.h" +#include "spi.h" +#include "display.h" #include "font-notomono-10.h" /* TODO: Start cleaning up code and adding bounds checking! */ @@ -43,10 +44,12 @@ void SystemInit() * of the HSE oscillator used directly or indirectly as system * clock. This bit cannot be cleared if the MSI is used as system * clock. */ - SET(RCC->CR, RCC_CR_MSION); - CLEAR(RCC->ICSCR, RCC_ICSCR_MSIRANGE); + SET(RCC->CR, + RCC_CR_MSION); - SET_TO(RCC->ICSCR, RCC_ICSCR_MSIRANGE, RCC_ICSCR_MSIRANGE_6); + SET_TO(RCC->ICSCR, + RCC_ICSCR_MSIRANGE, + RCC_ICSCR_MSIRANGE_6); /*!< Reset * SW[1:0] (use MSI oscillator as system clock), @@ -55,7 +58,7 @@ void SystemInit() * PPRE2[2:0] (do not divide APB high-speed clock), * MCOSEL[2:0] (disable MCO clock), * MCOPRE[2:0] (disable MCO prescaler) */ - CLEAR(RCC->CFGR, + CLR(RCC->CFGR, RCC_CFGR_SW | ~RCC_CFGR_HPRE | RCC_CFGR_PPRE1 | RCC_CFGR_PPRE2 | RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE); @@ -66,19 +69,21 @@ void SystemInit() * CSSHSEON (disable HSE clock monitoring) * PLLON (disable PLL) */ - CLEAR(RCC->CR, + CLR(RCC->CR, RCC_CR_HSION | RCC_CR_HSIDIVEN | RCC_CR_HSEON | RCC_CR_CSSHSEON | RCC_CR_PLLON); /*!< Reset HSEBYP bit (disable HSE bypass) */ - RCC->CR &= ~RCC_CR_HSEBYP; + CLR(RCC->CR, + RCC_CR_HSEBYP); /*!< Reset * PLLSRC (HSI16 is the PLL source), * PLLMUL[3:0] (3x PLL multiplication) * Don't touch PLLDIV[1:0], since 0 is undefined */ - RCC->CFGR &= ~RCC_CFGR_PLLSRC & ~RCC_CFGR_PLLMUL & ~RCC_CFGR_PLLDIV; + CLR(RCC->CFGR, + RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL | RCC_CFGR_PLLDIV); /*!< Disable all interrupts */ @@ -91,14 +96,17 @@ void SystemInit() void init_lptim() { /* Enable APB1 for LPTIM */ - RCC->APB1ENR |= RCC_APB1ENR_LPTIM1EN; + SET(RCC->APB1ENR, + RCC_APB1ENR_LPTIM1EN); // Enable low-speed internal RCC->CSR |= RCC_CSR_LSION; while (!(RCC->CSR & RCC_CSR_LSIRDY)) {}; /*!< Set the LSI clock to be the source of the LPTIM */ - SET_TO(RCC->CCIPR, RCC_CCIPR_LPTIM1SEL, RCC_CCIPR_LPTIM1SEL_0); + SET_TO(RCC->CCIPR, + RCC_CCIPR_LPTIM1SEL, + RCC_CCIPR_LPTIM1SEL_0); /** Write CR CFGR and IER while LPTIM is disabled (LPTIM_CR_ENABLE not yet set) */ @@ -114,18 +122,20 @@ void init_lptim() * COUNTMODE (LPTIM counter updated on every clock pulse) * TRGFLT (Do not debounce triggers) */ - LPTIM1->CFGR &= ~LPTIM_CFGR_ENC & ~LPTIM_CFGR_TIMOUT & ~LPTIM_CFGR_TRIGEN & - ~LPTIM_CFGR_TRIGSEL & ~LPTIM_CFGR_PRELOAD & ~LPTIM_CFGR_CKSEL & - ~LPTIM_CFGR_COUNTMODE; + CLR(LPTIM1->CFGR, + LPTIM_CFGR_ENC | LPTIM_CFGR_TIMOUT | LPTIM_CFGR_TRIGEN | + LPTIM_CFGR_TRIGSEL | LPTIM_CFGR_PRELOAD | LPTIM_CFGR_CKSEL | + LPTIM_CFGR_COUNTMODE); /*!< Set * PRESC (Set prescaler to 128. Using 32kHz LSI as input, this should * correspond to 250Hz counting. */ - LPTIM1->CFGR &= LPTIM_CFGR_PRESC; - LPTIM1->CFGR |= 7u << LPTIM_CFGR_PRESC_Pos; + SET_TO(LPTIM1->CFGR, + LPTIM_CFGR_PRESC, + 7u << LPTIM_CFGR_PRESC_Pos); - LPTIM1->CR |= LPTIM_CR_ENABLE; + SET(LPTIM1->CR, LPTIM_CR_ENABLE); /*!< Do not modify ARR and CMP until after ENABLE bit is set */ /*!< Produce a 60Hz, 50% duty cycle square wave. These values were @@ -136,230 +146,58 @@ void init_lptim() while(!(LPTIM1->ISR & LPTIM_ISR_CMPOK)) {} /*!< Enable and start the timer */ - LPTIM1->CR |= LPTIM_CR_CNTSTRT; + SET(LPTIM1->CR, LPTIM_CR_CNTSTRT); } -/*!< The buffer that will be used in the future to display on the watch display. */ - -#define DISPLAY_WIDTH 144 -#define DISPLAY_HEIGHT 168 - -struct display_line -{ - uint8_t mode; - uint8_t line; - uint8_t data[DISPLAY_WIDTH / 8]; -}; - -struct display_buffer -{ - struct display_line lines[DISPLAY_HEIGHT]; - uint16_t dummy; -}; - -static_assert(sizeof(struct display_buffer) == (DISPLAY_WIDTH / 8 + 2) * DISPLAY_HEIGHT + 2, - "The display buffer structure must be packed"); - -void display_buffer_init(struct display_buffer *buffer) -{ - for (size_t i = 0; i < ARRAY_SIZE(buffer->lines); i++) { - struct display_line *line = &buffer->lines[i]; - line->mode = 1; // Update display - line->line = i; - for (size_t j = 0; j < ARRAY_SIZE(line->data); j++) { - line->data[j] = 0xFF; - } - } - - buffer->dummy = 0; -} - -void display_set_bit(struct display_buffer *buffer, unsigned int x, unsigned int y, uint8_t val) -{ - struct display_line *line = &buffer->lines[y]; - uint8_t *byte = &line->data[x >> 3]; - if (val) { - CLEAR_POS(*byte, x & 7); - } else { - SET_POS(*byte, x & 7); - } -} - -void display_set_byte(struct display_buffer *buffer, unsigned int x, unsigned int y, uint8_t val) -{ - if (x & 7) { - return; - } - - struct display_line *line = &buffer->lines[y]; - line->data[x >> 3] = val; -} - -static struct display_buffer buffer; +static struct display display; void init_lptim_toggler() { init_lptim(); /* Assign LPTIM1_OUT to PA7 */ - GPIOA->AFR[0] &= ~GPIO_AFRL_AFRL7; - GPIOA->AFR[0] |= 1 << GPIO_AFRL_AFRL7_Pos; + SET_TO(GPIOA->AFR[0], + GPIO_AFRL_AFRL7, + 1u << GPIO_AFRL_AFRL7_Pos); - GPIOA->MODER &= ~GPIO_MODER_MODE7; - GPIOA->MODER |= 2u << GPIO_MODER_MODE7_Pos; + SET_TO(GPIOA->MODER, + GPIO_MODER_MODE7, + 2u << GPIO_MODER_MODE7_Pos); - GPIOA->OTYPER &= ~GPIO_OTYPER_OT_7; - GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD7; -} - -void init_spi_display() -{ - RCC->APB2ENR = RCC_APB2ENR_SPI1EN; - - GPIOB->OSPEEDR = ~0; - - /* Assign SPI_MOSI to PA12 (AFRH5), since PA7 is taken by LPTIM_OUT */ - GPIOA->AFR[1] &= ~GPIO_AFRH_AFRH4; - - SET_TO(GPIOA->MODER, GPIO_MODER_MODE12, 2u << GPIO_MODER_MODE12_Pos); - - GPIOA->OTYPER &= ~GPIO_OTYPER_OT_12; - GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD12; - - // SPI1 NSS (PA4) - GPIOA->AFR[0] &= ~GPIO_AFRL_AFRL4; - - SET_TO(GPIOA->MODER, GPIO_MODER_MODE4, 2u << GPIO_MODER_MODE4_Pos); - - GPIOA->OTYPER &= ~GPIO_OTYPER_OT_4; - GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD4; - // enable pullup, since the pin doesn't seem to stay up - GPIOA->PUPDR |= 2u << GPIO_PUPDR_PUPD4_Pos; - - // SPI1 SCK (PA5) - GPIOA->AFR[0] &= ~GPIO_AFRL_AFRL5; - - SET_TO(GPIOA->MODER, GPIO_MODER_MODE5, 2u << GPIO_MODER_MODE5_Pos); - - GPIOA->OTYPER &= ~GPIO_OTYPER_OT_5; - GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD5; - - // SPI1 MISO (PA6) - GPIOA->AFR[0] &= ~GPIO_AFRL_AFRL6; - - SET_TO(GPIOA->MODER, GPIO_MODER_MODE6, 2u << GPIO_MODER_MODE6_Pos); - - GPIOA->OTYPER &= ~GPIO_OTYPER_OT_6; - GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD6; - - // Enable Master mode and half the baud rate, so it's set to ~1MHz - SPI1->CR1 |= SPI_CR1_MSTR | SPI_CR1_LSBFIRST; - SPI1->CR1 |= 1u << SPI_CR1_BR_Pos; - SPI1->CR2 |= SPI_CR2_SSOE; -} - -void spi_send_blocking(SPI_TypeDef *spi, const uint8_t *data, size_t len) -{ - if (len <= 0) { - return; - } - - spi->CR1 |= SPI_CR1_SPE; - - for (size_t i = 0; i < len; i++) { - while (!(spi->SR & SPI_SR_TXE)) {} - spi->DR = data[i]; - } - - while (!(spi->SR & SPI_SR_TXE)) {} - - // Ensure that NSS is held for long enough to meet the display's thSCS - for (int i = 0; i < 4; i++); - - spi->CR1 &= ~SPI_CR1_SPE; -} - -const struct glyph *glyph_for_char(const struct font *font, char c) -{ - // TODO: This is almost the least efficient way imaginable to implement this - for (int i = 0; i < font->max; i++) { - const struct glyph *g = font->glyphs[i]; - if (g == NULL) { - continue; - } - - if (g->glyph == c) { - return g; - } - } - - return NULL; -} - -void display_char_at(int *x_off, int y_off, char c) -{ - const struct glyph *g = glyph_for_char(&font_notomono_10, c); - if (g == NULL) { - return; - } - - int byte_cols = 2; - for (size_t x = 0; x < g->cols; x++) { - for (size_t y = 0; y < g->rows; y++) { - int byte_x = x >> 3; - int byte_y = y; - uint8_t bit = (g->bitmap[byte_y * byte_cols + byte_x] >> (7 - (x & 7))) & 1; - /* 16 is font max height */ - display_set_bit(&buffer, g->left + *x_off + x, y_off + y + 16 - g->top, bit); - } - } - *x_off += g->advance; -} - -void display_string_at(int x_off, int y_off, const char *string) -{ - int i = 0; - while (string[i]) { - display_char_at(&x_off, y_off, string[i]); - i++; - } -} - -void display_update() -{ - static uint16_t count = 0; - - // for (size_t x = 0; x < DISPLAY_WIDTH / 8; x++) { - // for (size_t y = 0; y < DISPLAY_HEIGHT; y++) { - // display_set_byte(&buffer, (x << 3), y, (((y + count) >> 4) & 1) ? 0xFF : 0); - // } - // } - - display_string_at(0, 0, "Hello world!"); - count++; + CLR(GPIOA->OTYPER, GPIO_OTYPER_OT_7); + CLR(GPIOA->PUPDR, GPIO_PUPDR_PUPD7); } int main() { /** Enable Port A,B clock */ - RCC->IOPENR |= RCC_IOPENR_IOPAEN; - RCC->IOPENR |= RCC_IOPENR_IOPBEN; + SET(RCC->IOPENR, RCC_IOPENR_IOPAEN); + SET(RCC->IOPENR, RCC_IOPENR_IOPBEN); /** Enable pin P3 for output */ - SET_TO(GPIOB->MODER, GPIO_MODER_MODE3, GPIO_MODER_MODE3_0); + SET_TO(GPIOB->MODER, + GPIO_MODER_MODE3, + GPIO_MODER_MODE3_0); - CLEAR(GPIOB->OTYPER, GPIO_OTYPER_OT_3); - CLEAR(GPIOB->PUPDR, GPIO_PUPDR_PUPD3); + CLR(GPIOB->OTYPER, GPIO_OTYPER_OT_3); + CLR(GPIOB->PUPDR, GPIO_PUPDR_PUPD3); init_lptim_toggler(); - init_spi_display(); - display_buffer_init(&buffer); + display_init(&display, SPI1); + int x = 0; while (1) { - display_update(); - spi_send_blocking(SPI1, (uint8_t *) &buffer, sizeof(buffer)); FLIP(GPIOB->ODR, GPIO_ODR_OD3); - // for (int i = 0; i < 100000; i++); + // for (int i = 0; i < 10000; i++); + display_clear(&display); + display_string_at(&display, 0, font_notomono_10.height * 0, "> Option 1", &font_notomono_10); + display_string_at(&display, 0, font_notomono_10.height * 1, " Option 2", &font_notomono_10); + display_string_at(&display, 0, font_notomono_10.height * 2, " Option 3", &font_notomono_10); + display_refresh(&display); + x++; + if (x == DISPLAY_WIDTH) { + x = 0; + } } }