Skip to content
Snippets Groups Projects
Commit 1d26dfa4 authored by cnlohr's avatar cnlohr
Browse files

Fix warnings + add -Wall

parent 6c06cef6
No related branches found
No related tags found
No related merge requests found
Showing
with 46 additions and 31 deletions
......@@ -897,7 +897,6 @@ int _write(int fd, const char *buf, int size)
if( timeout-- == 0 ) return place;
timeout = 160000;
uint32_t d;
int t = 3;
while( t < tosend )
{
......
......@@ -27,7 +27,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I. -DTINYVECTOR
-I. -DTINYVECTOR -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
No preview for this file type
......@@ -17,7 +17,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I.
-I. -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
......@@ -30,10 +30,10 @@ int main()
{
GPIOD->BSHR = 1 | (1<<4); // Turn on GPIOs
GPIOC->BSHR = 1;
printf( "+%d\n", count++ );
printf( "+%lu\n", count++ );
GPIOD->BSHR = (1<<16) | (1<<(16+4)); // Turn off GPIODs
GPIOC->BSHR = (1<<16);
printf( "-%d\n", count++ );
printf( "-%lu\n", count++ );
count++;
//_write( 0, "xxxxxxx", 7 );
}
......
......@@ -27,7 +27,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I. -DTINYVECTOR
-I. -DTINYVECTOR -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
......@@ -27,7 +27,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I. -DTINYVECTOR
-I. -DTINYVECTOR -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
......@@ -17,7 +17,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I.
-I. -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
......@@ -21,6 +21,7 @@ void SRAMCode( )
"1: c.sw a1, 0(a0)\n"
" c.sw a2, 0(a0)\n"
" j 1b\n" );
__builtin_unreachable();
}
int main()
......
......@@ -17,7 +17,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I.
-I. -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
......@@ -91,7 +91,7 @@ int main()
{
uint32_t rv = ReadCSRSelfModifySimple( i );
if( rv )
printf( "%03x = %08x\n", i, rv );
printf( "%03x = %08lx\n", i, rv );
}
printf( "Done\n" );
for(;;);
......
......@@ -17,7 +17,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I. -DSTDOUT_UART
-I. -DSTDOUT_UART -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
......@@ -29,6 +29,6 @@ int main()
Delay_Ms( 50 );
GPIOD->BSHR = 1<<16; // Turn off GPIOD0
Delay_Ms( 50 );
printf( "Count: %d\n", count++ );
printf( "Count: %lu\n", count++ );
}
}
......@@ -15,7 +15,7 @@ CFLAGS:= \
-I/usr/include/newlib \
-I$(CH32V003FUN) \
-nostdlib \
-I.
-I. -Wall
LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections
......
......@@ -7,7 +7,9 @@
#ifndef _COLOR_UTILITIES_H
#define _COLOR_UTILITIES_H
// To stop warnings about unused functions.
static uint32_t EHSVtoHEX( uint8_t hue, uint8_t sat, uint8_t val ) __attribute__((used));
static uint32_t TweenHexColors( uint32_t hexa, uint32_t hexb, int tween ) __attribute__((used));
static uint32_t EHSVtoHEX( uint8_t hue, uint8_t sat, uint8_t val )
{
......@@ -136,6 +138,8 @@ static const unsigned char sintable[] = {
static uint32_t TweenHexColors( uint32_t hexa, uint32_t hexb, int tween )
{
if( tween <= 0 ) return hexa;
if( tween >= 255 ) return hexb;
int32_t aamt = 255-tween;
int32_t bamt = tween;
int32_t hab = hexa & 0xff;
......
......@@ -34,14 +34,14 @@ uint32_t WS2812BLEDCallback( int ledno );
#ifdef WS2812DMA_IMPLEMENTATION
// Note first 2 LEDs of DMA Buffer are 0's as a "break"
// Must be divisble by 4.
#define DMALEDS 16
// Note first n LEDs of DMA Buffer are 0's as a "break"
// Need one extra LED at end to leave line high.
// This must be greater than WS2812B_RESET_PERIOD.
// 1: Divisble by 2.
// 2:
#define DMALEDS 16
#define WS2812B_RESET_PERIOD 2
#define DMA_BUFFER_LEN (((DMALEDS+1)/2)*6)
#define DMA_BUFFER_LEN (((DMALEDS)/2)*6) // The +1 is for the buffered start.
static uint16_t WS2812dmabuff[DMA_BUFFER_LEN];
static volatile int WS2812LEDs;
......@@ -98,12 +98,22 @@ static void WS2812FillBuffSec( uint16_t * ptr, int numhalfwords, int tce )
// Use a LUT to figure out how we should set the SPI line.
uint32_t ledval24bit = WS2812BLEDCallback( place++ );
#ifdef WSRBG
ptr[0] = bitquartets[(ledval24bit>>12)&0xf];
ptr[1] = bitquartets[(ledval24bit>>8)&0xf];
ptr[2] = bitquartets[(ledval24bit>>20)&0xf];
ptr[3] = bitquartets[(ledval24bit>>16)&0xf];
ptr[4] = bitquartets[(ledval24bit>>4)&0xf];
ptr[5] = bitquartets[(ledval24bit>>0)&0xf];
#else
ptr[0] = bitquartets[(ledval24bit>>20)&0xf];
ptr[1] = bitquartets[(ledval24bit>>16)&0xf];
ptr[2] = bitquartets[(ledval24bit>>12)&0xf];
ptr[3] = bitquartets[(ledval24bit>>8)&0xf];
ptr[4] = bitquartets[(ledval24bit>>4)&0xf];
ptr[5] = bitquartets[(ledval24bit>>0)&0xf];
#endif
ptr += 6;
i += 6;
}
......@@ -122,12 +132,12 @@ void DMA1_Channel3_IRQHandler( void )
// Clear all possible flags.
DMA1->INTFCR = DMA1_IT_GL3;
if( intfr & DMA1_IT_HT3 )
if( intfr & DMA1_IT_TC3 )
{
// Halfwaay (Fill in first part)
WS2812FillBuffSec( WS2812dmabuff, DMA_BUFFER_LEN / 2, 1 );
}
if( intfr & DMA1_IT_TC3 )
if( intfr & DMA1_IT_HT3 )
{
// Complete (Fill in second part)
WS2812FillBuffSec( WS2812dmabuff + DMA_BUFFER_LEN / 2, DMA_BUFFER_LEN / 2, 0 );
......@@ -164,7 +174,7 @@ void WS2812BDMAInit( )
// MOSI, Configure GPIO Pin
GPIOC->CFGLR &= ~(0xf<<(4*6));
GPIOC->CFGLR |= (GPIO_Speed_50MHz | GPIO_CNF_OUT_PP_AF)<<(4*6);
GPIOC->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP_AF)<<(4*6);
// Configure SPI
SPI1->CTLR1 =
......
......@@ -7,16 +7,17 @@
#include <string.h>
#define WS2812DMA_IMPLEMENTATION
#define WSRBG //For WS2816C's.
#define NR_LEDS 191
#include "ws2812b_dma_spi_led_driver.h"
#include "color_utilities.h"
#define NR_LEDS 191
uint16_t phases[NR_LEDS];
int frameno;
volatile int tween = 0;
volatile int tween = -NR_LEDS;
// Callbacks that you must implement.
uint32_t WS2812BLEDCallback( int ledno )
......@@ -24,11 +25,11 @@ uint32_t WS2812BLEDCallback( int ledno )
uint8_t index = (phases[ledno])>>8;
uint8_t rsbase = sintable[index];
uint8_t rs = rsbase>>3;
uint32_t fire = huetable[(rs+190&0xff)] | (huetable[(rs+30&0xff)]<<8) | (huetable[(rs+0)]<<16);
uint32_t ice = 0xff | ((rsbase)<<8) | ((rsbase)<<16);
uint32_t fire = (huetable[(rs+190)&0xff]<<16) | (huetable[(rs+30)&0xff]) | (huetable[(rs+0)]<<8);
uint32_t ice = 0xff0000 | ((rsbase)<<8) | ((rsbase));
// Because this chip doesn't natively support multiplies, this can be very slow.
return TweenHexColors( fire, ice, tween ); // Where "tween" is a value from 0 ... 255
// Because this chip doesn't natively support multiplies, we are going to avoid tweening of 1..254.
return TweenHexColors( fire, ice, ((tween + ledno)>0)?255:0 ); // Where "tween" is a value from 0 ... 255
}
int main()
......@@ -65,11 +66,11 @@ int main()
if( frameno == 1024 )
{
tweendir = 4;
tweendir = 1;
}
if( frameno == 2048 )
{
tweendir = -4;
tweendir = -1;
frameno = 0;
}
......@@ -77,7 +78,7 @@ int main()
{
int t = tween + tweendir;
if( t > 255 ) t = 255;
if( t < 0 ) t = 0;
if( t < -NR_LEDS ) t = -NR_LEDS;
tween = t;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment