Skip to content
Snippets Groups Projects
Commit 519c22ed authored by Henrik Tjäder's avatar Henrik Tjäder
Browse files

Added a very empty but compiling source

parent 9c4616cb
No related branches found
No related tags found
No related merge requests found
/**
*****************************************************************************
**
** File : main.c
**
** Abstract : main function.
**
** Functions : main
**
** Environment : GNU GDB and Vim or Atollic TrueSTUDIO(R)
** STMicroelectronics STM32F4xx Standard Peripherals Library
**
** Distribution: The file is distributed "as is", without any warranty
** of any kind.
**
*****************************************************************************
*/
/* Includes */
#include "stm32f4xx.h"
#include "stdio.h" // snprintf()
#include <string.h> // memcpy()
//***************************************************************************
int main(void)
{
// Setup clocks
__enable_irq();
/* Infinite loop */
while (1)
{
/* Not a regular busy wait, "Wait For Interrupt" */
__WFI();
}
}
This diff is collapsed.
This diff is collapsed.
/**
******************************************************************************
* @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_conf.h
* @author MCD Application Team
* @version V1.1.0
* @date 18-January-2013
* @brief Library configuration file.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_CONF_H
#define __STM32F4xx_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Uncomment the line below to enable peripheral header file inclusion */
#include "stm32f4xx_adc.h"
#include "stm32f4xx_can.h"
#include "stm32f4xx_crc.h"
#include "stm32f4xx_cryp.h"
#include "stm32f4xx_dac.h"
#include "stm32f4xx_dbgmcu.h"
#include "stm32f4xx_dcmi.h"
#include "stm32f4xx_dma.h"
#include "stm32f4xx_exti.h"
#include "stm32f4xx_flash.h"
#include "stm32f4xx_fsmc.h"
#include "stm32f4xx_hash.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_i2c.h"
#include "stm32f4xx_iwdg.h"
#include "stm32f4xx_pwr.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_rng.h"
#include "stm32f4xx_rtc.h"
#include "stm32f4xx_sdio.h"
#include "stm32f4xx_spi.h"
#include "stm32f4xx_syscfg.h"
#include "stm32f4xx_tim.h"
#include "stm32f4xx_usart.h"
#include "stm32f4xx_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* If an external clock source is used, then the value of the following define
should be set to the value of the external clock source, else, if no external
clock is used, keep this define commented */
/*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32F4xx_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file Project/STM32F4xx_StdPeriph_Template/stm32f4xx_it.c
* @author MCD Application Team
* @version V1.1.0
* @date 18-January-2013
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_it.h"
/** @addtogroup Template_Project
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSVC exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
/* TimingDelay_Decrement(); */
}
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32f40xx.s/startup_stm32f427x.s). */
/******************************************************************************/
/**
* @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
*****************************************************************************
**
** File : stm32f4xx_it.h
**
** Abstract : Main Interrupt Service Routines.
** This file provides template for all exceptions handler and
** peripherals interrupt service routine.
**
** STMicroelectronics STM32F4xx Standard Peripherals Library
**
** Distribution: The file is distributed "as is", without any warranty
** of any kind.
**
*****************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_IT_H
#define __STM32F4xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_IT_H */
/**
*****************************************************************************
**
** File : syscalls.c
**
** Abstract : Minimal System calls file
**
** For more information about which c-functions
** need which of these lowlevel functions
** please consult the Newlib libc-manual
**
** Distribution: The file is distributed "as is", without any warranty
** of any kind.
**
*****************************************************************************
*/
/* Includes */
#include <stdint.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
/* Variables */
#undef errno
extern int32_t errno;
register uint8_t * stack_ptr asm("sp");
uint8_t *__env[1] = { 0 };
uint8_t **environ = __env;
/* Functions */
void initialise_monitor_handles()
{
}
int _getpid(void)
{
return 1;
}
int _kill(int32_t pid, int32_t sig)
{
errno = EINVAL;
return -1;
}
void _exit (int32_t status)
{
_kill(status, -1);
while (1) {} /* Make sure we hang here */
}
int _write(int32_t file, uint8_t *ptr, int32_t len)
{
/* Implement your write code here, this is used by puts and printf for example */
return len;
}
caddr_t _sbrk(int32_t incr)
{
extern uint8_t end asm("end");
static uint8_t *heap_end;
uint8_t *prev_heap_end;
if (heap_end == 0)
heap_end = &end;
prev_heap_end = heap_end;
if (heap_end + incr > stack_ptr)
{
// write(1, "Heap and stack collision\n", 25);
// abort();
errno = ENOMEM;
return (caddr_t) -1;
}
heap_end += incr;
return (caddr_t) prev_heap_end;
}
int _close(int32_t file)
{
return -1;
}
int _fstat(int32_t file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int _isatty(int32_t file)
{
return 1;
}
int _lseek(int32_t file, int32_t ptr, int32_t dir)
{
return 0;
}
int _read(int32_t file, uint8_t *ptr, int32_t len)
{
return 0;
}
int _open(const uint8_t *path, int32_t flags, int32_t mode)
{
/* Pretend like we always fail */
return -1;
}
int _wait(int32_t *status)
{
errno = ECHILD;
return -1;
}
int _unlink(const uint8_t *name)
{
errno = ENOENT;
return -1;
}
int _times(struct tms *buf)
{
return -1;
}
int _stat(const uint8_t *file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int _link(const uint8_t *old, const uint8_t *new)
{
errno = EMLINK;
return -1;
}
int _fork(void)
{
errno = EAGAIN;
return -1;
}
int _execve(const uint8_t *name, uint8_t * const *argv, uint8_t * const *env)
{
errno = ENOMEM;
return -1;
}
This diff is collapsed.
/**
*****************************************************************************
**
** File : tiny_printf.c
**
** Abstract : Minimal iprintf/siprintf/fiprintf
** and puts/fputs.
** Provides aliased declarations for printf/sprintf/fprintf
** pointing to *iprintf variants.
**
** The argument contains a format string that may include
** conversion specifications. Each conversion specification
** is introduced by the character %, and ends with a
** conversion specifier.
**
** The following conversion specifiers are supported
** cdisuxX%
**
** Usage:
** c character
** d,i signed integer (-sign added, + sign not supported)
** s character string
** u unsigned integer as decimal
** x,X unsigned integer as hexadecimal (uppercase letter)
** % % is written (conversion specification is '%%')
**
** Note:
** Character padding is not supported
**
** Distribution: The file is distributed "as is", without any warranty
** of any kind.
**
**
*****************************************************************************
*/
/* Includes */
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
/* Create aliases for *printf to integer variants *iprintf */
__attribute__ ((alias("iprintf"))) int printf(const char *fmt, ...);
__attribute__ ((alias("fiprintf"))) int fprintf(FILE* fp, const char *fmt, ...);
__attribute__ ((alias("siprintf"))) int sprintf(char* str, const char *fmt, ...);
/* External function prototypes (defined in syscalls.c) */
extern int _write(int fd, char *str, int len);
/* Private function prototypes */
void ts_itoa(char **buf, unsigned int d, int base);
int ts_formatstring(char *buf, const char *fmt, va_list va);
int ts_formatlength(const char *fmt, va_list va);
/* Private functions */
/**
**---------------------------------------------------------------------------
** Abstract: Convert integer to ascii
** Returns: void
**---------------------------------------------------------------------------
*/
void ts_itoa(char **buf, unsigned int d, int base)
{
int div = 1;
while (d/div >= base)
div *= base;
while (div != 0)
{
int num = d/div;
d = d%div;
div /= base;
if (num > 9)
*((*buf)++) = (num-10) + 'A';
else
*((*buf)++) = num + '0';
}
}
/**
**---------------------------------------------------------------------------
** Abstract: Writes arguments va to buffer buf according to format fmt
** Returns: Length of string
**---------------------------------------------------------------------------
*/
int ts_formatstring(char *buf, const char *fmt, va_list va)
{
char *start_buf = buf;
while(*fmt)
{
/* Character needs formating? */
if (*fmt == '%')
{
switch (*(++fmt))
{
case 'c':
*buf++ = va_arg(va, int);
break;
case 'd':
case 'i':
{
signed int val = va_arg(va, signed int);
if (val < 0)
{
val *= -1;
*buf++ = '-';
}
ts_itoa(&buf, val, 10);
}
break;
case 's':
{
char * arg = va_arg(va, char *);
while (*arg)
{
*buf++ = *arg++;
}
}
break;
case 'u':
ts_itoa(&buf, va_arg(va, unsigned int), 10);
break;
case 'x':
case 'X':
ts_itoa(&buf, va_arg(va, int), 16);
break;
case '%':
*buf++ = '%';
break;
}
fmt++;
}
/* Else just copy */
else
{
*buf++ = *fmt++;
}
}
*buf = 0;
return (int)(buf - start_buf);
}
/**
**---------------------------------------------------------------------------
** Abstract: Calculate maximum length of the resulting string from the
** format string and va_list va
** Returns: Maximum length
**---------------------------------------------------------------------------
*/
int ts_formatlength(const char *fmt, va_list va)
{
int length = 0;
while (*fmt)
{
if (*fmt == '%')
{
++fmt;
switch (*fmt)
{
case 'c':
va_arg(va, int);
++length;
break;
case 'd':
case 'i':
case 'u':
/* 32 bits integer is max 11 characters with minus sign */
length += 11;
va_arg(va, int);
break;
case 's':
{
char * str = va_arg(va, char *);
while (*str++)
++length;
}
break;
case 'x':
case 'X':
/* 32 bits integer as hex is max 8 characters */
length += 8;
va_arg(va, unsigned int);
break;
default:
++length;
break;
}
}
else
{
++length;
}
++fmt;
}
return length;
}
/**
**===========================================================================
** Abstract: Loads data from the given locations and writes them to the
** given character string according to the format parameter.
** Returns: Number of bytes written
**===========================================================================
*/
int siprintf(char *buf, const char *fmt, ...)
{
int length;
va_list va;
va_start(va, fmt);
length = ts_formatstring(buf, fmt, va);
va_end(va);
return length;
}
/**
**===========================================================================
** Abstract: Loads data from the given locations and writes them to the
** given file stream according to the format parameter.
** Returns: Number of bytes written
**===========================================================================
*/
int fiprintf(FILE * stream, const char *fmt, ...)
{
int length = 0;
va_list va;
va_start(va, fmt);
length = ts_formatlength(fmt, va);
va_end(va);
{
char buf[length];
va_start(va, fmt);
length = ts_formatstring(buf, fmt, va);
length = _write(stream->_file, buf, length);
va_end(va);
}
return length;
}
/**
**===========================================================================
** Abstract: Loads data from the given locations and writes them to the
** standard output according to the format parameter.
** Returns: Number of bytes written
**
**===========================================================================
*/
int iprintf(const char *fmt, ...)
{
int length = 0;
va_list va;
va_start(va, fmt);
length = ts_formatlength(fmt, va);
va_end(va);
{
char buf[length];
va_start(va, fmt);
length = ts_formatstring(buf, fmt, va);
length = _write(1, buf, length);
va_end(va);
}
return length;
}
/**
**===========================================================================
** Abstract: fputs writes the string at s (but without the trailing null) to
** the file or stream identified by fp.
** Returns: If successful, the result is 0; otherwise, the result is EOF.
**
**===========================================================================
*/
int fputs(const char *s, FILE *fp)
{
int length = strlen(s);
int wlen = 0;
int res;
wlen = _write((fp->_file), (char*)s, length);
wlen += _write((fp->_file), "\n", 1);
if (wlen == (length+1))
{
res = 0;
}
else
{
res = EOF;
}
return res;
}
/**
**===========================================================================
** Abstract: puts writes the string at s (followed by a newline, instead of
** the trailing null) to the standard output stream.
** Returns: If successful, the result is a nonnegative integer; otherwise,
** the result is EOF.
**
**===========================================================================
*/
int puts(const char *s)
{
int length = strlen(s);
int numbytes = 0;
int res;
numbytes = _write(1, (char*)s, length);
numbytes += _write(1, "\n", 1);
if (numbytes == (length+1))
{
res = 0;
}
else
{
res = EOF;
}
return res;
}
/**
**===========================================================================
** Abstract: Copy, starting from the memory location buf, count elements
** (each of size size) into the file or stream identified by fp.
** Returns: Number of elements written
**
**===========================================================================
*/
size_t fwrite(const void * buf, size_t size, size_t count, FILE * fp)
{
return (_write((fp->_file), (char*)buf, size * count) / size);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment