This is a part of the Kinetiszer project.
Revision 0:5a419ba2726d, committed 2014-10-28
- Comitter:
- Clemo
- Date:
- Tue Oct 28 12:19:22 2014 +0000
- Commit message:
- Error & warning free (I believe as I don't know how to clean).
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/amplitude.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,29 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __AMPLITUDE_H__ +#define __AMPLITUDE_H__ + + +void Amplitude_Process(void); +void Amplitude_Let_LFOAmt(byte newamt); +byte Amplitude_Get_LFOAmt(void); +byte Amplitude_Get_LFOGain(void); + + +#endif // __AMPLITUDE_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arpeggiator.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,47 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#ifndef __ARPEGGIATOR_H__ +#define __ARPEGGIATOR_H__ + + +//****THIS IS WHERE THE ARPEGGIATOR PATTERNS ARE STORED******* +//The way its is by up the notes currently being held down +//So if C,D,E,F,G were held down and pattern was {5,3,2,4,1}, +//the arp would be G,E,D,F,C. Minus nums count downwards + +#define PATLEN 16 + +extern const signed char arp_patstore[16][16]; + + +void Arp_Let_Type(byte newpat); +byte Arp_Get_Type(void); +void Arp_Let_Speed(unsigned int newspeed); +unsigned int Arp_Get_Speed(void); +void Arp_Let_PingPong(boolean newpingpong); +boolean Arp_Get_PingPong(void); +void Arp_Reset(void); +void Arp_Poll(void); +void Arp_TriggerStep(void); +byte Arp_FindNote(signed char pos); +void Arp_IncPatPos(void); + + +#endif // __ARPEGGIATOR_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atmegatron.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,113 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __ATMEGATRON_H__ +#define __ATMEGATRON_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define __HAS_ARPEGGIATOR__ + + +#include <stdint.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + + +typedef uint8_t byte; +typedef bool boolean; +typedef uint8_t uchar; +typedef int8_t sample_t; + + +#define MEM_PATCHSIZE (19) //size of flash mem patch +#define CTRL_FILT (0) //digital control nums +#define CTRL_Q (1) +#define CTRL_ENV (2) +#define CTRL_LFO (3) +#define CTRL_AMP (4) +#define CTRL_FX (5) +#define FUNC_WAVE (0) //function nums +#define FUNC_FILT (1) +#define FUNC_FENVA (2) +#define FUNC_FENVDR (3) +#define FUNC_FENVS (4) +#define FUNC_AENVA (5) +#define FUNC_AENVD (6) +#define FUNC_AENVS (7) +#define FUNC_AENVR (8) +#define FUNC_LFOTYPE (9) +#define FUNC_LFOSPEED (10) + +#ifdef __HAS_ARPEGGIATOR__ +#define FUNC_ARPTYPE (11) +#define FUNC_ARPSPEED (12) +#include "arpeggiator.h" +#endif // __HAS_ARPEGGIATOR__ + +#define FUNC_PORTA (13) +#define FUNC_BITCRUSH (14) +#define FUNC_MEM (15) +#define WAVE_LEN (32) //length of wavetable +#define POLL_HARD (1) //poll the function/val dials and digital controls +#define POLL_MIDI (1) //poll the midi input +#define POLL_TEST (0) //test mode + +#define FUNC_MAX (16) +#define CTRL_MAX (6) +#define RED false +#define GREEN true + + +#include "systick.h" +#include "util.h" +#include "serial.h" +#include "keyboard.h" +#include "eeprom.h" +#include "master.h" +#include "waveforms.h" +#include "distortion.h" +#include "flange.h" +#include "bitcrush.h" +#include "lfo.h" +#include "filter.h" +#include "amplitude.h" +#include "envelope.h" +#include "envelope2.h" +#include "pwm.h" +#include "midi.h" +#include "pitch.h" +#include "memory.h" +#include "hardware.h" +#include "testmode.h" +#include "user_interface.h" + +void setup(void); +void loop_priority_low(void); +void loop_priority_high(void); + +#ifdef __cplusplus +} +#endif + + +#endif // __ATMEGATRON_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bitcrush.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,32 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//*******THIS IS THE WAVE CRUSHER*************** + +#ifndef __BITCRUSHER_H__ +#define __BITCRUSHER_H__ + + +void BitCrush_Let_Type(byte newtype); +byte BitCrush_Get_Type(void); +void BitCrush_Let_PreFilt(boolean newprefilt); +boolean BitCrush_Get_PreFilt(void); +void BitCrush_Process(void); + + +#endif // __BITCRUSHER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distortion.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,30 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +// Very simple clipping distortion + +#ifndef __DISTORTION_H__ +#define __DISTORTION_H__ + + +void Distortion_Let_Amt(byte newamt); +byte Distortion_Get_Amt(void); +void Distortion_Process(void); + + +#endif // __DISTORTION_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,16 @@ +#ifndef __EEPROM_H__ +#define __EEPROM_H__ + + +// TODO: replace this structure by external EEPROM chip driver. +typedef struct +{ + void (*write)(uint32_t address, uint8_t value); + uint8_t (*read)(uint32_t address); +} +eeprom_t; + +extern eeprom_t EEPROM; + + +#endif // __EEPROM_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/envelope.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,40 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//******UNIPOLAR ENVELOPE - for amplitude*********** + +#ifndef __ENVELOPE_H__ +#define __ENVELOPE_H__ + + +void Aenv_Let_A(int newA); +int Aenv_Get_A(void); +void Aenv_Let_D(int newD); +int Aenv_Get_D(void); +void Aenv_Let_S(byte newS); +byte Aenv_Get_S(void); +void Aenv_Let_R(int newR); +int Aenv_Get_R(void); +byte Aenv_Get_State(void); +byte Aenv_Get_Level(void); +void AEnv_Trigger(void); +void AEnv_Release(void); +void AEnv_CalcVal(void); + + +#endif // __ENVELOPE_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/envelope2.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,39 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//******PIBOLAR ENVELOPE - for filter and pitch*********** + +#ifndef __ENVELOPE_2_H__ +#define __ENVELOPE_2_H__ + + +void Fenv_Let_A(int newA); +int Fenv_Get_A(void); +void Fenv_Let_DR(int newDR); +int Fenv_Get_DR(void); +void Fenv_Let_S(signed char newS); +signed char Fenv_Get_S(void); +void Fenv_Let_Invert(boolean newinv); +boolean Fenv_Get_Invert(void); +signed char Fenv_Get_Level(void); +void FEnv_Trigger(void); +void FEnv_Release(void); +void FEnv_CalcVal(void); + + +#endif // __ENVELOPE_2_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filter.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,89 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//***15 Biquad filter algorithms*** + +#ifndef __FILTER_H__ +#define __FILTER_H__ + + +//the filter types +#define FILT_OFF 0 +#define FILT_LPF 1 +#define FILT_HPF 2 +#define FILT_BPF 3 +#define FILT_NOTCH 4 +#define FILT_PEAK10 5 +#define FILT_PEAK30 6 +#define FILT_PEAK100 7 +#define FILT_LS10 8 +#define FILT_LS30 9 +#define FILT_HS10 10 +#define FILT_HS30 11 +#define FILT_BUTLPF 12 +#define FILT_BUTHPF 13 +#define FILT_BESLPF 14 +#define FILT_BESHPF 15 + +//These constants are used to define the MAXIMUM amount the env and lfo can effect the filter cutoff. +//The default max (for both env and lfo) is: +//********multiplier = 4*********** +#define FILT_MAX 1.386294361119891f //ln(multiplier) +#define FILT_MULT 64 //multipler used for calculating lookup table (256 / multiplier) +#define FILT_BS 6UL //bitshift amount when multiplying fc by filt lfo amt. log2(FILT_MULT) + +#define SQRT2 1.414213562373095f //squareroot 2 - useful! +#define PI 3.141592653589793f + +#define MINQ 0.5f //minimum value of Q (default = 0.5) +#define MULTQ 0.076470588235294f //multiplier to convert from filt_q(0-255) to real Q (0.5-20) = (20 - 0.5)/255; + +#define abs(a) (a)>=0? (a) : -(a) + + +void Filt_Let_Fc(byte newfc); +byte Filt_Get_Fc(void); +void Filt_Let_Q(byte newq); +byte Filt_Get_Q(void); +void Filt_Let_Type(byte newtype); +byte Filt_Get_Type(void); +void Filt_Let_GainAdj(boolean newadj); +boolean Filt_Get_GainAdj(void); +void Filt_CalcVals(void); +void LPValCalculator(void); +void HPValCalculator(void); +void BPSkirtValCalculator(void); +void NotchValCalculator(void); +void PeakingEQValCalculator(void); +void LowShelfValCalculator(void); +void HighShelfValCalculator(void); +void ButterworthLPCalculator(void); +void ButterworthHPCalculator(void); +void BesselLPCalculator(void); +void BesselHPCalculator(void); +void Filt_Process(void); +float Biquad_process(float bi0); +void Filt_Let_LFOAmt(byte newamt); +byte Filt_Get_LFOAmt(void); +byte Filt_Get_LFOGain(void); +void Filt_Let_FenvAmt(byte newamt); +byte Filt_Get_FenvAmt(void); +byte Filt_Get_FenvGain(void); + + +#endif // __FILTER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flange.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,33 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//*******PHASER - referred to as Flanger in code*************** +//Adds delayed copy of waveform to output + feedback + +#ifndef __FLANGER_H__ +#define __FLANGER_H__ + + +void Flange_Let_LFOAmt(byte newamt); +byte Flange_Get_LFOAmt(void); +void Flange_Process(void); +void Flange_ClearBuffer(void); +void Flange_Process_Channel2(void); // CPV + + +#endif // __FLANGER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hardware.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,25 @@ +#ifndef __HARDWARE_PORT_H__ +#define __HARDWARE_PORT_H__ + + +#define HIGH (1) +#define LOW (0) + + +void Init_Hardware(void); +void Hardware_Poll(void); +void Hardware_Let_Ctrl(byte shift, byte index, byte value); +byte Hardware_Get_Ctrl(byte shift, byte index); +byte Hardware_Get_Ctrl_Shift(void); +void Hardware_Let_Function(byte newfunc); +byte Hardware_Get_Function(void); +void Hardware_Let_Value(byte func, byte newval); +byte Hardware_Get_Value(byte func); +void Hard_Let_Shift(byte func, boolean newshift); +boolean Hard_Get_Shift(byte func); +void Hardware_LED_SetState(byte LEDnum, byte LEDstate); +void Hardware_LED_StartFlash(byte LEDnum, byte FlashTimes); +void Hardware_BicolorLED_SetState(uint8_t led, uint8_t green, uint8_t red); + + +#endif // __HARDWARE_PORT_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/keyboard.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,80 @@ +#ifndef __KEYBOARD_H__ +#define __KEYBOARD_H__ + + +#include "board.h" + + +typedef enum +{ + key_released = 0, + key_pressed +} +keyboard_key_press_t; + + +typedef struct +{ + int8_t debounce; + keyboard_key_press_t value; + bool changed; +} +keyboard_key_data_t; + + +typedef struct +{ + uint8_t port; + uint8_t pin; + uint8_t function; + keyboard_key_data_t data; +} +keyboard_key_t; + + +typedef struct +{ + uint8_t col_port; + uint8_t col_pin; + uint8_t row_port; + uint8_t row_pin; + keyboard_key_data_t data; +} +keyboard_matrix_key_t; + + +typedef struct +{ + int8_t value; + int8_t state; + uint8_t accelerator; + uint32_t timestamp; + int8_t state_sub; +} +keyboard_rotary_encoder_data_t; + + +#define KEY_DEBOUNCE_MIN (0) +#define KEY_DEBOUNCE_MAX (3) +#define KEY_PERIOD_MIN (10) +#define KEY_PERIOD_MAX (500) + + +void keyboard_init(void); +int8_t keyboard_key_is_debounced(int8_t debounce); +uint8_t keyboard_matrix_key_read(keyboard_matrix_key_t *p_key); +uint8_t keyboard_key_read(keyboard_key_t *p_key); +uint8_t keyboard_key_debounce(int8_t *p_debounce, uint8_t state); +uint32_t keyboard_scan_matrix(void); +uint32_t keyboard_scan_encoders(void); +void keyboard_encoder_speed(keyboard_rotary_encoder_data_t *p_encoder_data); +int8_t keyboard_encoder_tick(keyboard_key_t *p_key_a, keyboard_key_t *p_key_b, keyboard_rotary_encoder_data_t *p_encoder_data); +bool keyboard_get_pushbutton_changed(uint8_t key_nr); +keyboard_key_press_t keyboard_get_pushbutton(uint8_t key_nr, bool use); +void keyboard_set_pushbutton(uint8_t key_nr, keyboard_key_press_t value); +int8_t keyboard_get_rotary_encoder_value(uint8_t encoder_nr); +void keyboard_set_rotary_encoder_value(uint8_t encoder_nr, int8_t value); +uint8_t keyboard_get_rotary_encoder_accelerator(uint8_t encoder_nr); + + +#endif // __KEYBOARD_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcd.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,123 @@ +/** +* @file +* Definitions for an I2C LCD driver based on the ST7032i chip from Sitronix. +* +* Author: Clemens Valens +* License: GNU General Public License +* +* History +* 2014.09.08 ver 1.00 Preliminary version, first release +*/ + +#ifndef __LCD_H__ +#define __LCD_H__ + + +#include "board.h" + + +#define LCD_I2C_ADDRESS (0x3e) + +// The speed of the display depends on the frequency of its internal oscillator. +#define ST7032_FOSC (192000) /* [Hz], can be tweaked if extended mode is available. */ +#define ST7032_RESPONSE_TIME_SLOW (410*1000000/ST7032_FOSC) /* [us] */ +#define ST7032_RESPONSE_TIME_NORMAL (10*1000000/ST7032_FOSC) /* [us] */ + +#define ST7032_RESET_RECOVERY_TIME (40) /* [ms] */ + +// ST7032 commands +// Clear Display +#define ST7032_CMD_CLEAR (0x01) + +// Return Home +#define ST7032_CMD_HOME (0x02) + +// Entry Mode Set +#define ST7032_CMD_ENTRY_MODE (0x04) +#define ST7032_SHIFT_CURSOR (0x00) /* default */ +#define ST7032_SHIFT_DISPLAY (0x01) +#define ST7032_DECREMENT (0x00) +#define ST7032_INCREMENT (0x02) /* default */ + +// Display ON/OFF +#define ST7032_CMD_ON_OFF (0x08) +#define ST7032_BLINK_OFF (0x00) /* default */ +#define ST7032_BLINK_ON (0x01) +#define ST7032_CURSOR_OFF (0x00) /* default */ +#define ST7032_CURSOR_ON (0x02) +#define ST7032_DISPLAY_OFF (0x00) /* default */ +#define ST7032_DISPLAY_ON (0x04) + +// Cursor or Display Shift +#define ST7032_CMD_SHIFT (0x10) +#define ST7032_SHIFT_LEFT (0x00) +#define ST7032_SHIFT_RIGHT (0x04) +#define ST7032_SHIFT_CURSOR (0x00) +#define ST7032_SHIFT_SCREEN (0x08) + +// Function Set +#define ST7032_CMD_FUNCTION (0x20) +#define ST7032_FUNC_NORMAL (0x00) /* default */ +#define ST7032_FUNC_EXTENDED (0x01) +#define ST7032_FUNC_HEIGHT_NORMAL (0x00) /* default */ +#define ST7032_FUNC_HEIGHT_DOUBLE (0x04) +#define ST7032_FUNC_1_LINE (0x00) /* default */ +#define ST7032_FUNC_2_LINES (0x08) +#define ST7032_FUNC_4_BIT (0x00) +#define ST7032_FUNC_8_BIT (0x10) /* default */ + +#define ST7032_FUNC_CONFIG_NORMAL (ST7032_FUNC_NORMAL | ST7032_FUNC_HEIGHT_NORMAL | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT) +#define ST7032_FUNC_CONFIG_EXTENDED (ST7032_FUNC_EXTENDED | ST7032_FUNC_HEIGHT_NORMAL | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT) +#define ST7032_FUNC_CONFIG_EXTENDED_DOUBLE (ST7032_FUNC_EXTENDED | ST7032_FUNC_HEIGHT_DOUBLE | ST7032_FUNC_2_LINES | ST7032_FUNC_8_BIT) + +// Set CGRAM Address (normal function, ST7032_FUNC_NORMAL) +#define ST7032_CMD_CGRAM_ADDRESS (0x40) +#define ST7032_CGRAM_ADDRESS_MASK (0x3f) + +// Set DDRAM Address +#define ST7032_CMD_DDRAM_ADDRESS (0x80) +#define ST7032_DDRAM_ADDRESS_MASK (0x7f) + +// Bias selection/Internal OSC frequency adjust (extended function) +#define ST7032_CMD_BIAS_OSC (0x10) +#define ST7032_BIAS_020 (0x00) /* default */ +#define ST7032_BIAS_025 (0x08) +#define ST7032_OSC_MASK (0x07) /* defaults to 0x04 */ + +// Set Icon RAM Address (extended function) +#define ST7032_CMD_ICON_RAM_ADDRESS (0x40) +#define ST7032_ICON_ADDRESS_MASK (0x0f) + +// Power/ICON control/Contrast set (high byte) (extended function) +#define ST7032_CMD_POWER_ICON_CONTRAST (0x50) +#define ST7032_BOOSTER_OFF (0x00) /* default */ +#define ST7032_BOOSTER_ON (0x04) +#define ST7032_ICON_OFF (0x00) /* default */ +#define ST7032_ICON_ON (0x08) +#define ST7032_CONTRAST_HI_MASK (0x03) /* defaults to 0x02 */ + +// Follower control (extended function) +#define ST7032_CMD_FOLLOWER (0x60) +#define ST7032_FOLLOWER_OFF (0x00) /* default */ +#define ST7032_FOLLOWER_ON (0x08) +#define ST7032_AMPLIFIER_RATIO_MASK (0x07) /* defaults to 0x02 */ + +// Contrast set (low byte) (extended function) +#define ST7032_CMD_CONTRAST_LO (0x70) +#define ST7032_CONTRAST_LO_MASK (0x0f) /* defaults to 0x00 */ + + +uint8_t lcd_putc(char ch); +uint8_t lcd_puts(char *p_str); +void lcd_clear(void); +void lcd_cursor(uint8_t line, uint8_t column); +void lcd_display_cursor_blink(uint8_t display, uint8_t cursor, uint8_t blink); +void lcd_clear_to_eol(int line, int column); +void lcd_contrast(uint8_t contrast); +void lcd_font(uint8_t font); +void lcd_set_custom_character(uint8_t index, const uint8_t *p_data); +void lcd_bar_graph(uint8_t position, uint8_t value, uint8_t value_max); +void lcd_init(void); + + +#endif // __LCD_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lfo.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,39 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//**********Bipolar LFO. 16 waveforms, each 64 samples long.*************** + +#ifndef __LFO_H__ +#define __LFO_H__ + + +#define LFO_LEN 64 +extern const signed char lfo_store[16][LFO_LEN]; + +void LFO_Let_Speed(unsigned int newspeed); +unsigned int LFO_Get_Speed(void); +void LFO_Let_Type(byte newtable); +byte LFO_Get_Type(void); +void LFO_Let_Invert(boolean newinv); +boolean LFO_Get_Invert(void); +signed char LFO_Get_Level(void); +void LFO_Reset(void); +void LFO_CalcVal(void); + + +#endif // __LFO_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/master.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,19 @@ +#ifndef __MASTER_H__ +#define __MASTER_H__ + + +#define MASTER_BEATTICK (500) //length of beat in ticks. 500 = 120bpm i.e. 1 beat = 500ms (this is overridden when MIDI clock received) + + +extern volatile uint16_t master_index; //position in master_output wavetable +extern unsigned char master_output[WAVE_LEN]; //output wavetable +extern unsigned char master_output_ch2[WAVE_LEN]; //output wavetable +extern unsigned long master_tick; //current tick. used for all timing of lfos, arp and envs +extern unsigned long master_ocr1; //interrupt frequency (sets pitch of synth) + + +void Master_Let_SampleFreq(void); +unsigned long Master_Get_SampleFreq(void); + + +#endif // __MASTER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memory.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,40 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//******Read and write patches to flash memory************** + +#ifndef __MEMORY_H__ +#define __MEMORY_H__ + + +#define SYSEXBEGIN 240 +#define SYSEXEND 247 + +//save patch +void Memory_Save(byte patchnum); +bool Memory_Load_Patch(uint8_t *p_dst, uint32_t src); // CPV +bool Memory_Load(byte patchnum); +void Memory_UserWave_Write(byte patchnum); +void Memory_UserWave_Read(byte patchnum); +void Memory_Vanilla(void); +void Memory_SYSEX_write_mem(void); +void Memory_Channel_Write(byte channel); +byte Memory_Channel_Read(void); + + +#endif // __MEMORY_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/midi.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,83 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __MIDI_H__ +#define __MIDI_H__ + + +//frequency of all midi notes (rounded to nearest integer) +extern const uint16_t MIDI_freqs[128]; + +//midi constants +#define NOTE_OFF 128 +#define NOTE_ON 144 +#define PITCH_WHEEL 224 +#define CONTROLLER 176 +#define SYSEXBEGIN 240 +#define SYSEXEND 247 +#define CC_PITCHLFO 1 +#define CC_PORTAMENTO 5 +#define CC_FILTERENV 16 +#define CC_DISTORTION 17 +#define CC_FILTCUTOFF 74 +#define CC_AMPENVR 72 +#define CC_AMPENVA 73 +#define CC_FILTRES 71 +#define CC_AMPENVD 75 +#define CC_LFOCLOCKDIV 79 +#define CC_PWM 91 +#define CC_AMPLFO 92 +#define CC_FILTLFO 93 +#define CC_PITCHENV 94 +#define CC_FLANGE 95 + +//sysex message types, used by librarian software +#define SYSEX_PATCH 0 +#define SYSEX_WAVE 1 +#define SYSEX_MEM 2 +#define SYSEX_CALLPATCH 3 +#define SYSEX_CALLWAVE 4 + +byte MIDI_Get_curNote(void); +unsigned int MIDI_Get_Freq(byte notenum); +boolean MIDI_Get_KeyDown(byte notenum); +void MIDI_Let_ClockArpSpeed(unsigned int newspeed); +void MIDI_Let_SYSEXRead(boolean newval); +boolean MIDI_Get_ClockPresent(void); +void MIDI_Set_Channel(byte newchannel); +void MIDI_Init(void); +void MIDI_NoteOn(byte notenum); +void MIDI_NoteOff(byte notenum); +void MIDI_TriggerNote(byte notenum); +void MIDI_Reset(void); +void MIDI_TestButtonDown(void); +void MIDI_TestButtonUp(void); +void MIDI_TestButtonInc(void); +void MIDI_TestButtonDec(void); +void MIDI_ClockStart(void); +void MIDI_ClockContinue(void); +void MIDI_ClockStop(void); +void MIDI_ClockTick(void); +unsigned long MIDI_Get_ClockTick(void); +char MIDI_Get_PitchBend_Level(void); +void MIDI_SYSEX_read(byte databyte); +void MIDI_SYSEX_write_patch(void); +void MIDI_Poll(void); + + +#endif // __MIDI_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pitch.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,58 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __PITCH_H__ +#define __PITCH_H__ + + +//These constants are used to define the MAXIMUM amount the env can effect the pitch. +//The default max for env is: +//********multiplier = 4*********** +#define PITCH_ENVMAX 1.386294361119891f //ln(multiplier) +#define PITCH_ENVMULT 64 //multipler used for calculating lookup table (256 / multiplier) +#define PITCH_ENVBS 6UL //bitshift amount when multiplying pitch by pitch env amt. log2(PITCH_MULT) + +//These constants are used to define the MAXIMUM amount the lfo can effect the pitch. +//The default max for lfo is: +//********multiplier = 2 (1 octave)*********** +#define PITCH_LFOMAX 0.693147180559945f //ln(multiplier) +#define PITCH_LFOMULT 128 //multipler used for calculating lookup table (256 / multiplier) +#define PITCH_LFOBS 7UL //bitshift amount when multiplying pitch by pitch lfo amt. log2(PITCH_MULT) + + +void Pitch_Let_NextFreq(unsigned int newfreq); +unsigned int Pitch_Get_NextFreq(void); +void Pitch_Let_Porta(int newporta); +int Pitch_Get_Porta(void); +void Pitch_ResetPorta(void); +void Pitch_RefreshPortaTicks(void); +unsigned long Pitch_Get_FreqCalc(void); +boolean Pitch_Get_PitchChanged(void); +void Pitch_Let_PropPorta(boolean newprop); +boolean Pitch_Get_PropPorta(void); +void Pitch_Process(void); +void Pitch_Let_LFOAmt(byte newamt); +byte Pitch_Get_LFOAmt(void); +byte Pitch_Get_LFOGain(void); +void Pitch_Let_FenvAmt(byte newamt); +byte Pitch_Get_FenvAmt(void); +byte Pitch_Get_FenvGain(void); +byte Pitch_Get_MIDIPbendGain(void); + + +#endif // __PITCH_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pwm.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,30 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +//*****Pulse Width Modulation. This sets a portion of the waveform to 0. The amount of the waveform blanked is set by the LFO and LFO amount****** + +#ifndef __PWM_H__ +#define __PWM_H__ + + +void PWM_Let_LFOAmt(byte newamt); +byte PWM_Get_LFOAmt(void); +void PWM_Process(void); + + +#endif // __PWM_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pwm_timer.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,183 @@ +/* + * @brief PWM timer driver + * + * @note + * Copyright (C) Elektor, 2014 + * All rights reserved. + * + * @par + * This software is supplied "AS IS" without any warranties of any kind, + * and Elektor and its licensor disclaim any and all warranties, express + * or implied, including all implied warranties of merchantability, + * fitness for a particular purpose and non-infringement of intellectual + * property rights. Elektor assumes no responsibility or liability for + * the use of the software, conveys no license or rights under any patent, + * copyright, mask work right, or any other intellectual property rights in + * or to any products. Elektor reserves the right to make changes in the + * software without notification. Elektor also makes no representation or + * warranty that such application will be suitable for the specified use + * without further testing or modification. + * + * @par + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, under Elektor's and its licensor's + * relevant copyrights in the software, without fee. This copyright, + * permission, and disclaimer notice must appear in all copies of this code. + */ + +#ifndef __PWM_TIMER_H__ +#define __PWM_TIMER_H__ + + +#include "timers.h" + +/* +// Choose the MR register that will determine the frequency. +#define PWM_FREQUENCY_REGISTER (3) +// Choose the MR register that will determine the duty-cycle. +#define PWM_DUTY_CYCLE_REGISTER (0) + +#if PWM_FREQUENCY_REGISTER == PWM_DUTY_CYCLE_REGISTER +#pragma GCC error "Frequency register and duty-cycle register may not be the same." +#endif + +#define PWM_MAT_OUTPUT PWM_DUTY_CYCLE_REGISTER + +#if PWM_TIMER_NR == TIMER16_0 + #define PWM_TIMER LPC_TIMER16_0 + #define PWM_TIMER_IRQ (TIMER_16_0_IRQn) + #if PWM_MAT_OUTPUT == 0 + #define PWM_MAT_PORT (0) + #define PWM_MAT_PIN (8) + #define PWM_IOCON IOCON_PIO0_8 + #define PWM_IOCON_FUNC IOCON_FUNC2 + #elif PWM_MAT_OUTPUT == 1 + #define PWM_MAT_PORT (0) + #define PWM_MAT_PIN (9) + #define PWM_IOCON IOCON_PIO0_9 + #define PWM_IOCON_FUNC IOCON_FUNC2 + #elif PWM_MAT_OUTPUT == 2 + #define PWM_MAT_PORT (0) + #define PWM_MAT_PIN (10) + #define PWM_IOCON IOCON_PIO0_10 + #define PWM_IOCON_FUNC IOCON_FUNC3 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#elif PWM_TIMER_NR == TIMER16_1 + #define PWM_TIMER LPC_TIMER16_1 + #define PWM_TIMER_IRQ (TIMER_16_1_IRQn) + #if PWM_MAT_OUTPUT == 0 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (9) + #define PWM_IOCON IOCON_PIO1_9 + #define PWM_IOCON_FUNC IOCON_FUNC1 + #elif PWM_MAT_OUTPUT == 1 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (10) + #define PWM_IOCON IOCON_PIO1_10 + #define PWM_IOCON_FUNC IOCON_FUNC2 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#elif PWM_TIMER_NR == TIMER32_0 + #define PWM_TIMER LPC_TIMER32_0 + #define PWM_TIMER_IRQ (TIMER_32_0_IRQn) + #if PWM_MAT_OUTPUT == 0 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (6) + #define PWM_IOCON IOCON_PIO1_6 + #define PWM_IOCON_FUNC IOCON_FUNC2 + #elif PWM_MAT_OUTPUT == 1 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (7) + #define PWM_IOCON IOCON_PIO1_7 + #define PWM_IOCON_FUNC IOCON_FUNC2 + #elif PWM_MAT_OUTPUT == 2 + #define PWM_MAT_PORT (0) + #define PWM_MAT_PIN (1) + #define PWM_IOCON IOCON_PIO0_1 + #define PWM_IOCON_FUNC IOCON_FUNC2 + #elif PWM_MAT_OUTPUT == 3 + #define PWM_MAT_PORT (0) + #define PWM_MAT_PIN (11) + #define PWM_IOCON IOCON_PIO0_11 + #define PWM_IOCON_FUNC IOCON_FUNC3 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#elif PWM_TIMER_NR == TIMER32_1 + #define PWM_TIMER LPC_TIMER32_1 + #define PWM_TIMER_IRQ (TIMER_32_1_IRQn) + #if PWM_MAT_OUTPUT == 0 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (1) + #define PWM_IOCON IOCON_PIO1_1 + #define PWM_IOCON_FUNC IOCON_FUNC3 + #elif PWM_MAT_OUTPUT == 1 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (2) + #define PWM_IOCON IOCON_PIO1_2 + #define PWM_IOCON_FUNC IOCON_FUNC3 + #elif PWM_MAT_OUTPUT == 2 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (3) + #define PWM_IOCON IOCON_PIO1_3 + #define PWM_IOCON_FUNC IOCON_FUNC3 + #elif PWM_MAT_OUTPUT == 3 + #define PWM_MAT_PORT (1) + #define PWM_MAT_PIN (4) + #define PWM_IOCON IOCON_PIO1_4 + #define PWM_IOCON_FUNC IOCON_FUNC2 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#else + // Does not exist. + #pragma GCC error "Selected PWM timer does not exist." +#endif +*/ + +typedef struct +{ + uint8_t port; + uint8_t pin; + uint32_t function; + uint32_t duty_cycle; +} +pwm_timer_channel_t; + +typedef uint32_t LPC_TIMER_T; +typedef uint32_t LPC1347_IRQn_Type; + +typedef struct +{ + LPC_TIMER_T *timer; + LPC1347_IRQn_Type irq; + uint8_t frequency_register; + pwm_timer_channel_t channel[4]; +} +pwm_timer_t; + +// The datasheet recommends to use MR3 as the PWM frequency register. +#define PWM_TIMER_FREQUENCY_REGISTER (3) +#define PWM_TIMER_DEFAULT_DUTY_CYCLE (50) + +#define PWM_TIMERS (4) +extern const pwm_timer_t pwm_timers[PWM_TIMERS]; + + +void PwmTimer_Init(const pwm_timer_t *p_timer, uint32_t frequency); +void PwmTimer_InitChannel(const pwm_timer_t *p_timer, uint8_t channel, uint32_t duty_cycle); +void PwmTimer_SetFrequency(const pwm_timer_t *p_timer, uint32_t frequency); +void PwmTimer_SetDutyCycle(const pwm_timer_t *p_timer, uint8_t channel, uint32_t duty_cycle); +void PwmTimer_Start(const pwm_timer_t *p_timer); +void PwmTimer_Stop(const pwm_timer_t *p_timer); +void PwmTimer_EnableInterrupt(const pwm_timer_t *p_timer, uint8_t channel); + + +#endif // __PWM_TIMER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample_rate.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,113 @@ +#ifndef __SAMPLE_RATE_H__ +#define __SAMPLE_RATE_H__ + + +#include "timers.h" + +#define SAMPLE_RATE_FREQUENCY_REGISTER (3) /* Choose the MR register that will determine the frequency. */ +#define SAMPLE_RATE_MAT_OUTPUT SAMPLE_RATE_FREQUENCY_REGISTER + +/* +#if SAMPLE_RATE_TIMER_NR == TIMER16_0 + #define SAMPLE_RATE_TIMER LPC_TIMER16_0 + #define SAMPLE_RATE_TIMER_IRQ (TIMER_16_0_IRQn) + #if SAMPLE_RATE_MAT_OUTPUT == 0 + #define SAMPLE_RATE_MAT_PORT (0) + #define SAMPLE_RATE_MAT_PIN (8) + #define SAMPLE_RATE_IOCON IOCON_PIO0_8 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2 + #elif SAMPLE_RATE_MAT_OUTPUT == 1 + #define SAMPLE_RATE_MAT_PORT (0) + #define SAMPLE_RATE_MAT_PIN (9) + #define SAMPLE_RATE_IOCON IOCON_PIO0_9 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2 + #elif SAMPLE_RATE_MAT_OUTPUT == 2 + #define SAMPLE_RATE_MAT_PORT (0) + #define SAMPLE_RATE_MAT_PIN (10) + #define SAMPLE_RATE_IOCON IOCON_PIO0_10 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#elif SAMPLE_RATE_TIMER_NR == TIMER16_1 + #define SAMPLE_RATE_TIMER LPC_TIMER16_1 + #define SAMPLE_RATE_TIMER_IRQ (TIMER_16_1_IRQn) + #if SAMPLE_RATE_MAT_OUTPUT == 0 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (9) + #define SAMPLE_RATE_IOCON IOCON_PIO1_9 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC1 + #elif SAMPLE_RATE_MAT_OUTPUT == 1 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (10) + #define SAMPLE_RATE_IOCON IOCON_PIO1_10 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#elif SAMPLE_RATE_TIMER_NR == TIMER32_0 + #define SAMPLE_RATE_TIMER LPC_TIMER32_0 + #define SAMPLE_RATE_TIMER_IRQ (TIMER_32_0_IRQn) + #if SAMPLE_RATE_MAT_OUTPUT == 0 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (6) + #define SAMPLE_RATE_IOCON IOCON_PIO1_6 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2 + #elif SAMPLE_RATE_MAT_OUTPUT == 1 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (7) + #define SAMPLE_RATE_IOCON IOCON_PIO1_7 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2 + #elif SAMPLE_RATE_MAT_OUTPUT == 2 + #define SAMPLE_RATE_MAT_PORT (0) + #define SAMPLE_RATE_MAT_PIN (1) + #define SAMPLE_RATE_IOCON IOCON_PIO0_1 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2 + #elif SAMPLE_RATE_MAT_OUTPUT == 3 + #define SAMPLE_RATE_MAT_PORT (0) + #define SAMPLE_RATE_MAT_PIN (11) + #define SAMPLE_RATE_IOCON IOCON_PIO0_11 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#elif SAMPLE_RATE_TIMER_NR == TIMER32_1 + #define SAMPLE_RATE_TIMER LPC_TIMER32_1 + #define SAMPLE_RATE_TIMER_IRQ (TIMER_32_1_IRQn) + #if SAMPLE_RATE_MAT_OUTPUT == 0 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (1) + #define SAMPLE_RATE_IOCON IOCON_PIO1_1 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3 + #elif SAMPLE_RATE_MAT_OUTPUT == 1 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (2) + #define SAMPLE_RATE_IOCON IOCON_PIO1_2 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3 + #elif SAMPLE_RATE_MAT_OUTPUT == 2 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (3) + #define SAMPLE_RATE_IOCON IOCON_PIO1_3 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC3 + #elif SAMPLE_RATE_MAT_OUTPUT == 3 + #define SAMPLE_RATE_MAT_PORT (1) + #define SAMPLE_RATE_MAT_PIN (4) + #define SAMPLE_RATE_IOCON IOCON_PIO1_4 + #define SAMPLE_RATE_IOCON_FUNC IOCON_FUNC2 + #else + // Does not exist. + #pragma GCC error "Match output pin MATx does not exist." + #endif +#else + // Does not exist. + #pragma GCC error "Selected SAMPLE_RATE timer does not exist." +#endif +*/ + +void SampleRate_Init(uint32_t default_rate, uint32_t samples_per_period); + + +#endif // __SAMPLE_RATE_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/serial.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,46 @@ +/* + * @brief Serial port driver + * + * @note + * Copyright (C) Elektor, 2014 + * All rights reserved. + * + * @par + * This software is supplied "AS IS" without any warranties of any kind, + * and Elektor and its licensor disclaim any and all warranties, express + * or implied, including all implied warranties of merchantability, + * fitness for a particular purpose and non-infringement of intellectual + * property rights. Elektor assumes no responsibility or liability for + * the use of the software, conveys no license or rights under any patent, + * copyright, mask work right, or any other intellectual property rights in + * or to any products. Elektor reserves the right to make changes in the + * software without notification. Elektor also makes no representation or + * warranty that such application will be suitable for the specified use + * without further testing or modification. + * + * @par + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, under Elektor's and its licensor's + * relevant copyrights in the software, without fee. This copyright, + * permission, and disclaimer notice must appear in all copies of this code. + */ + +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + + +// Emulation of some Arduino Serial class methods. +typedef struct +{ + size_t (*write)(uint8_t value); + int (*read)(void); + void (*flush)(void); + int (*available)(void); + void (*begin)(uint32_t baudrate); +} +serial2_t; + +extern const serial2_t Serial; + + +#endif // __SERIAL_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/systick.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,16 @@ +#ifndef __SYSTICK_H__ +#define __SYSTICK_H__ + + +#define SYSTICK_RATE_HZ (1000) // Ticks per second. + +void SysTick_Handler(void); +void SysTick_Seconds(void); +void SysTick_Delay(uint32_t ticks); +void SysTick_LED_Flash(uint8_t led, uint32_t ticks); + +extern volatile uint32_t seconds_counter; +extern volatile uint32_t systick_counter; + + +#endif // __SYSTICK_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testmode.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,28 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __TEST_MODE_H__ +#define __TEST_MODE_H__ + + +void Testmode_Let_NextTick(long newtick); +long Testmode_Get_NextTick(void); +void Testmode_ProcessNext(void); + + +#endif // __TEST_MODE_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/timers.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,46 @@ +/* + * @brief Timer definitions + * + * @note + * Copyright (C) Elektor, 2014 + * All rights reserved. + * + * @par + * This software is supplied "AS IS" without any warranties of any kind, + * and Elektor and its licensor disclaim any and all warranties, express + * or implied, including all implied warranties of merchantability, + * fitness for a particular purpose and non-infringement of intellectual + * property rights. Elektor assumes no responsibility or liability for + * the use of the software, conveys no license or rights under any patent, + * copyright, mask work right, or any other intellectual property rights in + * or to any products. Elektor reserves the right to make changes in the + * software without notification. Elektor also makes no representation or + * warranty that such application will be suitable for the specified use + * without further testing or modification. + * + * @par + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, under Elektor's and its licensor's + * relevant copyrights in the software, without fee. This copyright, + * permission, and disclaimer notice must appear in all copies of this code. + */ + +#ifndef __TIMERS_H__ +#define __TIMERS_H__ + + +// Timers you can use. +#define TIMER16_0 (0) +#define TIMER16_1 (1) +#define TIMER32_0 (2) +#define TIMER32_1 (3) + +#define SAMPLE_RATE_TIMER TIMER32_0 +#define AUDIO_OUT_TIMER TIMER32_1 + +#if SAMPLE_RATE_TIMER == AUDIO_OUT_TIMER +#pragma GCC error "Sample rate timer and audio out timer may not be the same." +#endif + + +#endif // __TIMERS_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/user_interface.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,48 @@ +/* + * @brief User interface + * + * @note + * Copyright (C) Elektor, 2014 + * All rights reserved. + * + * @par + * This software is supplied "AS IS" without any warranties of any kind, + * and Elektor and its licensor disclaim any and all warranties, express + * or implied, including all implied warranties of merchantability, + * fitness for a particular purpose and non-infringement of intellectual + * property rights. Elektor assumes no responsibility or liability for + * the use of the software, conveys no license or rights under any patent, + * copyright, mask work right, or any other intellectual property rights in + * or to any products. Elektor reserves the right to make changes in the + * software without notification. Elektor also makes no representation or + * warranty that such application will be suitable for the specified use + * without further testing or modification. + * + * @par + * Permission to use, copy, modify, and distribute this software and its + * documentation is hereby granted, under Elektor's and its licensor's + * relevant copyrights in the software, without fee. This copyright, + * permission, and disclaimer notice must appear in all copies of this code. + */ + +#ifndef __DISPLAY_H__ +#define __DISPLAY_H__ + + +#define PAGE_SPLASH (0) +#define PAGE_FUNCTION (1) +#define PAGE_CTRL (2) + + +void display_init(void); +void display_print_value(uint8_t line, uint8_t position, int value, boolean ignore_sign); +void display_page_splash(void); +void display_page_function(void); +void display_page_ctrl(void); +boolean display_page_set(uint8_t page); +uint8_t display_page_get(void); +void display_draw(boolean force_redraw); +void display_invalidate(void); + + +#endif // __DISPLAY_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,19 @@ +#ifndef __UTIL_H__ +#define __UTIL_H__ + + +// From Arduino.h +#define bitRead(value,bit) (((value) >> (bit)) & 0x01) +#define bitSet(value,bit) ((value) |= (1UL << (bit))) +#define bitClear(value,bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value,bit, bitvalue) (bitvalue ? bitSet(value,bit) : bitClear(value,bit)) + +long map(long x, long in_min, long in_max, long out_min, long out_max); +//int round(double number); +void randomSeed(unsigned int seed); +long random(long howsmall, long howbig); +void cli(void); +void sei(void); + + +#endif // __UTIL_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/waveforms.h Tue Oct 28 12:19:22 2014 +0000 @@ -0,0 +1,45 @@ +/* +Copyright 2013 Paul Soulsby www.soulsbysynths.com + This file is part of Atmegatron. + + Atmegatron is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Atmegatron 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Atmegatron. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __WAVEFORMS_H__ +#define __WAVEFORMS_H__ + + +extern const sample_t wave_store[2][16][WAVE_LEN]; +// CPV - Made extern to speed up processing +extern sample_t wave_process[WAVE_LEN]; //temp wavetable used to process wavetable +extern sample_t wave_process_ch2[WAVE_LEN]; //temp wavetable used for channel two + +void Wave_Let_Table(byte newtable); +byte Wave_Get_Table(void); +void Wave_Let_Bank(byte newbank); +byte Wave_Get_Bank(void); +// CPV - inlined to speed up processing +inline void Wave_Let_Process(byte index, sample_t newval); +// CPV - inlined to speed up processing +inline sample_t Wave_Get_Process(byte index); +void Wave_Let_UserMode(boolean newval); +boolean Wave_Get_UserMode(void); +void Wave_Let_UserWave(byte index, sample_t newval); +sample_t Wave_Get_UserWave(byte index); +void Init_Waves(void); +void Wave_Process(void); +void Wave_Clear(void); + + +#endif // __WAVEFORMS_H__