Compare commits

..

No commits in common. "64e1a0c83df28fdbfd14b40fc2883c69b690453a" and "eb0ca60aa12d7f8bad3d7d5b361cf8ed6c5750c3" have entirely different histories.

4 changed files with 3 additions and 75 deletions

View File

@ -8,7 +8,6 @@
//--includes-------------------------------------------------------------------- //--includes--------------------------------------------------------------------
#include "dma_cbuf.h" #include "dma_cbuf.h"
#include "error.h"
//--local definitions----------------------------------------------------------- //--local definitions-----------------------------------------------------------
@ -32,9 +31,7 @@ void dma_cbuf_configure(volatile struct DmaCircBuffer* buffer,
const struct DmaParam* param, enum DmaConfig priority, const struct DmaParam* param, enum DmaConfig priority,
volatile void* raw_buffer, uint16_t buffer_size) volatile void* raw_buffer, uint16_t buffer_size)
{ {
error_assert(buffer != nullptr); #warning "check for null ptr"
error_assert(param != nullptr);
error_assert(raw_buffer != nullptr);
buffer->buffer = raw_buffer; buffer->buffer = raw_buffer;
@ -55,9 +52,6 @@ void dma_cbuf_configure(volatile struct DmaCircBuffer* buffer,
uint32_t dma_cbuf_read_byte(volatile struct DmaCircBuffer* buffer, uint32_t dma_cbuf_read_byte(volatile struct DmaCircBuffer* buffer,
uint8_t* byte) uint8_t* byte)
{ {
error_assert(buffer != nullptr);
error_assert(byte != nullptr);
//retreive the current end of the buffer based on the DMA's progress //retreive the current end of the buffer based on the DMA's progress
uint16_t end = buffer->size uint16_t end = buffer->size
- dma_get_remaining(buffer->dma, buffer->channel); - dma_get_remaining(buffer->dma, buffer->channel);
@ -92,8 +86,6 @@ uint32_t dma_cbuf_read_byte(volatile struct DmaCircBuffer* buffer,
static void cbuf_callback(enum DmaIRQSource src, volatile void* param) static void cbuf_callback(enum DmaIRQSource src, volatile void* param)
{ {
(void)src; //only transfer complete expected (void)src; //only transfer complete expected
error_assert(param != nullptr);
volatile struct DmaCircBuffer* buffer = param; volatile struct DmaCircBuffer* buffer = param;
buffer->dma_looped = true; buffer->dma_looped = true;
} }

View File

@ -8,7 +8,6 @@
//--includes-------------------------------------------------------------------- //--includes--------------------------------------------------------------------
#include "dma_mbuf.h" #include "dma_mbuf.h"
#include "error.h"
//--local definitions----------------------------------------------------------- //--local definitions-----------------------------------------------------------
@ -31,9 +30,7 @@ void dma_mbuf_configure(volatile struct DmaMultiBuffer* buffer,
const struct DmaParam* param, enum DmaConfig priority, const struct DmaParam* param, enum DmaConfig priority,
void* raw_buffer, uint16_t buffer_size) void* raw_buffer, uint16_t buffer_size)
{ {
error_assert(buffer != nullptr); #warning "check for null ptr"
error_assert(param != nullptr);
error_assert(raw_buffer != nullptr);
buffer->raw_buffer = raw_buffer; buffer->raw_buffer = raw_buffer;
@ -54,8 +51,6 @@ void dma_mbuf_configure(volatile struct DmaMultiBuffer* buffer,
uint32_t dma_mbuf_write_byte(volatile struct DmaMultiBuffer* buffer, uint32_t dma_mbuf_write_byte(volatile struct DmaMultiBuffer* buffer,
uint8_t byte) uint8_t byte)
{ {
error_assert(buffer != nullptr);
//if the current buffer is full, give up //if the current buffer is full, give up
if (buffer->byte_index >= buffer->buffer_size) { if (buffer->byte_index >= buffer->buffer_size) {
return 1; return 1;
@ -70,8 +65,6 @@ uint32_t dma_mbuf_write_byte(volatile struct DmaMultiBuffer* buffer,
uint32_t dma_mbuf_switch(volatile struct DmaMultiBuffer* buffer) uint32_t dma_mbuf_switch(volatile struct DmaMultiBuffer* buffer)
{ {
error_assert(buffer != nullptr);
//no data to send, stop here //no data to send, stop here
if (buffer->byte_index == 0) { if (buffer->byte_index == 0) {
return 0; return 0;
@ -107,8 +100,6 @@ uint32_t dma_mbuf_switch(volatile struct DmaMultiBuffer* buffer)
static void mbuf_callback(enum DmaIRQSource src, volatile void* param) static void mbuf_callback(enum DmaIRQSource src, volatile void* param)
{ {
(void)src; //only transfer complete expected (void)src; //only transfer complete expected
error_assert(param != nullptr);
volatile struct DmaMultiBuffer* buffer = param; volatile struct DmaMultiBuffer* buffer = param;
dma_stop(buffer->dma, buffer->channel); dma_stop(buffer->dma, buffer->channel);
buffer->dma_running = false; buffer->dma_running = false;

View File

@ -1,50 +0,0 @@
/** @file error.h
* Module providing error handling macros
*
* The module implements the assert macro intended to allow catching critical
* errors during debug while having no influence in the release code as well as
* multiple tool macros to handles other kinds of errors
*/
#ifndef _ERROR_H_
#define _ERROR_H_
//--includes--------------------------------------------------------------------
#include "debug.h"
#define ERROR_ASSERT 1
//--type definitions------------------------------------------------------------
#define error_to_string(arg) #arg
#if ERROR_ASSERT
#define error_assert(cond) \
do { \
if (!(cond)) { \
debug_error("%s:l%u:%s: %s", __FILE__, __LINE__, __func__, \
error_to_string(cond)); \
while (true) {} \
} \
} while (0)
#else
#define error_assert(cond) do {} while (0)
#endif
#if ERROR_ASSERT
#define error_trigger(msg, ...) \
do { \
debug_error(msg __VA_OPT__(,) __VA_ARGS__); \
while (true) {} \
} while (0)
#else
#define error_trigger(msg) do {} while (0)
#endif
//--functions-------------------------------------------------------------------
#endif //_ERROR_H_

View File

@ -7,7 +7,6 @@
//--includes-------------------------------------------------------------------- //--includes--------------------------------------------------------------------
#include "format.h" #include "format.h"
#include "error.h"
//--local definitions----------------------------------------------------------- //--local definitions-----------------------------------------------------------
@ -69,8 +68,6 @@ uint32_t format_vfctprintf(FormatCallback callback, void* arg,
*/ */
static uint32_t buffer_write(uint8_t byte, void* arg) static uint32_t buffer_write(uint8_t byte, void* arg)
{ {
error_assert(arg != nullptr);
struct BufferArg* buffer_arg = (struct BufferArg*)arg; struct BufferArg* buffer_arg = (struct BufferArg*)arg;
if (buffer_arg->byte_index >= buffer_arg->buffer_size) { if (buffer_arg->byte_index >= buffer_arg->buffer_size) {
return 1; return 1;
@ -90,8 +87,6 @@ static uint32_t buffer_write(uint8_t byte, void* arg)
static uint32_t render_format(FormatCallback callback, void* arg, static uint32_t render_format(FormatCallback callback, void* arg,
const char* restrict format, va_list va) const char* restrict format, va_list va)
{ {
error_assert(format != nullptr);
uint8_t width = 0; uint8_t width = 0;
bool in_format = false; bool in_format = false;
bool zero_padding = false; bool zero_padding = false;
@ -153,7 +148,7 @@ static uint32_t render_format(FormatCallback callback, void* arg,
width += (*c - '0'); width += (*c - '0');
continue; continue;
default: default:
error_trigger("unsupported option: %c in %s", c, format); //TODO manage error
break; break;
} }
} else { } else {