Skip to content

Instantly share code, notes, and snippets.

@Caustic
Created March 7, 2013 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Caustic/5112557 to your computer and use it in GitHub Desktop.
Save Caustic/5112557 to your computer and use it in GitHub Desktop.
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/usart.h>
#include "lcd.h"
#include "mystrlen.h"
void printlcd(char *message)
{
int len, i;
len = mystrlen(message);
for (i=0; i<len; i++){
usart_send_blocking(USART1, message[i]); /* USART1: Send byte. */
}
}
void clearlcd(void)
{
usart_send_blocking(USART1, LCD_LF); /* Linefeed */
usart_send_blocking(USART1, LCD_LF); /* Linefeed */
usart_send_blocking(USART1, LCD_HOME);
}
#ifndef LCD_H
#define LCD_H
#define LCD_LF '\012'
#define LCD_HOME '\001'
void printlcd(char *message);
void clearlcd(void);
#endif
##
## This file is part of the libopencm3 project.
##
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
##
## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This library 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 Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this library. If not, see <http://www.gnu.org/licenses/>.
##
OBJS += mystrlen.o lcd.o
BINARY = usart
LDSCRIPT = $(OPENCM3_DIR)/examples/stm32/f1/stm32vl-discovery/stm32vl-discovery.ld
include $(OPENCM3_DIR)/examples/stm32/f1/Makefile.include
mystrlen.o: mystrlen.h mystrlen.c
arm-none-eabi-gcc -Wall -pedantic -g -c -o mystrlen.o mystrlen.c -DSTM32F1
lcd.o: lcd.h lcd.c
arm-none-eabi-gcc -Wall -pedantic -g -c -o lcd.o lcd.c -DSTM32F1
#ifndef MYSTRLEN_H
#define MYSTRLEN_H
int mystrlen(char *string);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment