From 7919850a6dd27d6af788b93f0c3110c933f3ccc3 Mon Sep 17 00:00:00 2001 From: Eddy Date: Wed, 19 Mar 2014 00:38:10 +0400 Subject: [PATCH] copy --- Noice_generator/Makefile | 34 + Noice_generator/README | 1 + Noice_generator/interrupts.c | 181 ++++ Noice_generator/interrupts.h | 144 +++ Noice_generator/main.c | 291 ++++++ Noice_generator/main.h | 42 + Noice_generator/noicegen.c | 70 ++ Noice_generator/noicegen.h | 48 + Noice_generator/ports_definition.h | 43 + Noice_generator/waveforms.m | 12 + blinky/Makefile | 39 + blinky/blinky.c | 235 +++++ blinky/blinky.h | 30 + blinky/interrupts.c | 153 +++ blinky/interrupts.h | 144 +++ blinky/testproj.bin | Bin 0 -> 533 bytes led/Makefile | 39 + led/interrupts.c | 150 +++ led/interrupts.h | 147 +++ led/led.c | 243 +++++ led/led.h | 48 + led/main.c | 85 ++ led/testproj.bin | Bin 0 -> 1517 bytes stepper/Makefile | 39 + stepper/client-term/Makefile | 22 + stepper/client-term/client.c | 222 ++++ stepper/interrupts.c | 169 +++ stepper/interrupts.h | 144 +++ stepper/main.c | 396 ++++++++ stepper/main.h | 41 + stepper/ports_definition.h | 50 + stepper/schematic/kicad.pro | 82 ++ stepper/schematic/stepper-cache.lib | 237 +++++ stepper/schematic/stepper.cmp | 108 ++ stepper/schematic/stepper.net | 361 +++++++ stepper/schematic/stepper.pro | 42 + stepper/schematic/stepper.sch | 612 +++++++++++ stepper/schematic/stm8s105k4t6c.bck | 9 + stepper/schematic/stm8s105k4t6c.dcm | 13 + stepper/schematic/stm8s105k4t6c.lib | 99 ++ stepper/schematic/template-cache.lib | 204 ++++ stepper/schematic/template.cmp | 94 ++ stepper/schematic/template.net | 321 ++++++ stepper/schematic/template.sch | 518 ++++++++++ stepper/stepper.c | 126 +++ stepper/stepper.h | 41 + stepper/testproj.bin | Bin 0 -> 2958 bytes stepper_independent/Makefile | 39 + stepper_independent/README | 13 + stepper_independent/client-term/Makefile | 22 + stepper_independent/client-term/client.c | 222 ++++ stepper_independent/interrupts.c | 181 ++++ stepper_independent/interrupts.h | 144 +++ stepper_independent/main.c | 260 +++++ stepper_independent/main.h | 41 + stepper_independent/ports_definition.h | 55 + stepper_independent/schematic/kicad.kicad_pcb | 961 ++++++++++++++++++ stepper_independent/schematic/kicad.pro | 82 ++ .../schematic/stepper-cache.lib | 318 ++++++ stepper_independent/schematic/stepper.cmp | 108 ++ stepper_independent/schematic/stepper.net | 415 ++++++++ stepper_independent/schematic/stepper.sch | 731 +++++++++++++ .../schematic/stm8s105k4t6c.bck | 9 + .../schematic/stm8s105k4t6c.dcm | 13 + .../schematic/stm8s105k4t6c.lib | 99 ++ stepper_independent/stepper.c | 187 ++++ stepper_independent/stepper.h | 38 + stepper_independent/testproj.bin | Bin 0 -> 3280 bytes stepper_independent_bin/Makefile | 34 + stepper_independent_bin/README | 26 + stepper_independent_bin/client-term/Makefile | 22 + stepper_independent_bin/client-term/client.c | 259 +++++ stepper_independent_bin/interrupts.c | 207 ++++ stepper_independent_bin/interrupts.h | 144 +++ stepper_independent_bin/main.c | 392 +++++++ stepper_independent_bin/main.h | 44 + stepper_independent_bin/ports_definition.h | 90 ++ .../schematic/kicad.kicad_pcb | 961 ++++++++++++++++++ stepper_independent_bin/schematic/kicad.pro | 82 ++ .../schematic/stepper-cache.dcm | 8 + .../schematic/stepper-cache.lib | 253 +++++ stepper_independent_bin/schematic/stepper.cmp | 108 ++ stepper_independent_bin/schematic/stepper.net | 415 ++++++++ stepper_independent_bin/schematic/stepper.pro | 45 + stepper_independent_bin/schematic/stepper.sch | 779 ++++++++++++++ .../schematic/stm8s105k4t6c.bck | 9 + .../schematic/stm8s105k4t6c.dcm | 13 + .../schematic/stm8s105k4t6c.lib | 99 ++ stepper_independent_bin/stepper.c | 242 +++++ stepper_independent_bin/stepper.h | 47 + stepper_independent_bin/testproj.bin | Bin 0 -> 4840 bytes stm8l.h | 395 +++++++ zakwire.tgz | Bin 0 -> 9623 bytes zakwire/Makefile | 39 + zakwire/interrupts.c | 176 ++++ zakwire/interrupts.h | 147 +++ zakwire/led.c | 258 +++++ zakwire/led.h | 50 + zakwire/main.c | 124 +++ zakwire/testproj.bin | Bin 0 -> 2807 bytes zakwire/zacwire.c | 149 +++ zakwire/zacwire.h | 34 + zakwire00.tgz | Bin 0 -> 9189 bytes 103 files changed, 15718 insertions(+) create mode 100644 Noice_generator/Makefile create mode 100644 Noice_generator/README create mode 100644 Noice_generator/interrupts.c create mode 100644 Noice_generator/interrupts.h create mode 100644 Noice_generator/main.c create mode 100644 Noice_generator/main.h create mode 100644 Noice_generator/noicegen.c create mode 100644 Noice_generator/noicegen.h create mode 100644 Noice_generator/ports_definition.h create mode 100644 Noice_generator/waveforms.m create mode 100644 blinky/Makefile create mode 100644 blinky/blinky.c create mode 100644 blinky/blinky.h create mode 100644 blinky/interrupts.c create mode 100644 blinky/interrupts.h create mode 100644 blinky/testproj.bin create mode 100644 led/Makefile create mode 100644 led/interrupts.c create mode 100644 led/interrupts.h create mode 100644 led/led.c create mode 100644 led/led.h create mode 100644 led/main.c create mode 100644 led/testproj.bin create mode 100644 stepper/Makefile create mode 100644 stepper/client-term/Makefile create mode 100644 stepper/client-term/client.c create mode 100644 stepper/interrupts.c create mode 100644 stepper/interrupts.h create mode 100644 stepper/main.c create mode 100644 stepper/main.h create mode 100644 stepper/ports_definition.h create mode 100644 stepper/schematic/kicad.pro create mode 100644 stepper/schematic/stepper-cache.lib create mode 100644 stepper/schematic/stepper.cmp create mode 100644 stepper/schematic/stepper.net create mode 100644 stepper/schematic/stepper.pro create mode 100644 stepper/schematic/stepper.sch create mode 100644 stepper/schematic/stm8s105k4t6c.bck create mode 100644 stepper/schematic/stm8s105k4t6c.dcm create mode 100644 stepper/schematic/stm8s105k4t6c.lib create mode 100644 stepper/schematic/template-cache.lib create mode 100644 stepper/schematic/template.cmp create mode 100644 stepper/schematic/template.net create mode 100644 stepper/schematic/template.sch create mode 100644 stepper/stepper.c create mode 100644 stepper/stepper.h create mode 100644 stepper/testproj.bin create mode 100644 stepper_independent/Makefile create mode 100644 stepper_independent/README create mode 100644 stepper_independent/client-term/Makefile create mode 100644 stepper_independent/client-term/client.c create mode 100644 stepper_independent/interrupts.c create mode 100644 stepper_independent/interrupts.h create mode 100644 stepper_independent/main.c create mode 100644 stepper_independent/main.h create mode 100644 stepper_independent/ports_definition.h create mode 100644 stepper_independent/schematic/kicad.kicad_pcb create mode 100644 stepper_independent/schematic/kicad.pro create mode 100644 stepper_independent/schematic/stepper-cache.lib create mode 100644 stepper_independent/schematic/stepper.cmp create mode 100644 stepper_independent/schematic/stepper.net create mode 100644 stepper_independent/schematic/stepper.sch create mode 100644 stepper_independent/schematic/stm8s105k4t6c.bck create mode 100644 stepper_independent/schematic/stm8s105k4t6c.dcm create mode 100644 stepper_independent/schematic/stm8s105k4t6c.lib create mode 100644 stepper_independent/stepper.c create mode 100644 stepper_independent/stepper.h create mode 100644 stepper_independent/testproj.bin create mode 100644 stepper_independent_bin/Makefile create mode 100644 stepper_independent_bin/README create mode 100644 stepper_independent_bin/client-term/Makefile create mode 100644 stepper_independent_bin/client-term/client.c create mode 100644 stepper_independent_bin/interrupts.c create mode 100644 stepper_independent_bin/interrupts.h create mode 100644 stepper_independent_bin/main.c create mode 100644 stepper_independent_bin/main.h create mode 100644 stepper_independent_bin/ports_definition.h create mode 100644 stepper_independent_bin/schematic/kicad.kicad_pcb create mode 100644 stepper_independent_bin/schematic/kicad.pro create mode 100644 stepper_independent_bin/schematic/stepper-cache.dcm create mode 100644 stepper_independent_bin/schematic/stepper-cache.lib create mode 100644 stepper_independent_bin/schematic/stepper.cmp create mode 100644 stepper_independent_bin/schematic/stepper.net create mode 100644 stepper_independent_bin/schematic/stepper.pro create mode 100644 stepper_independent_bin/schematic/stepper.sch create mode 100644 stepper_independent_bin/schematic/stm8s105k4t6c.bck create mode 100644 stepper_independent_bin/schematic/stm8s105k4t6c.dcm create mode 100644 stepper_independent_bin/schematic/stm8s105k4t6c.lib create mode 100644 stepper_independent_bin/stepper.c create mode 100644 stepper_independent_bin/stepper.h create mode 100644 stepper_independent_bin/testproj.bin create mode 100644 stm8l.h create mode 100644 zakwire.tgz create mode 100644 zakwire/Makefile create mode 100644 zakwire/interrupts.c create mode 100644 zakwire/interrupts.h create mode 100644 zakwire/led.c create mode 100644 zakwire/led.h create mode 100644 zakwire/main.c create mode 100644 zakwire/testproj.bin create mode 100644 zakwire/zacwire.c create mode 100644 zakwire/zacwire.h create mode 100644 zakwire00.tgz diff --git a/Noice_generator/Makefile b/Noice_generator/Makefile new file mode 100644 index 0000000..b766c39 --- /dev/null +++ b/Noice_generator/Makefile @@ -0,0 +1,34 @@ +NAME=testproj +SDCC=sdcc + +CCFLAGS=-DSTM8S105 -I../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx +LDFLAGS= -mstm8 --out-fmt-ihx -lstm8 +FLASHFLAGS=-cstlinkv2 -pstm8s105 + +SRC=$(wildcard *.c) +# ATTENTION: FIRST in list should be file with main() +OBJ=$(SRC:%.c=%.rel) +TRASH=$(OBJ) $(SRC:%.c=%.rst) $(SRC:%.c=%.asm) $(SRC:%.c=%.lst) +TRASH+=$(SRC:%.c=%.sym) $(NAME).ihx $(NAME).lk $(NAME).map +INDEPENDENT_HEADERS=../stm8l.h ports_definition.h Makefile + +all: $(NAME).ihx + +$(SRC) : %.c : %.h $(INDEPENDENT_HEADERS) + @touch $@ + +%.h: ; + +clean: + rm -f $(TRASH) + +load: $(NAME).ihx + stm8flash $(FLASHFLAGS) -w $(NAME).ihx + +%.rel: %.c + $(SDCC) $(CCFLAGS) -c $< + +$(NAME).ihx: $(OBJ) + $(SDCC) $(LDFLAGS) $(OBJ) -o $(NAME).ihx + +.PHONY: all diff --git a/Noice_generator/README b/Noice_generator/README new file mode 100644 index 0000000..c5f02b8 --- /dev/null +++ b/Noice_generator/README @@ -0,0 +1 @@ +This is a table-based generator of simplest waveforms diff --git a/Noice_generator/interrupts.c b/Noice_generator/interrupts.c new file mode 100644 index 0000000..d427036 --- /dev/null +++ b/Noice_generator/interrupts.c @@ -0,0 +1,181 @@ +/* + * interrupts.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "ports_definition.h" +#include "main.h" +#include "noicegen.h" + +// Top Level Interrupt +INTERRUPT_HANDLER(TLI_IRQHandler, 0){} + +// Auto Wake Up Interrupt +INTERRUPT_HANDLER(AWU_IRQHandler, 1){} + +// Clock Controller Interrupt +INTERRUPT_HANDLER(CLK_IRQHandler, 2){} + +// External Interrupt PORTA +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3){ + +} + +// External Interrupt PORTB +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4){ + +} + +// External Interrupt PORTC +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5){ + +} + +// External Interrupt PORTD +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6){ + +} + +// External Interrupt PORTE +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7){ + +} + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8){} +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8){} + +// CAN TX Interrupt routine. +INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9){} +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_HANDLER(SPI_IRQHandler, 10){} + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11){ +} + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12){} + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13){} + +// Timer5 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14){} + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +static U8 bank_i = 0; +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13){ // generate pulses for stepper CLK + if(TIM2_SR1 & TIM_SR1_UIF){ + change_CCR(current_bank[bank_i]); + if(++bank_i == 16) bank_i = 0; + TIM2_SR1 &= ~TIM_SR1_UIF; + } +} + +// Timer2 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14){ +} +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15){ + +} + +// Timer3 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16){} +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17){} + +// UART1 RX Interrupt +INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18){} +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_HANDLER(I2C_IRQHandler, 19){} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){} + +// UART2 RX interrupt +INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21){ + U8 rb; + if(UART2_SR & UART_SR_RXNE){ // data received + rb = UART2_DR; // read received byte & clear RXNE flag + while(!(UART2_SR & UART_SR_TXE)); + UART_send_byte(rb); // echo received symbol + UART_rx[UART_rx_cur_i++] = rb; // put received byte into cycled buffer + if(UART_rx_cur_i == UART_rx_start_i){ // Oops: buffer overflow! Just forget old data + UART_rx_start_i++; + check_UART_pointer(UART_rx_start_i); + } + check_UART_pointer(UART_rx_cur_i); + } +} +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20){} + +// UART3 RX interrupt +INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21){} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_HANDLER(ADC2_IRQHandler, 22){} +#else +// ADC1 interrupt +INTERRUPT_HANDLER(ADC1_IRQHandler, 22){ +} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23){} +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23){ + if(TIM4_SR & TIM_SR1_UIF){ // update interrupt + Global_time++; // increase timer + } + TIM4_SR = 0; // clear all interrupt flags +} +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24){} diff --git a/Noice_generator/interrupts.h b/Noice_generator/interrupts.h new file mode 100644 index 0000000..6edf384 --- /dev/null +++ b/Noice_generator/interrupts.h @@ -0,0 +1,144 @@ +/* + * interrupts.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __INTERRUPTS_H__ +#define __INTERRUPTS_H__ + +#include "stm8l.h" + +// Top Level Interrupt +INTERRUPT_DEFINITION(TLI_IRQHandler, 0); + +// Auto Wake Up Interrupt +INTERRUPT_DEFINITION(AWU_IRQHandler, 1); + +// Clock Controller Interrupt +INTERRUPT_DEFINITION(CLK_IRQHandler, 2); + +// External Interrupt PORTA +INTERRUPT_DEFINITION(EXTI_PORTA_IRQHandler, 3); + +// External Interrupt PORTB +INTERRUPT_DEFINITION(EXTI_PORTB_IRQHandler, 4); + +// External Interrupt PORTC +INTERRUPT_DEFINITION(EXTI_PORTC_IRQHandler, 5); + +// External Interrupt PORTD +INTERRUPT_DEFINITION(EXTI_PORTD_IRQHandler, 6); + +// External Interrupt PORTE +INTERRUPT_DEFINITION(EXTI_PORTE_IRQHandler, 7); + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_DEFINITION(EXTI_PORTF_IRQHandler, 8); +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_DEFINITION(CAN_RX_IRQHandler, 8); + +// CAN TX Interrupt routine. +INTERRUPT_DEFINITION(CAN_TX_IRQHandler, 9); +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_DEFINITION(SPI_IRQHandler, 10); + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_DEFINITION(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_DEFINITION(TIM1_CAP_COM_IRQHandler, 12); + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_DEFINITION(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); + +// Timer5 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM5_CAP_COM_IRQHandler, 14); + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM2_UPD_OVF_BRK_IRQHandler, 13); + +// Timer2 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM2_CAP_COM_IRQHandler, 14); +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM3_UPD_OVF_BRK_IRQHandler, 15); + +// Timer3 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM3_CAP_COM_IRQHandler, 16); +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_DEFINITION(UART1_TX_IRQHandler, 17); + +// UART1 RX Interrupt +INTERRUPT_DEFINITION(UART1_RX_IRQHandler, 18); +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_DEFINITION(I2C_IRQHandler, 19); + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_DEFINITION(UART2_TX_IRQHandler, 20); + +// UART2 RX interrupt +INTERRUPT_DEFINITION(UART2_RX_IRQHandler, 21); +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_DEFINITION(UART3_TX_IRQHandler, 20); + +// UART3 RX interrupt +INTERRUPT_DEFINITION(UART3_RX_IRQHandler, 21); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_DEFINITION(ADC2_IRQHandler, 22); +#else // STM8S105, STM8S103 or STM8S903 or STM8AF626x +// ADC1 interrupt +INTERRUPT_DEFINITION(ADC1_IRQHandler, 22); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_DEFINITION(TIM6_UPD_OVF_TRG_IRQHandler, 23); +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_DEFINITION(TIM4_UPD_OVF_IRQHandler, 23); +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_DEFINITION(EEPROM_EEC_IRQHandler, 24); + +#endif // __INTERRUPTS_H__ diff --git a/Noice_generator/main.c b/Noice_generator/main.c new file mode 100644 index 0000000..3ba32c4 --- /dev/null +++ b/Noice_generator/main.c @@ -0,0 +1,291 @@ +/* + * blinky.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "ports_definition.h" +#include "interrupts.h" +#include "main.h" +#include "noicegen.h" + +/* + * 0 0000 + * 1 0001 + * 2 0010 + * 3 0011 + * 4 0100 + * 5 0101 + * 6 0110 + * 7 0111 + * 8 1000 + * 9 1001 + * a 1010 + * b 1011 + * c 1100 + * d 1101 + * e 1110 + * f 1111 + */ + +unsigned long Global_time = 0L; // global time in ms +U16 paused_val = 500; // interval between LED flashing + +U8 UART_rx[UART_BUF_LEN]; // cycle buffer for received data +U8 UART_rx_start_i = 0; // started index of received data (from which reading starts) +U8 UART_rx_cur_i = 0; // index of current first byte in rx array (to which data will be written) +U8 UART_is_our = 0; // ==1 if we get UART +// ATTENTION! to change global variable in PROGRAM memory, it should be CONST!!! +const U8 UART_devNUM = THIS_DEVICE_NUM; // device number, master sais it + +/** + * Send one byte through UART + * @param byte - data to send + */ +void UART_send_byte(U8 byte){ + UART2_DR = byte; + while(!(UART2_SR & UART_SR_TC)); +} + +void uart_write(char *str){ + while(*str){ + UART2_DR = *str++; + while(!(UART2_SR & UART_SR_TC)); + } +} + + +/** + * Read one byte from Rx buffer + * @param byte - where to store readed data + * @return 1 in case of non-empty buffer + */ +U8 UART_read_byte(U8 *byte){ + if(UART_rx_start_i == UART_rx_cur_i) // buffer is empty + return 0; + *byte = UART_rx[UART_rx_start_i++]; + check_UART_pointer(UART_rx_start_i); + return 1; +} + +void printUint(U8 *val, U8 len){ + unsigned long Number = 0; + U8 i = len; + char ch; + U8 decimal_buff[12]; // max len of U32 == 10 + \n + \0 + if(len > 4 || len == 3 || len == 0) return; + for(i = 0; i < 12; i++) + decimal_buff[i] = 0; + decimal_buff[10] = '\n'; + ch = 9; + switch(len){ + case 1: + Number = *((U8*)val); + break; + case 2: + Number = *((U16*)val); + break; + case 4: + Number = *((unsigned long*)val); + break; + } + do{ + i = Number % 10L; + decimal_buff[ch--] = i + '0'; + Number /= 10L; + }while(Number && ch > -1); + uart_write((char*)&decimal_buff[ch+1]); +} + +U8 readInt(int *val){ + unsigned long T = Global_time; + unsigned long R = 0; + int readed; + U8 sign = 0, rb, ret = 0, bad = 0; + do{ + if(!UART_read_byte(&rb)) continue; + if(rb == '-' && R == 0){ // negative number + sign = 1; + continue; + } + if(rb < '0' || rb > '9') break; // number ends with any non-digit symbol that will be omitted + ret = 1; // there's at least one digit + R = R * 10L + rb - '0'; + if(R > 0x7fff){ // bad value + R = 0; + bad = 0; + } + }while(Global_time - T < 10000); // wait no longer than 10s + if(bad || !ret) return 0; + readed = (int) R; + if(sign) readed *= -1; + *val = readed; + return 1; +} + + +void error_msg(char *msg){ + uart_write("\nERROR: "); + uart_write(msg); + UART_send_byte('\n'); +} + + +/** + * Change variable stored in program memory + * !!! You can change only const values (non-constants are initializes on program start) + * @param addr - variable address + * @param new value + * @return 0 in case of error + * +U8 change_progmem_value(U8 *addr, U8 val){ + // unlock memory + FLASH_PUKR = EEPROM_KEY2; + FLASH_PUKR = EEPROM_KEY1; + // check bit PUL=1 in FLASH_IAPSR + if(!FLASH_IAPSR & 0x02) + return 0; + *addr = val; + // clear PUL to lock write + FLASH_IAPSR &= ~0x02; + return 1; +} +*/ +/* +U8 change_eeprom_value(U8 *addr, U8 val){ + // unlock memory + FLASH_DUKR = EEPROM_KEY1; + FLASH_DUKR = EEPROM_KEY2; + // check bit DUL=1 in FLASH_IAPSR + if(!FLASH_IAPSR & 0x08) + return 0; + *addr = val; + // clear DUL to lock write + FLASH_IAPSR &= ~0x08; + return 1; +} +*/ + +int main() { + unsigned long T = 0L; + int Ival; + U8 rb; + + CFG_GCR |= 1; // disable SWIM + + // Configure clocking + CLK_CKDIVR = 0; // F_HSI = 16MHz, f_CPU = 16MHz + + // Timer 4 (8 bit) used as system tick timer + // prescaler == 128 (2^7), Tfreq = 125kHz + // period = 1ms, so ARR = 125 + TIM4_PSCR = 7; + TIM4_ARR = 125; + // interrupts: update + TIM4_IER = TIM_IER_UIE; + // auto-reload + interrupt on overflow + enable + TIM4_CR1 = TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN; + + // Configure pins + // PC2 - PP output (on-board LED) + PORT(LED_PORT, DDR) |= LED_PIN; + PORT(LED_PORT, CR1) |= LED_PIN; + // PD5 - UART2_TX -- pseudo open-drain output; don't forget an pullup resistor! + PORT(UART_PORT, DDR) |= UART_TX_PIN; + PORT(UART_PORT, ODR) &= ~UART_TX_PIN; // turn off N push-down + //PORT(UART_PORT, CR1) |= UART_TX_PIN; + PC_DDR |= GPIO_PIN1; // setup timer's output + PC_ODR &= ~GPIO_PIN1; + + // Configure UART + // 9 bit, no parity, 1 stop (UART_CR3 = 0 - reset value) + // 57600 on 16MHz: BRR1=0x11, BRR2=0x06 + UART2_BRR1 = 0x11; UART2_BRR2 = 0x06; + UART2_CR2 = UART_CR2_TEN | UART_CR2_REN | UART_CR2_RIEN; // Allow RX/TX, generate ints on rx + + configure_timers(); + + // enable all interrupts + enableInterrupts(); + + // Loop + do{ + if((Global_time - T > paused_val) || (T > Global_time)){ + T = Global_time; + PORT(LED_PORT, ODR) ^= LED_PIN; // blink on-board LED + } + if(UART_read_byte(&rb)){ // buffer isn't empty + switch(rb){ + case 'h': // help + case 'H': + uart_write("\nPROTO:\n" + "+/-\tLED period\n" + "P/p\tStart/stop playing\n" + "F\tSet frequency\n" + "t\tsawtooth\n" + "s\tsine\n" + "e\texp\n" + "l\tlog\n" + "r\trand\n" + ); + break; + break; + case '+': + paused_val += 100; + if(paused_val > 10000) + paused_val = 500; // but not more than 10s + break; + case '-': + paused_val -= 100; + if(paused_val < 100) // but not less than 0.1s + paused_val = 500; + break; + case 'F': + if(readInt(&Ival) && Ival > 64){ + change_period(((U16)Ival) >> 4); // F*4 for 16 array values + //change_period((U16)Ival); // F*4 for 16 array values + }else error_msg("bad period"); + break; + case 'P': + play_snd(); + break; + case 'p': + stop_snd(); + break; + case 't': + change_snd_bank(B_SAWTOOTH); + break; + case 's': + change_snd_bank(B_SINE); + break; + case 'e': + change_snd_bank(B_EXP); + break; + case 'l': + change_snd_bank(B_LOG); + break; + case 'r': + change_snd_bank(B_RAND); + break; + } + } + }while(1); +} + + diff --git a/Noice_generator/main.h b/Noice_generator/main.h new file mode 100644 index 0000000..436dd36 --- /dev/null +++ b/Noice_generator/main.h @@ -0,0 +1,42 @@ +/* + * blinky.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __MAIN_H__ +#define __MAIN_H__ + +extern unsigned long Global_time; // global time in ms + +#define UART_BUF_LEN 8 // max 7 bytes transmited in on operation +#define MIN_STEP_LENGTH 9 // max speed, microseconds for one microstep +#define THIS_DEVICE_NUM 1 // hardware number (0..255) can be changed by writting into EEPROM + +extern U8 UART_rx[]; +extern U8 UART_rx_start_i; +extern U8 UART_rx_cur_i; + +void UART_send_byte(U8 byte); +void uart_write(char *str); +void printUint(U8 *val, U8 len); +void error_msg(char *msg); + +#define check_UART_pointer(x) if(x == UART_BUF_LEN) x = 0; + +#endif // __MAIN_H__ diff --git a/Noice_generator/noicegen.c b/Noice_generator/noicegen.c new file mode 100644 index 0000000..b05e1c5 --- /dev/null +++ b/Noice_generator/noicegen.c @@ -0,0 +1,70 @@ +/* + * noicegen.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "noicegen.h" +//#include "main.h" + +/**** sound banks ****/ +// x_pi = [0:15]/15*pi; x_2pi = [0:15]/15*2*pi; +// sawtooth: V = sawtooth(x_pi)+1; waveforms(V, "sawtooth") +static const U8 sawtooth[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; +// sine: V = sin(x_2pi)/2+0.5; waveforms(V, "sine") +static const U8 sine[16] = {8, 11, 14, 16, 16, 15, 13, 10, 6, 3, 1, 0, 0, 2, 5, 8}; +// exp: waveforms(exp([0:15]/4), "exp") +static const U8 exp[16] = {0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 6, 7, 10, 12, 16}; +// log: waveforms(1-exp([0:15]/4), "log") +static const U8 log[16] = {16, 16, 16, 16, 15, 15, 15, 14, 14, 13, 12, 10, 9, 6, 4, 0}; +//pseudorand: waveforms(rand(1,16), "pseudorand") +static const U8 pseudorand[16] = {1, 3, 11, 11, 9, 5, 0, 9, 6, 8, 14, 12, 6, 13, 16, 14}; +static U8 *banks[5] = {sawtooth, sine, exp, log, pseudorand}; +// currend sound bank +unsigned char *current_bank = sawtooth; + +void configure_timers(){ + /**** TIMERS TIM1 - 1MHz, TIM2 - 1MHz ****/ + TIM1_PSCRH = 0; // this timer have 16 bit prescaler + TIM1_PSCRL = 3; // LSB should be written last as it updates prescaler + TIM2_PSCR = 4; + // Timer1 is PWM sound level generator + // Timer2 runs with F*16 to change voltage level (F - frequency of sound) + TIM1_ARRH = 0; + TIM1_ARRL = 16; + TIM1_CCR1H = 0; TIM1_CCR1L = 8; // default: 50% + // channel 1 generates PWM pulses + TIM1_CCMR1 = 0x60; // OC1M = 110b - PWM mode 1 ( 1 -> 0) + //TIM1_CCMR1 = 0x70; // OC1M = 111b - PWM mode 2 ( 0 -> 1) + TIM1_CCER1 = 1; // Channel 1 is on. Active is high + //TIM1_CCER1 = 3; // Channel 1 is on. Active is low + // default period: near 32ms + TIM2_ARRH = 127; TIM2_ARRL = 0; + // interrupts: update for timer 2, none for timer 1 + TIM1_IER = 0; + TIM2_IER = TIM_IER_UIE; + // enable PWM output for timer1 + TIM1_BKR |= 0x80; // MOE +} +/** + * Changes current sound "Bank" to i-th in banks + */ + +void change_snd_bank(U8 i){ + current_bank = banks[i]; +} diff --git a/Noice_generator/noicegen.h b/Noice_generator/noicegen.h new file mode 100644 index 0000000..5ede8ec --- /dev/null +++ b/Noice_generator/noicegen.h @@ -0,0 +1,48 @@ +/* + * noicegen.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __NOICEGEN_H__ +#define __NOICEGEN_H__ + +#include "stm8l.h" + +#define TIM_EN (TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN) + +// soundbank +enum { + B_SAWTOOTH, B_SINE, B_EXP, B_LOG, B_RAND +}; + +extern U8 *current_bank; +void configure_timers(); +void change_snd_bank(U8 i); + +// change period (in us) +#define change_period(F) do{TIM2_ARRH = F >> 8; TIM2_ARRL = F;}while(0) +// change CCR value. U = Vcc * +#define change_CCR(C) do{TIM1_CCR1H = 0; TIM1_CCR1L = C;}while(0) +#define play_snd() do{TIM1_CR1 = TIM_EN; TIM2_CR1 = TIM_EN;}while(0) +//#define stop_snd() do{TIM1_CR1 = 0; TIM2_CR1 = 0; PC_ODR &= ~GPIO_PIN1; }while(0) +#define stop_snd() do{TIM1_CR1 |= TIM_CR1_OPM; TIM2_CR1 = 0;}while(0) + + +#endif // __NOICEGEN_H__ diff --git a/Noice_generator/ports_definition.h b/Noice_generator/ports_definition.h new file mode 100644 index 0000000..90e5611 --- /dev/null +++ b/Noice_generator/ports_definition.h @@ -0,0 +1,43 @@ +/* + * ports_definition.h - definition of ports pins & so on + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __PORTS_DEFINITION_H__ +#define __PORTS_DEFINITION_H__ + +#include "stm8l.h" + +// macro for using in port constructions like PORT(LED_PORT, ODR) = xx +#define CONCAT(a,b) a##_##b +#define PORT(a,b) CONCAT(a,b) + +// on-board LED +#define LED_PORT PC +#define LED_PIN GPIO_PIN2 + +// UART2_TX +#define UART_PORT PD +#define UART_TX_PIN GPIO_PIN5 + + + + +#endif // __PORTS_DEFINITION_H__ diff --git a/Noice_generator/waveforms.m b/Noice_generator/waveforms.m new file mode 100644 index 0000000..593c2d1 --- /dev/null +++ b/Noice_generator/waveforms.m @@ -0,0 +1,12 @@ +function waveforms(FN, nm) +% Prints on stdout 16 values for waveform bank +% FN - array with 16 values of Vout (Vmin..Vmax), will be normalized +% nm - name of array + MIN = min(FN); MAX = max(FN); + FN = (FN - MIN) / (MAX - MIN); + VAL = round(FN * 16); + printf("static const U8 %s[16] = {", nm) + for i = 1:15; printf("%d, ", VAL(i)); endfor; + printf("%d};\n", VAL(16)); + plot(VAL, 'o'); +endfunction diff --git a/blinky/Makefile b/blinky/Makefile new file mode 100644 index 0000000..699c8e8 --- /dev/null +++ b/blinky/Makefile @@ -0,0 +1,39 @@ +NAME=testproj +SDCC=sdcc +HEX2BIN=hex2bin + +CCFLAGS=-DSTM8S003 -I../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx +LDFLAGS= -mstm8 --out-fmt-ihx +FLASHFLAGS=-cstlinkv2 -pstm8s003 + +SRC=$(wildcard *.c) +# ATTENTION: FIRST in list should be file with main() +OBJ=$(SRC:%.c=%.rel) +TRASH=$(OBJ) $(SRC:%.c=%.rst) $(SRC:%.c=%.asm) $(SRC:%.c=%.lst) +TRASH+=$(SRC:%.c=%.sym) $(NAME).ihx $(NAME).lk $(NAME).map +INDEPENDENT_HEADERS=../stm8l.h Makefile + +all: $(NAME).bin + +$(SRC) : %.c : %.h $(INDEPENDENT_HEADERS) + @touch $@ + @echo $@ + +%.h: ; + +clean: + rm -f $(TRASH) + +load: $(NAME).bin + stm8flash $(FLASHFLAGS) -wf $(NAME).bin + +%.rel: %.c + $(SDCC) $(CCFLAGS) -c $< + +$(NAME).ihx: $(OBJ) + $(SDCC) $(LDFLAGS) $(OBJ) -o $(NAME).ihx + +$(NAME).bin: $(NAME).ihx + $(HEX2BIN) -p 00 $< + +.PHONY: all diff --git a/blinky/blinky.c b/blinky/blinky.c new file mode 100644 index 0000000..aa3f818 --- /dev/null +++ b/blinky/blinky.c @@ -0,0 +1,235 @@ +/* + * blinky.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#include "stm8l.h" +#include "interrupts.h" +#include "blinky.h" +/* + * 0 0000 + * 1 0001 + * 2 0010 + * 3 0011 + * 4 0100 + * 5 0101 + * 6 0110 + * 7 0111 + * 8 1000 + * 9 1001 + * a 1010 + * b 1011 + * c 1100 + * d 1101 + * e 1110 + * f 1111 + */ + +/* + ********************* Internal timer (HSI) ******************** + * on startup: HSI = 2MHz (16/8) + * HSI divisor: CLK_CKDIVR: bits 4,3: f_{HSI}/2^x; bits2..0: f_{CPU}=f/2^x (page 93) + * CLK_PCKENR1/2 - enable periph clocking (page 94,95) reset value: all enabled + */ + +/* + ********************* Timer1 ******************** + * prescaler: TIM1_PSCRH/L, f = f_{in}/(TIM1_PSCR + 1) + * other registers: + * TIM1_CR1 (page 185): | ARPE | CMS[1:0] | DIR | OPM | URS | UDIS | CEN | + * ARPE - Auto-reload preload enable (for TIM1_ARR) + * CMS[1:0]: Center-aligned mode selection (0 - simple counter up/down) + * DIR: Direction (0 - up, 1 - down) + * OPM: One-pulse mode (1 - opm enabled) + * URS: Update request source (When enabled by the UDIS bit, 1 - interrupt only on counter overflow/underflow) + * UDIS: Update disable (1 - disable update int) + * CEN: Counter enable (1 - enable) + * TIM1_CR2 (page 187): | - | MMS [2:0] | - | COMS | - | CCPS | + * MMS[2:0]: Master mode selection (for ADC or other timers) + * COMS: Capture/compare control update selection + * CCPC: Capture/compare preloaded control + * TIM1_IER (page 191): | BIE | TIE | COMIE | CC4IE | CC3IE | CC2IE | CC1IE | UIE | + * B - break; T - trigger; COM - commutation; CC - comp/capt; U - update <-- + * TIM1_SR1 (page 192): similar (but instead of IE -> IF) + * interrupt flags + * TIM1_CNTRH, TIM1_CNTRL - counter value (automatical) + * TIM1_PSCRH, TIM1_PSCRL - prescaler value + * TIM1_ARRH, TIM1_ARRL - auto-reload value (while zero, timer is stopped) (page 206) + */ + +/* + ********************* External interrupts (page 69) ******************** + * EXTI_CR1: | PDIS[1:0] | PCIS[1:0] | PBIS[1:0] | PAIS[1:0] | + * per-port sensivity bits: + * 00: Falling edge and low level + * 01: Rising edge only + * 10: Falling edge only + * 11: Rising and falling edge + * EXTI_CR2: | -reserved[7:3]- | TLIS | PEIS[1:0] | + * TLIS: Top level interrupt sensitivity (0: Falling edge, 1 - Rising) + * PEIS[1:0]: Port E external interrupt sensitivity bits + * after config run enableInterrupts() + * ports: + * 5 lines on Port A: PA[6:2] + * 8 lines on Port B: PB[7:0] + * 8 lines on Port C: PC[7:0] + * 7 lines on Port D: PD[6:0] + * 8 lines on Port E: PE[7:0] + * PD7 is the Top Level Interrupt source (TLI), except for 20-pin packages + * on which the Top Level Interrupt source (TLI) can be available on the + * PC3 pin using an alternate function remapping option bit + */ + +/* + ********************* GPIO (page 111) ******************** + * Px_ODR - Output data register bits + * Px_IDR - Pin input values + * Px_DDR - Data direction bits (1 - output) + * Px_CR1 - DDR=0: 0 - floating, 1 - pull-up input; DDR=1: 0 - pseudo-open-drain, 1 - push-pull output [not for "T"] + * Px_CR2 - DDR=0: 0/1 - EXTI disabled/enabled; DDR=1: 0/1 - 2/10MHz + * + */ + +/* + ********************* UART ******************** + * baud rate: regs UART_BRR1/2 !!!VERY STUPID!!! + * f_{UART} = f_{master} / UART_DIV + * if UART_DIV = 0xABCD then + * UART_BRR1 = UART_DIV[11:4] = 0xBC; + * UART_BRR2 = UART_DIV[15:12|3:0] = 0xAD + * registers + * UART_SR: | TXE | TC | RXNE | IDLE | OR/LHE | NF | FE | PE | + * TXE: Transmit data register empty + * TC: Transmission complete + * RXNE: Read data register not empty + * IDLE: IDLE line detected + * OR: Overrun error / LHE: LIN Header Error (LIN slave mode) + * NF: Noise flag + * FE: Framing error + * PE: Parity error + * UART_DR: data register (when readed returns coming byte, when writed fills output shift register) + * UART_BRR1 / UART_BRR2 - see upper + * UART_CR1: | R8 | T8 | UARTD | M | WAKE | PCEN | PS | PIEN | + * R8, T8 - ninth bit (in 9-bit mode) + * UARTD: UART Disable (for low power consumption) + * M: word length (0 - 8bits, 1 - 9bits) + * WAKE: Wakeup method + * PCEN: Parity control enable + * PS: Parity selection (0 - even) + * PIEN: Parity interrupt enable + * UART_CR2: | TIEN | TCEN | RIEN | ILIEN | TEN | REN | RWU | SBK | + * TIEN: Transmitter interrupt enable + * TCIEN: Transmission complete interrupt enable + * RIEN: Receiver interrupt enable + * ILIEN: IDLE Line interrupt enable + * TEN: Transmitter enable <---------------------------------------- + * REN: Receiver enable <---------------------------------------- + * RWU: Receiver wakeup + * SBK: Send break + * UART_CR3: | - | LINEN | STOP[1:0] | CLCEN | CPOL | CPHA | LBCL | + * LINEN: LIN mode enable + * STOP: STOP bits + * CLKEN: Clock enable (CLC pin) + * CPOL: Clock polarity + * CPHA: Clock phase + * LBCL: Last bit clock pulse + */ + +/* + ********************* ADC (page 413) ******************** + * ADC_DBxRH / ADC_DRH: 9:2 data bits in left-aligned or 9:8 bits in right-aligned mode + * ADC_DBxRL / ADC_DRL: 1:0 data bits in left-aligned or 7:0 bits in right-aligned mode + * ADC_CSR: | EOC | AWD | EOCIE | AWDIE | CH[3:0] | + * EOC: End of conversion + * AWD: Analog Watchdog flag + * EOCIE: Interrupt enable for EOC + * AWDIE: Analog watchdog interrupt enable + * CH[3:0]: Channel selection bits (0..15) + * ADC_CR1: | - | SPSEL[2:0] | - | - | CONT | ADON | + * SPSEL[2:0]: Prescaler selection + * CONT: Continuous conversion (0 for single) + * ADON: A/D Converter on/off <---------------------------------------- + * ADC_CR2: | - | EXTTRIG | EXTSEL[1:0] | ALIGN | - | SCAN | - | + * EXTTRIG: External trigger enable + * EXTSEL[1:0]: External event selection + * ALIGN: Data alignment (1 - right alignment, first read ADC_DRL) + * SCAN: Scan mode enable + * ADC_CR3: | DBUF | OVR | reserved[5:0] | + * DBUF: Data buffer enable (on buffered mode data stored not in ADC_DBhl but in ADC_DBxRhl) + * OVR: Overrun flag + * ADC_TDRH/L - trigger shmidt disable (1 - disable) + */ + +unsigned long Global_time = 0L; // global time in ms +char onboard_blink = 1; // == 1 to blink on-board LED +int ADC_value = 500; // value of last ADC measurement + +int main() { + unsigned long T = 0L; + unsigned char LedCntr = 0; + // Configure clocking + CLK_CKDIVR = 0; // F_HSI = 16MHz, f_CPU = 16MHz + // Configure pins + PD_DDR = GPIO_PIN3; // PD3 - output, other are inputs + PD_CR1 = GPIO_PIN3|GPIO_PIN5; // PD3 is PPout, PD5 is input with pull-up, PD2 is floating input (for ADC) + PD_CR2 = GPIO_PIN5; // enable interrupts for PD5 + PD_ODR = GPIO_PIN3; // turn on LED on PD3 + // pin interrupts for PD2&PD5 + EXTI_CR1 = 0x80; // PDIS = 10 - falling edge + // 5 LEDs on PC3..PC7 + PC_DDR = 0xf8; + PC_CR1 = 0xf8; // PPout + // Configure Timer1 + // prescaler = f_{in}/f_{tim1} - 1 + // set Timer1 to 1MHz: 1/1 - 1 = 15 + TIM1_PSCRH = 0; + TIM1_PSCRL = 15; // LSB should be written last as it updates prescaler + // auto-reload each 1ms: TIM_ARR = 1000 = 0x03E8 + TIM1_ARRH = 0x03; + TIM1_ARRL = 0xE8; + // interrupts: update + TIM1_IER = TIM_IER_UIE; + // auto-reload + interrupt on overflow + enable + TIM1_CR1 = TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN; + // configure ADC + // select PD2[AIN3] & enable interrupt for EOC + ADC_CSR = 0x23; + ADC_TDRL = 0x08; // disable Schmitt triger for AIN3 + // right alignment + ADC_CR2 = 0x08; // don't forget: first read ADC_DRL! + // f_{ADC} = f/18 & continuous non-buffered conversion & wake it up + ADC_CR1 = 0x73; + ADC_CR1 = 0x73; // turn on ADC (this needs second write operation) + // enable all interrupts + enableInterrupts(); + // Loop + do { + // ADC_value sets half-period in ms + if((Global_time - T > (long)ADC_value) || (T > Global_time)){ + T = Global_time; + if(onboard_blink) PD_ODR ^= GPIO_PIN3; // blink on-board LED + PC_ODR = (LedCntr++) << 3; + if(LedCntr == 0x20) LedCntr = 0; + } + //if(!(PD_IDR & 0x20) && T < 650000L) T+= 5000L; + //else if(!(PD_IDR & 0x04) & T > 5000L) T -= 5000L; // PD2 + } while(1); +} + diff --git a/blinky/blinky.h b/blinky/blinky.h new file mode 100644 index 0000000..ef6a29a --- /dev/null +++ b/blinky/blinky.h @@ -0,0 +1,30 @@ +/* + * blinky.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __BLINKY_H__ +#define __BLINKY_H__ + +extern unsigned long Global_time; // global time in ms +extern char onboard_blink; // == 1 to blink on-board LED +extern int ADC_value; // value of last ADC measurement + +#endif // __BLINKY_H__ diff --git a/blinky/interrupts.c b/blinky/interrupts.c new file mode 100644 index 0000000..b605494 --- /dev/null +++ b/blinky/interrupts.c @@ -0,0 +1,153 @@ +/* + * interrupts.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "blinky.h" + +// Top Level Interrupt +INTERRUPT_HANDLER(TLI_IRQHandler, 0){} + +// Auto Wake Up Interrupt +INTERRUPT_HANDLER(AWU_IRQHandler, 1){} + +// Clock Controller Interrupt +INTERRUPT_HANDLER(CLK_IRQHandler, 2){} + +// External Interrupt PORTA +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3){} + +// External Interrupt PORTB +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4){} + +// External Interrupt PORTC +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5){} + +// External Interrupt PORTD +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6){ + if((PD_IDR & GPIO_PIN5) == 0){ // PD5 - switch on-board blinking + onboard_blink = !onboard_blink; + }; +} + +// External Interrupt PORTE +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7){} + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8){} +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8){} + +// CAN TX Interrupt routine. +INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9){} +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_HANDLER(SPI_IRQHandler, 10){} + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11){ + if(TIM1_SR1 & TIM_SR1_UIF){ // update interrupt + Global_time++; // increase timer + } + TIM1_SR1 = 0; // clear all interrupt flags +} + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12){} + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13){} + +// Timer5 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14){} + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13){} + +// Timer2 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14){} +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15){} + +// Timer3 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16){} +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17){} + +// UART1 RX Interrupt +INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18){} +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_HANDLER(I2C_IRQHandler, 19){} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){} + +// UART2 RX interrupt +INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21){} +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20){} + +// UART3 RX interrupt +INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21){} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_HANDLER(ADC2_IRQHandler, 22){} +#else +// ADC1 interrupt +INTERRUPT_HANDLER(ADC1_IRQHandler, 22){ + ADC_value = ADC_DRL; // in right-alignment mode we should first read LSB + ADC_value |= ADC_DRH << 8; + ADC_CSR &= 0x3f; // clear EOC & AWD flags +} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23){} +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23){} +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24){} diff --git a/blinky/interrupts.h b/blinky/interrupts.h new file mode 100644 index 0000000..6edf384 --- /dev/null +++ b/blinky/interrupts.h @@ -0,0 +1,144 @@ +/* + * interrupts.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __INTERRUPTS_H__ +#define __INTERRUPTS_H__ + +#include "stm8l.h" + +// Top Level Interrupt +INTERRUPT_DEFINITION(TLI_IRQHandler, 0); + +// Auto Wake Up Interrupt +INTERRUPT_DEFINITION(AWU_IRQHandler, 1); + +// Clock Controller Interrupt +INTERRUPT_DEFINITION(CLK_IRQHandler, 2); + +// External Interrupt PORTA +INTERRUPT_DEFINITION(EXTI_PORTA_IRQHandler, 3); + +// External Interrupt PORTB +INTERRUPT_DEFINITION(EXTI_PORTB_IRQHandler, 4); + +// External Interrupt PORTC +INTERRUPT_DEFINITION(EXTI_PORTC_IRQHandler, 5); + +// External Interrupt PORTD +INTERRUPT_DEFINITION(EXTI_PORTD_IRQHandler, 6); + +// External Interrupt PORTE +INTERRUPT_DEFINITION(EXTI_PORTE_IRQHandler, 7); + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_DEFINITION(EXTI_PORTF_IRQHandler, 8); +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_DEFINITION(CAN_RX_IRQHandler, 8); + +// CAN TX Interrupt routine. +INTERRUPT_DEFINITION(CAN_TX_IRQHandler, 9); +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_DEFINITION(SPI_IRQHandler, 10); + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_DEFINITION(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_DEFINITION(TIM1_CAP_COM_IRQHandler, 12); + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_DEFINITION(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); + +// Timer5 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM5_CAP_COM_IRQHandler, 14); + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM2_UPD_OVF_BRK_IRQHandler, 13); + +// Timer2 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM2_CAP_COM_IRQHandler, 14); +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM3_UPD_OVF_BRK_IRQHandler, 15); + +// Timer3 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM3_CAP_COM_IRQHandler, 16); +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_DEFINITION(UART1_TX_IRQHandler, 17); + +// UART1 RX Interrupt +INTERRUPT_DEFINITION(UART1_RX_IRQHandler, 18); +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_DEFINITION(I2C_IRQHandler, 19); + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_DEFINITION(UART2_TX_IRQHandler, 20); + +// UART2 RX interrupt +INTERRUPT_DEFINITION(UART2_RX_IRQHandler, 21); +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_DEFINITION(UART3_TX_IRQHandler, 20); + +// UART3 RX interrupt +INTERRUPT_DEFINITION(UART3_RX_IRQHandler, 21); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_DEFINITION(ADC2_IRQHandler, 22); +#else // STM8S105, STM8S103 or STM8S903 or STM8AF626x +// ADC1 interrupt +INTERRUPT_DEFINITION(ADC1_IRQHandler, 22); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_DEFINITION(TIM6_UPD_OVF_TRG_IRQHandler, 23); +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_DEFINITION(TIM4_UPD_OVF_IRQHandler, 23); +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_DEFINITION(EEPROM_EEC_IRQHandler, 24); + +#endif // __INTERRUPTS_H__ diff --git a/blinky/testproj.bin b/blinky/testproj.bin new file mode 100644 index 0000000000000000000000000000000000000000..4a2ad549bd38fc4cc2cc4414ef4e67a3756e42ab GIT binary patch literal 533 zcmYk3yGz4R6o=1E(xwecZ91qpq~N3CKjGp~K`@jE(jxUScB^BDwo$<`4yE8wtF{-r z++E!qDoANJ-F=S^lIZ3yQPB(E$2sSod&nU+Rd#G5vZ>Mp$KV8v@< z#BC>Mv@V63Y=5gc)S-HpSchuPfaC!&bd-N5SRprGA5d6W z3WC+2b96&$y>Ua~T5v^fYhGC7;Za7*8;T*tm@vC#Va9pH6Q<5*;RH{@v7plA6~sgQ z10MFBSucys29F`yO!w$&}oy9>f@w)2jF>#Mt{60*b*m literal 0 HcmV?d00001 diff --git a/led/Makefile b/led/Makefile new file mode 100644 index 0000000..4d04c2e --- /dev/null +++ b/led/Makefile @@ -0,0 +1,39 @@ +NAME=testproj +SDCC=sdcc +HEX2BIN=hex2bin + +CCFLAGS=-DSTM8S003 -I../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx +LDFLAGS= -lstm8 -mstm8 --out-fmt-ihx +FLASHFLAGS=-cstlinkv2 -pstm8s003 + +SRC=$(wildcard *.c) +# ATTENTION: FIRST in list should be file with main() +OBJ=$(SRC:%.c=%.rel) +TRASH=$(OBJ) $(SRC:%.c=%.rst) $(SRC:%.c=%.asm) $(SRC:%.c=%.lst) +TRASH+=$(SRC:%.c=%.sym) $(NAME).ihx $(NAME).lk $(NAME).map +INDEPENDENT_HEADERS=../stm8l.h Makefile + +all: $(NAME).bin + +$(SRC) : %.c : %.h $(INDEPENDENT_HEADERS) + @touch $@ + @echo $@ + +%.h: ; + +clean: + rm -f $(TRASH) + +load: $(NAME).bin + stm8flash $(FLASHFLAGS) -wf $(NAME).bin + +%.rel: %.c + $(SDCC) $(CCFLAGS) -c $< + +$(NAME).ihx: $(OBJ) + $(SDCC) $(LDFLAGS) $(OBJ) -o $(NAME).ihx + +$(NAME).bin: $(NAME).ihx + $(HEX2BIN) -p 00 $< + +.PHONY: all diff --git a/led/interrupts.c b/led/interrupts.c new file mode 100644 index 0000000..61f6d2e --- /dev/null +++ b/led/interrupts.c @@ -0,0 +1,150 @@ +/* + * interrupts.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "interrupts.h" + +// Top Level Interrupt +INTERRUPT_HANDLER(TLI_IRQHandler, 0){} + +// Auto Wake Up Interrupt +INTERRUPT_HANDLER(AWU_IRQHandler, 1){} + +// Clock Controller Interrupt +INTERRUPT_HANDLER(CLK_IRQHandler, 2){} + +// External Interrupt PORTA +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3){} + +// External Interrupt PORTB +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4){} + +// External Interrupt PORTC +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5){} + +// External Interrupt PORTD +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6){ +} + +// External Interrupt PORTE +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7){} + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8){} +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8){} + +// CAN TX Interrupt routine. +INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9){} +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_HANDLER(SPI_IRQHandler, 10){} + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11){ + if(TIM1_SR1 & TIM_SR1_UIF){ // update interrupt + Global_time++; // increase timer + } + TIM1_SR1 = 0; // clear all interrupt flags +} + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12){} + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13){} + +// Timer5 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14){} + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13){} + +// Timer2 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14){} +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15){} + +// Timer3 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16){} +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17){} + +// UART1 RX Interrupt +INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18){} +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_HANDLER(I2C_IRQHandler, 19){} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){} + +// UART2 RX interrupt +INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21){} +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20){} + +// UART3 RX interrupt +INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21){} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_HANDLER(ADC2_IRQHandler, 22){} +#else +// ADC1 interrupt +INTERRUPT_HANDLER(ADC1_IRQHandler, 22){ + ADC_value = ADC_DRL; // in right-alignment mode we should first read LSB + ADC_value |= ADC_DRH << 8; + ADC_CSR &= 0x3f; // clear EOC & AWD flags +} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23){} +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23){} +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24){} diff --git a/led/interrupts.h b/led/interrupts.h new file mode 100644 index 0000000..5a17e8b --- /dev/null +++ b/led/interrupts.h @@ -0,0 +1,147 @@ +/* + * interrupts.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __INTERRUPTS_H__ +#define __INTERRUPTS_H__ + +#include "stm8l.h" + +extern unsigned long Global_time; // global time in ms +extern int ADC_value; // value of last ADC measurement + +// Top Level Interrupt +INTERRUPT_DEFINITION(TLI_IRQHandler, 0); + +// Auto Wake Up Interrupt +INTERRUPT_DEFINITION(AWU_IRQHandler, 1); + +// Clock Controller Interrupt +INTERRUPT_DEFINITION(CLK_IRQHandler, 2); + +// External Interrupt PORTA +INTERRUPT_DEFINITION(EXTI_PORTA_IRQHandler, 3); + +// External Interrupt PORTB +INTERRUPT_DEFINITION(EXTI_PORTB_IRQHandler, 4); + +// External Interrupt PORTC +INTERRUPT_DEFINITION(EXTI_PORTC_IRQHandler, 5); + +// External Interrupt PORTD +INTERRUPT_DEFINITION(EXTI_PORTD_IRQHandler, 6); + +// External Interrupt PORTE +INTERRUPT_DEFINITION(EXTI_PORTE_IRQHandler, 7); + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_DEFINITION(EXTI_PORTF_IRQHandler, 8); +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_DEFINITION(CAN_RX_IRQHandler, 8); + +// CAN TX Interrupt routine. +INTERRUPT_DEFINITION(CAN_TX_IRQHandler, 9); +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_DEFINITION(SPI_IRQHandler, 10); + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_DEFINITION(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_DEFINITION(TIM1_CAP_COM_IRQHandler, 12); + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_DEFINITION(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); + +// Timer5 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM5_CAP_COM_IRQHandler, 14); + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM2_UPD_OVF_BRK_IRQHandler, 13); + +// Timer2 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM2_CAP_COM_IRQHandler, 14); +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM3_UPD_OVF_BRK_IRQHandler, 15); + +// Timer3 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM3_CAP_COM_IRQHandler, 16); +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_DEFINITION(UART1_TX_IRQHandler, 17); + +// UART1 RX Interrupt +INTERRUPT_DEFINITION(UART1_RX_IRQHandler, 18); +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_DEFINITION(I2C_IRQHandler, 19); + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_DEFINITION(UART2_TX_IRQHandler, 20); + +// UART2 RX interrupt +INTERRUPT_DEFINITION(UART2_RX_IRQHandler, 21); +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_DEFINITION(UART3_TX_IRQHandler, 20); + +// UART3 RX interrupt +INTERRUPT_DEFINITION(UART3_RX_IRQHandler, 21); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_DEFINITION(ADC2_IRQHandler, 22); +#else // STM8S105, STM8S103 or STM8S903 or STM8AF626x +// ADC1 interrupt +INTERRUPT_DEFINITION(ADC1_IRQHandler, 22); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_DEFINITION(TIM6_UPD_OVF_TRG_IRQHandler, 23); +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_DEFINITION(TIM4_UPD_OVF_IRQHandler, 23); +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_DEFINITION(EEPROM_EEC_IRQHandler, 24); + +#endif // __INTERRUPTS_H__ diff --git a/led/led.c b/led/led.c new file mode 100644 index 0000000..145cdde --- /dev/null +++ b/led/led.c @@ -0,0 +1,243 @@ +/* + * led.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "led.h" + +/* + * bits no 7 6 5 4 3 2 1 0 + * dec value 128 64 32 16 8 4 2 1 + */ + +/********** one variant **********/ +/* + * One digit: TABLE: + * ***A*** 0 1 2 3 4 5 6 7 8 9 A B C D E F - h + * * * (A) PB4 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 + * F B (F) PB5 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 + * * * (B) PC5 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 + * ***G*** (G) PC6 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 + * * * (C) PC7 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 + * E C (E) PD1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 0 + * * * ** (D) PD2 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1 1 + * ***D*** *DP* (DP)PD3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + * ** + */ +/* +// PB, mask: 0x30, PB4: 0x10, PB5: 0x20 +#define PB_BLANK 0x30 +static U8 PB_bits[18] = {0,0x30,0x20,0x20,0x10,0,0,0x20,0,0,0,0x10,0,0x30,0,0,0x30,0x10}; +// PC, mask: 0xe0, PC5: 0x20, PC6: 0x40, PC7: 0x80 +#defin PC_BLANK 0xe0 +static U8 PC_bits[18] = {0x40,0x40,0x80,0,0,0x20,0x20,0x40,0,0,0,0x20,0xe0,0,0xa0,0xa0,0xa0,0x20}; +// PD, mask: 0x0e, PD1: 0x02, PD2: 0x04, PD3: 0x08 +#define PD_BLANK 0x0e +static U8 PD_bits[18] = {0x08,0x0e,0x08,0x0a,0x0e,0x0a,0x08,0x0e,0x08,0x0a,0x0c,0x8,0x08,0x08,0x08,0x0c,0x0e,0x0c}; +*/ +/* + * Number of digit on indicator with common anode + * digis 0..3: PC3, PC4, PA3, PD4 + */ + + +/********** current variant **********/ +/* + * One digit: TABLE: + * ***A*** 0 1 2 3 4 5 6 7 8 9 A B C D E F - h + * * * (F) PA1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 + * F B (B) PB4 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 + * * * (A) PB5 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 + * ***G*** (G) PC3 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 + * * * (C) PC4 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 + * E C (DP)PC5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + * * * ** (D) PC6 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1 1 + * ***D*** *DP* (E) PC7 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 0 + * ** + */ + +/* + * Number of digit on indicator with common anode + * digis 0..3: PA3, PD6, PD4, PD1 + */ + +/************* arrays for ports *************/ +// PA, mask: 0x02, PA1 +static U8 PA_bits[18] = {0,2,2,2,0,0,0,2,0,0,0,0,0,2,0,0,2,0}; +#define PA_BLANK 0x02 +// PB, mask: 0x30, PB4:0x10=16, PB5:0x20=32 +#define PB_BLANK 0x30 +static U8 PB_bits[18] = {0,32,0,0,32,16,16,0,0,0,0,48,16,32,16,16,48,48}; +// PC, mask: 0xF8, PC3:0x08=8, PC4:0x10=16, PC5:0x20=32, PC6:0x40=64, PC7:0x80=128 +#define PC_BLANK 0xF8 +static U8 PC_bits[18] = {40,232,48,160,224,160,32,232,32,160,96,32,56,32,48,112,240,96}; + +/** + * Setup for writing a letter + * @param ltr - letter (0..17 for 0..F, - or h | 0x80 for DP, any other value for 'space') + */ +void write_letter(U8 ltr){ + U8 L = ltr & 0x7f; + PD_ODR = 0; // turn off digits 1..3 + if(L < 18){ // letter + PA_ODR = PA_bits[L]; + PB_ODR = PB_bits[L]; + PC_ODR = PC_bits[L]; + }else{ // space + PA_ODR = PA_BLANK; + PB_ODR = PB_BLANK; + PC_ODR = PC_BLANK; + } + if(ltr & 0x80){ // DP + PC_ODR ^= 0x20; + } +} + +/** + * Turn on anode power for digit N (0..3: PA3, PD6, PD4, PD1 -- A0x08, D0x40, D0x10, D0x02) + * @param N - number of digit (0..3), if other - no action (display off) + * @return + */ +void light_up_digit(U8 N){ + switch(N){ + case 0: + PA_ODR |= 0x08; + break; + case 1: + PD_ODR |= 0x40; + break; + case 2: + PD_ODR |= 0x10; + break; + case 3: + PD_ODR |= 0x02; + break; + } +} + +static U8 display_buffer[4] = {' ',' ',' ',' '}; // blank by default +static U8 N_current = 0; // current digit to display + +/** + * fills buffer to display + * @param str - string to display, contains "0..f" for digits, " " for space, "." for DP + * for example: " 1.22" or "h1ab" (something like "0...abc" equivalent to "0.abc" + * register independent! + * any other letter would be omitted + * if NULL - fill buffer with spaces + */ +void set_display_buf(char *str){ + U8 B[4]; + char ch, M = 0, i; + N_current = 0; // refresh current digit number + // empty buffer + for(i = 0; i < 4; i++) + display_buffer[i] = ' '; + if(!str) return; + i = 0; + for(;(ch = *str) && (i < 4); str++){ + M = 0; + if(ch > '/' && ch < ':'){ // digit + M = '0'; + }else if(ch > '`' & ch < 'g'){ // a..f + M = 'a' - 10; + }else if(ch > '@' & ch < 'G'){ // A..F + M = 'A' - 10; + }else if(ch == '-'){ // minus + M = '-' - 16; + }else if(ch == 'h'){ // hex + M = 'h' - 17; + }else if(ch == 'H'){ // hex + M = 'H' - 17; + }else if(ch == '.'){ // DP, set it to previous char + if(i == 0){ // word starts from '.' - make a space with point + B[0] = 0xff; + }else{ // set point for previous character + B[i-1] |= 0x80; + } + continue; + }else if(ch != ' '){ // bad character - continue + continue; + } + B[i] = ch - M; + i++; + } + // now make align to right + ch = 3; + for(M = i-1; M > -1; M--, ch--){ + display_buffer[ch] = B[M]; + } +} + +/** + * Show Nth digit of buffer (function ran by timer) + * @param N - number of digit in buffer (0..3) + */ +void show_buf_digit(U8 N){ + if(N > 3) return; + write_letter(display_buffer[N]); + light_up_digit(N); +} + +/** + * Show next digit - function calls from main() by some system time value amount + */ +void show_next_digit(){ + show_buf_digit(N_current++); + if(N_current > 3) N_current = 0; +} + +/** + * convert integer value i into string and display it + * @param i - value to display, -999 <= i <= 9999, if wrong, displays "---E" + */ +void display_int(int I){ + int rem; + char N = 3, sign = 0; + if(I < -999 || I > 9999){ + set_display_buf("---E"); + return; + } + set_display_buf(NULL); // empty buffer + if(I == 0){ // just show zero + display_buffer[3] = 0; + return; + } + if(I < 0){ + sign = 1; + I *= -1; + } + do{ + rem = I % 10; + display_buffer[N] = rem; + I /= 10; + }while(--N > -1 && I); + if(sign && N > -1) display_buffer[N] = 16; // minus sign +} + + +/** + * displays digital point at position i + * @param i - position to display DP, concequent calls can light up many DPs + */ +void display_DP_at_pos(U8 i){ + if(i > 3) return; + display_buffer[i] |= 0x80; +} diff --git a/led/led.h b/led/led.h new file mode 100644 index 0000000..858f51b --- /dev/null +++ b/led/led.h @@ -0,0 +1,48 @@ +/* + * led.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __LED_H__ +#define __LED_H__ +#include "stm8l.h" + +void set_display_buf(char *str); +void show_buf_digit(U8 N); +void show_next_digit(); +void display_int(int i); +void display_DP_at_pos(U8 i); + +/** + * Initialize ports + * PA3, PB4|5, PC3|4|5|6|7, PD1|2|3|4 + * +#define LED_init() do{ \ + PA_DDR = 0x08; PB_DDR = 0x30; PC_DDR = 0xf8; PD_DDR = 0x1e; \ + PA_CR1 = 0x08; PB_CR1 = 0x30; PC_CR1 = 0xf8; PD_CR1 = 0x1e; \ + }while(0) +*/ + +// PA1|3, PB4|5, PC3|4|5|6|7, PD1|4|6 +#define LED_init() do{ \ + PA_DDR = 0x0a; PB_DDR = 0x30; PC_DDR = 0xf8; PD_DDR = 0x52; \ + PA_CR1 = 0x0a; PB_CR1 = 0x30; PC_CR1 = 0xf8; PD_CR1 = 0x52; \ + }while(0) + +#endif // __LED_H__ diff --git a/led/main.c b/led/main.c new file mode 100644 index 0000000..7c77b5a --- /dev/null +++ b/led/main.c @@ -0,0 +1,85 @@ +/* + * main.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#include "stm8l.h" +#include "interrupts.h" +#include "led.h" + +#define DIGIT_PER 10 +unsigned long Global_time = 0L; // global time in ms +int ADC_value = 0; // value of last ADC measurement +U8 LED_delay = 1; // one digit emitting time + +int main() { + unsigned long T_LED = 0L; // time of last digit update + unsigned long T_time = 0L; // timer + int i = -1200; + // Configure clocking + CLK_CKDIVR = 0; // F_HSI = 16MHz, f_CPU = 16MHz + // Configure pins + CFG_GCR |= 1; // disable SWIM + LED_init(); + // Configure Timer1 + // prescaler = f_{in}/f_{tim1} - 1 + // set Timer1 to 1MHz: 1/1 - 1 = 15 + TIM1_PSCRH = 0; + TIM1_PSCRL = 15; // LSB should be written last as it updates prescaler + // auto-reload each 1ms: TIM_ARR = 1000 = 0x03E8 + TIM1_ARRH = 0x03; + TIM1_ARRL = 0xE8; + // interrupts: update + TIM1_IER = TIM_IER_UIE; + // auto-reload + interrupt on overflow + enable + TIM1_CR1 = TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN; + // configure ADC + // select PD2[AIN3] & enable interrupt for EOC + ADC_CSR = 0x23; + ADC_TDRL = 0x08; // disable Schmitt triger for AIN3 + // right alignment + ADC_CR2 = 0x08; // don't forget: first read ADC_DRL! + // f_{ADC} = f/18 & continuous non-buffered conversion & wake it up + ADC_CR1 = 0x73; + ADC_CR1 = 0x73; // turn on ADC (this needs second write operation) + // enable all interrupts + enableInterrupts(); + display_int(i++); + show_next_digit(); // show zero + // Loop + do { + if(((unsigned int)(Global_time - T_time) > DIGIT_PER) || (T_time > Global_time)){ // set next timer value + T_time = Global_time; + display_int(i++); + if(i > 9999) i = -1200; + // check ADC value to light up DPs proportionaly + if(ADC_value > 819) display_DP_at_pos(0); // big value == 4 points + if(ADC_value > 614) display_DP_at_pos(1); // less == 3 points + if(ADC_value > 410) display_DP_at_pos(2); // little == 2 points + if(ADC_value > 205) display_DP_at_pos(3); // more little == 1 point + // values less than 206 == 0 + } + if((U8)(Global_time - T_LED) > LED_delay){ + T_LED = Global_time; + show_next_digit(); + } + } while(1); +} + diff --git a/led/testproj.bin b/led/testproj.bin new file mode 100644 index 0000000000000000000000000000000000000000..709d99729c1b676000468c8a4d4a501613d9c5a1 GIT binary patch literal 1517 zcmYjROK%%h6ux)vjAt_Obo{8CG=Z6`H1Z%6#}+I=U6c?}Q4vgx6)3`y93F*A-XJ3( zp;WU(e0`2K_tik8{2U4N{k2 zk!QYOossqHvPXy|SCxi%;LJ?6ri}zNfVYzceByU9o`QU8q+$WLF_I)C?!znVn`kT zWm7VlS2(D7wYA|s1^Qk=a8;n}=73T6A7I=q0$J!+LcbRJ6M?_DR`ZG%CyRv0ytHXM`^4^`l}XH~DD4)1ZG@6>J9 zCDuhCwWffA#evL9^LZo>_myBHK7&IH_ZNUZPlY@da;yZu5b%02SuK-Ak6bmi<#MNb zqBULaJ8yTz?B7Nz&HB#VH_s8#RCJn3O{j)Ctgxmnyj9Vhd@xH;qnHiIavLYeW}?6= z^AR`K?r;1BzBVW7NiMpyl7#v^%a*y|(u>Kw6>)Ez#VjBu5ym7C^XAi-MBb9zSK9m< zoSC%bKHuh7KyQKGX!9)Sbx;J%g3hNWHJX+U#Xa?Tx@<>Li!$6__xUBv@^rFQwrQ(V zeXQ7QD@He4ev}&Os;TxjUbLeX!4@iUmsOY@@1AC+$~FsnVd`Z&9xi0)z8Y5URL+HS<$V3^SM^LL zbBz=wL%|WUqArC`N75td{SIYsS^~R9J_fNL9|ek>P5vEA7v|H zwxTJ>9uKm|O=@VPITp?_jaf1K!a_w}PH2@#Dl#ErNo_(*i3YuCE0ZiAEUMJ;$HbsS o5Cq%<3lW6lip2t*i-F{FFC6D~AMWyFzPrX><+(2&t#J(UANE1#VE_OC literal 0 HcmV?d00001 diff --git a/stepper/Makefile b/stepper/Makefile new file mode 100644 index 0000000..b739ed5 --- /dev/null +++ b/stepper/Makefile @@ -0,0 +1,39 @@ +NAME=testproj +SDCC=sdcc +HEX2BIN=hex2bin + +CCFLAGS=-DSTM8S105 -I../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx +LDFLAGS= -mstm8 --out-fmt-ihx -lstm8 +FLASHFLAGS=-cstlinkv2 -pstm8s105 + +SRC=$(wildcard *.c) +# ATTENTION: FIRST in list should be file with main() +OBJ=$(SRC:%.c=%.rel) +TRASH=$(OBJ) $(SRC:%.c=%.rst) $(SRC:%.c=%.asm) $(SRC:%.c=%.lst) +TRASH+=$(SRC:%.c=%.sym) $(NAME).ihx $(NAME).lk $(NAME).map +INDEPENDENT_HEADERS=../stm8l.h Makefile + +all: $(NAME).bin + +$(SRC) : %.c : %.h $(INDEPENDENT_HEADERS) + @touch $@ + @echo $@ + +%.h: ; + +clean: + rm -f $(TRASH) + +load: $(NAME).bin + stm8flash $(FLASHFLAGS) -wf $(NAME).bin + +%.rel: %.c + $(SDCC) $(CCFLAGS) -c $< + +$(NAME).ihx: $(OBJ) + $(SDCC) $(LDFLAGS) $(OBJ) -o $(NAME).ihx + +$(NAME).bin: $(NAME).ihx + $(HEX2BIN) -p 00 $< + +.PHONY: all diff --git a/stepper/client-term/Makefile b/stepper/client-term/Makefile new file mode 100644 index 0000000..19bac1f --- /dev/null +++ b/stepper/client-term/Makefile @@ -0,0 +1,22 @@ +PROGRAM = client +LDFLAGS = +SRCS = client.c +CC = gcc +DEFINES = -D_XOPEN_SOURCE=501 +CXX = gcc +CFLAGS = -Wall -Werror $(DEFINES) +OBJS = $(SRCS:.c=.o) +all : $(PROGRAM) clean +$(PROGRAM) : $(OBJS) + $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(PROGRAM) + +# some addition dependencies +# %.o: %.c +# $(CC) $(LDFLAGS) $(CFLAGS) $< -o $@ +#$(SRCS) : %.c : %.h $(INDEPENDENT_HEADERS) +# @touch $@ + +clean: + /bin/rm -f *.o *~ +depend: + $(CXX) -MM $(CXX.SRCS) diff --git a/stepper/client-term/client.c b/stepper/client-term/client.c new file mode 100644 index 0000000..453ad22 --- /dev/null +++ b/stepper/client-term/client.c @@ -0,0 +1,222 @@ +/* + * client.c - simple terminal client + * + * Copyright 2013 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include // tcsetattr +#include // tcsetattr, close, read, write +#include // ioctl +#include // printf, getchar, fopen, perror +#include // exit +#include // read +#include // read +#include // signal +#include // time +#include // memcpy +#include // int types +#include // gettimeofday + +double t0; // start time + +FILE *fout = NULL; // file for messages duplicating +char *comdev = "/dev/ttyUSB0"; +int BAUD_RATE = B57600; +struct termio oldtty, tty; // TTY flags +struct termios oldt, newt; // terminal flags +int comfd; // TTY fd + +/** + * function for different purposes that need to know time intervals + * @return double value: time in seconds + */ +double dtime(){ + double t; + struct timeval tv; + gettimeofday(&tv, NULL); + t = tv.tv_sec + ((double)tv.tv_usec)/1e6; + return t; +} + +/** + * Exit & return terminal to old state + * @param ex_stat - status (return code) + */ +void quit(int ex_stat){ + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // return terminal to previous state + ioctl(comfd, TCSANOW, &oldtty ); // return TTY to previous state + close(comfd); + if(fout) fclose(fout); + printf("Exit! (%d)\n", ex_stat); + exit(ex_stat); +} + +/** + * Open & setup TTY, terminal + */ +void tty_init(){ + // terminal without echo + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + if(tcsetattr(STDIN_FILENO, TCSANOW, &newt) < 0) quit(-2); + printf("\nOpen port...\n"); + if ((comfd = open(comdev,O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0){ + fprintf(stderr,"Can't use port %s\n",comdev); + quit(1); + } + printf(" OK\nGet current settings...\n"); + if(ioctl(comfd,TCGETA,&oldtty) < 0) exit(-1); // Get settings + tty = oldtty; + tty.c_lflag = 0; // ~(ICANON | ECHO | ECHOE | ISIG) + tty.c_oflag = 0; + tty.c_cflag = BAUD_RATE|CS8|CREAD|CLOCAL; // 9.6k, 8N1, RW, ignore line ctrl + tty.c_cc[VMIN] = 0; // non-canonical mode + tty.c_cc[VTIME] = 5; + if(ioctl(comfd,TCSETA,&tty) < 0) exit(-1); // set new mode + printf(" OK\n"); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); +} + +/** + * Read character from console without echo + * @return char readed + */ +int read_console(){ + int rb; + struct timeval tv; + int retval; + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(STDIN_FILENO, &rfds); + tv.tv_sec = 0; tv.tv_usec = 10000; + retval = select(1, &rfds, NULL, NULL, &tv); + if(!retval) rb = 0; + else { + if(FD_ISSET(STDIN_FILENO, &rfds)) rb = getchar(); + else rb = 0; + } + return rb; +} + +/** + * getchar() without echo + * wait until at least one character pressed + * @return character readed + */ +int mygetchar(){ // аналог getchar() без необходимости жать Enter + int ret; + do ret = read_console(); + while(ret == 0); + return ret; +} + +/** + * Read data from TTY + * @param buff (o) - buffer for data read + * @param length - buffer len + * @return amount of readed bytes + */ +size_t read_tty(uint8_t *buff, size_t length){ + ssize_t L = 0; + fd_set rfds; + struct timeval tv; + int retval; + FD_ZERO(&rfds); + FD_SET(comfd, &rfds); + tv.tv_sec = 0; tv.tv_usec = 10000; // wait for 10ms + retval = select(comfd + 1, &rfds, NULL, NULL, &tv); + if (!retval) return 0; + if(FD_ISSET(comfd, &rfds)){ + if((L = read(comfd, buff, length)) < 1) return 0; + } + return (size_t)L; +} + +void help(){ + printf("Use this commands:\n" + "h\tShow this help\n" + "q\tQuit\n" + ); +} + +#define dup_pr(...) do{printf(__VA_ARGS__); if(fout) fprintf(fout, __VA_ARGS__);}while(0) + +void con_sig(int rb){ + uint8_t cmd; + if(rb < 1) return; + if(rb == 'q') quit(0); // q == exit + cmd = (uint8_t) rb; + write(comfd, &cmd, 1); + /*switch(rb){ + case 'h': + help(); + break; + default: + cmd = (uint8_t) rb; + write(comfd, &cmd, 1); + }*/ +} + +/** + * Get integer value from buffer + * @param buff (i) - buffer with int + * @param len - length of data in buffer (could be 2 or 4) + * @return + */ +uint32_t get_int(uint8_t *buff, size_t len){ + if(len != 2 && len != 4){ + fprintf(stdout, "Bad data length!\n"); + return 0xffffffff; + } + uint32_t data = 0; + uint8_t *i8 = (uint8_t*) &data; + if(len == 2) memcpy(i8, buff, 2); + else memcpy(i8, buff, 4); + return data; +} + +int main(int argc, char *argv[]){ + int rb; + uint8_t buff[128]; + size_t L; + if(argc == 2){ + fout = fopen(argv[1], "a"); + if(!fout){ + perror("Can't open output file"); + exit(-1); + } + setbuf(fout, NULL); + } + tty_init(); + signal(SIGTERM, quit); // kill (-15) + signal(SIGINT, quit); // ctrl+C + signal(SIGQUIT, SIG_IGN); // ctrl+\ . + signal(SIGTSTP, SIG_IGN); // ctrl+Z + setbuf(stdout, NULL); + t0 = dtime(); + while(1){ + rb = read_console(); + if(rb > 0) con_sig(rb); + L = read_tty(buff, 127); + if(L){ + buff[L] = 0; + printf("%s", buff); + if(fout) fprintf(fout, "%zd\t%s\n", time(NULL), buff); + } + } +} diff --git a/stepper/interrupts.c b/stepper/interrupts.c new file mode 100644 index 0000000..9f6ebac --- /dev/null +++ b/stepper/interrupts.c @@ -0,0 +1,169 @@ +/* + * interrupts.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "ports_definition.h" +#include "main.h" +#include "stepper.h" + +// Top Level Interrupt +INTERRUPT_HANDLER(TLI_IRQHandler, 0){} + +// Auto Wake Up Interrupt +INTERRUPT_HANDLER(AWU_IRQHandler, 1){} + +// Clock Controller Interrupt +INTERRUPT_HANDLER(CLK_IRQHandler, 2){} + +// External Interrupt PORTA +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3){} + +// External Interrupt PORTB +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4){} + +// External Interrupt PORTC +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5){} + +// External Interrupt PORTD +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6){ +} + +// External Interrupt PORTE +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7){} + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8){} +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8){} + +// CAN TX Interrupt routine. +INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9){} +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_HANDLER(SPI_IRQHandler, 10){} + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11){ + if(TIM1_SR1 & TIM_SR1_UIF){ // update interrupt + Global_time++; // increase timer + } + TIM1_SR1 = 0; // clear all interrupt flags +} + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12){} + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13){} + +// Timer5 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14){} + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13){ // generate pulses for stepper CLK + if(TIM2_SR1 & TIM_SR1_UIF){ + TIM2_SR1 &= ~TIM_SR1_UIF; + if(--Nsteps == 0){ + stop_motor(); + } + } +} + +// Timer2 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14){ +} +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15){} + +// Timer3 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16){} +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17){} + +// UART1 RX Interrupt +INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18){} +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_HANDLER(I2C_IRQHandler, 19){} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){} + +// UART2 RX interrupt +INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21){ + U8 rb; + if(UART2_SR & UART_SR_RXNE){ // data received + rb = UART2_DR; // read received byte & clear RXNE flag + while(!(UART2_SR & UART_SR_TXE)); + UART2_DR = rb; // echo received symbol + UART_rx[UART_rx_cur_i++] = rb; // put received byte into cycled buffer + if(UART_rx_cur_i == UART_rx_start_i){ // Oops: buffer overflow! Just forget old data + UART_rx_start_i++; + check_UART_pointer(UART_rx_start_i); + } + check_UART_pointer(UART_rx_cur_i); + } +} +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20){} + +// UART3 RX interrupt +INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21){} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_HANDLER(ADC2_IRQHandler, 22){} +#else +// ADC1 interrupt +INTERRUPT_HANDLER(ADC1_IRQHandler, 22){ +} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23){} +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23){} +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24){} diff --git a/stepper/interrupts.h b/stepper/interrupts.h new file mode 100644 index 0000000..6edf384 --- /dev/null +++ b/stepper/interrupts.h @@ -0,0 +1,144 @@ +/* + * interrupts.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __INTERRUPTS_H__ +#define __INTERRUPTS_H__ + +#include "stm8l.h" + +// Top Level Interrupt +INTERRUPT_DEFINITION(TLI_IRQHandler, 0); + +// Auto Wake Up Interrupt +INTERRUPT_DEFINITION(AWU_IRQHandler, 1); + +// Clock Controller Interrupt +INTERRUPT_DEFINITION(CLK_IRQHandler, 2); + +// External Interrupt PORTA +INTERRUPT_DEFINITION(EXTI_PORTA_IRQHandler, 3); + +// External Interrupt PORTB +INTERRUPT_DEFINITION(EXTI_PORTB_IRQHandler, 4); + +// External Interrupt PORTC +INTERRUPT_DEFINITION(EXTI_PORTC_IRQHandler, 5); + +// External Interrupt PORTD +INTERRUPT_DEFINITION(EXTI_PORTD_IRQHandler, 6); + +// External Interrupt PORTE +INTERRUPT_DEFINITION(EXTI_PORTE_IRQHandler, 7); + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_DEFINITION(EXTI_PORTF_IRQHandler, 8); +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_DEFINITION(CAN_RX_IRQHandler, 8); + +// CAN TX Interrupt routine. +INTERRUPT_DEFINITION(CAN_TX_IRQHandler, 9); +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_DEFINITION(SPI_IRQHandler, 10); + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_DEFINITION(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_DEFINITION(TIM1_CAP_COM_IRQHandler, 12); + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_DEFINITION(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); + +// Timer5 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM5_CAP_COM_IRQHandler, 14); + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM2_UPD_OVF_BRK_IRQHandler, 13); + +// Timer2 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM2_CAP_COM_IRQHandler, 14); +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM3_UPD_OVF_BRK_IRQHandler, 15); + +// Timer3 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM3_CAP_COM_IRQHandler, 16); +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_DEFINITION(UART1_TX_IRQHandler, 17); + +// UART1 RX Interrupt +INTERRUPT_DEFINITION(UART1_RX_IRQHandler, 18); +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_DEFINITION(I2C_IRQHandler, 19); + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_DEFINITION(UART2_TX_IRQHandler, 20); + +// UART2 RX interrupt +INTERRUPT_DEFINITION(UART2_RX_IRQHandler, 21); +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_DEFINITION(UART3_TX_IRQHandler, 20); + +// UART3 RX interrupt +INTERRUPT_DEFINITION(UART3_RX_IRQHandler, 21); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_DEFINITION(ADC2_IRQHandler, 22); +#else // STM8S105, STM8S103 or STM8S903 or STM8AF626x +// ADC1 interrupt +INTERRUPT_DEFINITION(ADC1_IRQHandler, 22); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_DEFINITION(TIM6_UPD_OVF_TRG_IRQHandler, 23); +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_DEFINITION(TIM4_UPD_OVF_IRQHandler, 23); +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_DEFINITION(EEPROM_EEC_IRQHandler, 24); + +#endif // __INTERRUPTS_H__ diff --git a/stepper/main.c b/stepper/main.c new file mode 100644 index 0000000..23e27ba --- /dev/null +++ b/stepper/main.c @@ -0,0 +1,396 @@ +/* + * blinky.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#include "ports_definition.h" +#include "interrupts.h" +#include "main.h" +#include "stepper.h" + +/* + * 0 0000 + * 1 0001 + * 2 0010 + * 3 0011 + * 4 0100 + * 5 0101 + * 6 0110 + * 7 0111 + * 8 1000 + * 9 1001 + * a 1010 + * b 1011 + * c 1100 + * d 1101 + * e 1110 + * f 1111 + */ + +/* + ********************* Internal timer (HSI) ******************** + * on startup: HSI = 2MHz (16/8) + * HSI divisor: CLK_CKDIVR: bits 4,3: f_{HSI}/2^x; bits2..0: f_{CPU}=f/2^x (page 93) + * CLK_PCKENR1/2 - enable periph clocking (page 94,95) reset value: all enabled + */ + +/* + ********************* Timer1 ******************** + * prescaler: TIM1_PSCRH/L, f = f_{in}/(TIM1_PSCR + 1) + * other registers: + * TIM1_CR1 (page 185): | ARPE | CMS[1:0] | DIR | OPM | URS | UDIS | CEN | + * ARPE - Auto-reload preload enable (for TIM1_ARR) + * CMS[1:0]: Center-aligned mode selection (0 - simple counter up/down) + * DIR: Direction (0 - up, 1 - down) + * OPM: One-pulse mode (1 - opm enabled) + * URS: Update request source (When enabled by the UDIS bit, 1 - interrupt only on counter overflow/underflow) + * UDIS: Update disable (1 - disable update int) + * CEN: Counter enable (1 - enable) + * TIM1_CR2 (page 187): | - | MMS [2:0] | - | COMS | - | CCPS | + * MMS[2:0]: Master mode selection (for ADC or other timers) + * COMS: Capture/compare control update selection + * CCPC: Capture/compare preloaded control + * TIM1_IER (page 191): | BIE | TIE | COMIE | CC4IE | CC3IE | CC2IE | CC1IE | UIE | + * B - break; T - trigger; COM - commutation; CC - comp/capt; U - update <-- + * TIM1_SR1 (page 192): similar (but instead of IE -> IF) + * interrupt flags + * TIM1_CNTRH, TIM1_CNTRL - counter value (automatical) + * TIM1_PSCRH, TIM1_PSCRL - prescaler value + * TIM1_ARRH, TIM1_ARRL - auto-reload value (while zero, timer is stopped) (page 206) + */ + +/* + ********************* External interrupts (page 69) ******************** + * EXTI_CR1: | PDIS[1:0] | PCIS[1:0] | PBIS[1:0] | PAIS[1:0] | + * per-port sensivity bits: + * 00: Falling edge and low level + * 01: Rising edge only + * 10: Falling edge only + * 11: Rising and falling edge + * EXTI_CR2: | -reserved[7:3]- | TLIS | PEIS[1:0] | + * TLIS: Top level interrupt sensitivity (0: Falling edge, 1 - Rising) + * PEIS[1:0]: Port E external interrupt sensitivity bits + * after config run enableInterrupts() + * ports: + * 5 lines on Port A: PA[6:2] + * 8 lines on Port B: PB[7:0] + * 8 lines on Port C: PC[7:0] + * 7 lines on Port D: PD[6:0] + * 8 lines on Port E: PE[7:0] + * PD7 is the Top Level Interrupt source (TLI), except for 20-pin packages + * on which the Top Level Interrupt source (TLI) can be available on the + * PC3 pin using an alternate function remapping option bit + */ + +/* + ********************* GPIO (page 111) ******************** + * Px_ODR - Output data register bits + * Px_IDR - Pin input values + * Px_DDR - Data direction bits (1 - output) + * Px_CR1 - DDR=0: 0 - floating, 1 - pull-up input; DDR=1: 0 - pseudo-open-drain, 1 - push-pull output [not for "T"] + * Px_CR2 - DDR=0: 0/1 - EXTI disabled/enabled; DDR=1: 0/1 - 2/10MHz + * + */ + +/* + ********************* UART ******************** + * ALGO: + * 1. Program the M bit in UART_CR1 to define the word length [M=0, PCEN=0 - 8bit without parity] + * 2. Program the number of stop bits in UART_CR3 + * 3. Select the desired baud rate (UART_BRR1/2) [57600 on 16MHz: BRR1=0x11, BRR2=0x06] + * 4. Set the TEN bit in UART_CR2 to enable transmitter mode + * 5. Write the data to send in the UART_DR register (this clears the TXE bit) + * 6. Once the last data is written to the UART_DR register, wait until TC is set to ‘1’, which indicates that the last data transmission is complete + * baud rate: regs UART_BRR1/2 !!!VERY STUPID!!! + * f_{UART} = f_{master} / UART_DIV + * if UART_DIV = 0xABCD then + * UART_BRR1 = UART_DIV[11:4] = 0xBC; + * UART_BRR2 = UART_DIV[15:12|3:0] = 0xAD + * registers + * UART_SR: | TXE | TC | RXNE | IDLE | OR/LHE | NF | FE | PE | + * TXE: Transmit data register empty + * TC: Transmission complete + * RXNE: Read data register not empty + * IDLE: IDLE line detected + * OR: Overrun error / LHE: LIN Header Error (LIN slave mode) + * NF: Noise flag + * FE: Framing error + * PE: Parity error + * UART_DR: data register (when readed returns coming byte, when writed fills output shift register) + * UART_BRR1 / UART_BRR2 - see upper + * UART_CR1: | R8 | T8 | UARTD | M | WAKE | PCEN | PS | PIEN | + * R8, T8 - ninth bit (in 9-bit mode) + * UARTD: UART Disable (for low power consumption) + * M: word length (0 - 8bits, 1 - 9bits) + * WAKE: Wakeup method + * PCEN: Parity control enable + * PS: Parity selection (0 - even) + * PIEN: Parity interrupt enable + * UART_CR2: | TIEN | TCEN | RIEN | ILIEN | TEN | REN | RWU | SBK | + * TIEN: Transmitter interrupt enable + * TCIEN: Transmission complete interrupt enable + * RIEN: Receiver interrupt enable + * ILIEN: IDLE Line interrupt enable + * TEN: Transmitter enable <---------------------------------------- + * REN: Receiver enable <---------------------------------------- + * RWU: Receiver wakeup + * SBK: Send break + * UART_CR3: | - | LINEN | STOP[1:0] | CLCEN | CPOL | CPHA | LBCL | + * LINEN: LIN mode enable + * STOP: STOP bits + * CLKEN: Clock enable (CLC pin) + * CPOL: Clock polarity + * CPHA: Clock phase + * LBCL: Last bit clock pulse + */ + +/* + ********************* ADC (page 413) ******************** + * ADC_DBxRH / ADC_DRH: 9:2 data bits in left-aligned or 9:8 bits in right-aligned mode + * ADC_DBxRL / ADC_DRL: 1:0 data bits in left-aligned or 7:0 bits in right-aligned mode + * ADC_CSR: | EOC | AWD | EOCIE | AWDIE | CH[3:0] | + * EOC: End of conversion + * AWD: Analog Watchdog flag + * EOCIE: Interrupt enable for EOC + * AWDIE: Analog watchdog interrupt enable + * CH[3:0]: Channel selection bits (0..15) + * ADC_CR1: | - | SPSEL[2:0] | - | - | CONT | ADON | + * SPSEL[2:0]: Prescaler selection + * CONT: Continuous conversion (0 for single) + * ADON: A/D Converter on/off <---------------------------------------- + * ADC_CR2: | - | EXTTRIG | EXTSEL[1:0] | ALIGN | - | SCAN | - | + * EXTTRIG: External trigger enable + * EXTSEL[1:0]: External event selection + * ALIGN: Data alignment (1 - right alignment, first read ADC_DRL) + * SCAN: Scan mode enable + * ADC_CR3: | DBUF | OVR | reserved[5:0] | + * DBUF: Data buffer enable (on buffered mode data stored not in ADC_DBhl but in ADC_DBxRhl) + * OVR: Overrun flag + * ADC_TDRH/L - trigger shmidt disable (1 - disable) + */ + +unsigned long Global_time = 0L; // global time in ms +U16 paused_val = 500; // interval between LED flashing + +U8 UART_rx[UART_BUF_LEN]; // cycle buffer for received data +U8 UART_rx_start_i = 0; // started index of received data (from which reading starts) +U8 UART_rx_cur_i = 0; // index of current first byte in rx array (to which data will be written) + +/** + * Send one byte through UART + * @param byte - data to send + */ +void UART_send_byte(U8 byte){ + while(!(UART2_SR & UART_SR_TXE)); // wait until previous byte transmitted + UART2_DR = byte; +} + +void uart_write(char *str){ + while(*str){ + while(!(UART2_SR & UART_SR_TXE)); + UART2_CR2 |= UART_CR2_TEN; + UART2_DR = *str++; + } +} + + +/** + * Read one byte from Rx buffer + * @param byte - where to store readed data + * @return 1 in case of non-empty buffer + */ +U8 UART_read_byte(U8 *byte){ + if(UART_rx_start_i == UART_rx_cur_i) // buffer is empty + return 0; + *byte = UART_rx[UART_rx_start_i++]; + check_UART_pointer(UART_rx_start_i); + return 1; +} + +void printUint(U8 *val, U8 len){ + unsigned long Number = 0; + U8 i = len; + char ch; + U8 decimal_buff[12]; // max len of U32 == 10 + \n + \0 + if(len > 4 || len == 3 || len == 0) return; + for(i = 0; i < 12; i++) + decimal_buff[i] = 0; + decimal_buff[10] = '\n'; + ch = 9; + switch(len){ + case 1: + Number = *((U8*)val); + break; + case 2: + Number = *((U16*)val); + break; + case 4: + Number = *((unsigned long*)val); + break; + } + do{ + i = Number % 10L; + decimal_buff[ch--] = i + '0'; + Number /= 10L; + }while(Number && ch > -1); + uart_write((char*)&decimal_buff[ch+1]); +} + +U8 readInt(int *val){ + unsigned long T = Global_time; + unsigned long R = 0; + int readed; + U8 sign = 0, rb, ret = 0, bad = 0; + do{ + if(!UART_read_byte(&rb)) continue; + if(rb == '-' && R == 0){ // negative number + sign = 1; + continue; + } + if(rb < '0' || rb > '9') break; // number ends with any non-digit symbol that will be omitted + ret = 1; // there's at least one digit + R = R * 10L + rb - '0'; + if(R > 0x7fff){ // bad value + R = 0; + bad = 0; + } + }while(Global_time - T < 10000); // wait no longer than 10s + if(bad || !ret) return 0; + readed = (int) R; + if(sign) readed *= -1; + *val = readed; + return 1; +} + +void error_msg(char *msg){ + uart_write("\nERROR: "); + uart_write(msg); + UART_send_byte('\n'); +} + +int main() { + unsigned long T = 0L; + int Ival; + U8 rb; + CFG_GCR |= 1; // disable SWIM + // Configure clocking + CLK_CKDIVR = 0; // F_HSI = 16MHz, f_CPU = 16MHz + + // Configure timer 1 - systick + // prescaler = f_{in}/f_{tim1} - 1 + // set Timer1 to 1MHz: 1/1 - 1 = 15 + TIM1_PSCRH = 0; + TIM1_PSCRL = 15; // LSB should be written last as it updates prescaler + // auto-reload each 1ms: TIM_ARR = 1000 = 0x03E8 + TIM1_ARRH = 0x03; + TIM1_ARRL = 0xE8; + // interrupts: update + TIM1_IER = TIM_IER_UIE; + // auto-reload + interrupt on overflow + enable + TIM1_CR1 = TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN; + + // Configure pins + // PC2 - PP output (on-board LED) + PORT(LED_PORT, DDR) |= LED_PIN; + PORT(LED_PORT, CR1) |= LED_PIN; + // PD5 - UART2_TX + PORT(UART_PORT, DDR) |= UART_TX_PIN; + PORT(UART_PORT, CR1) |= UART_TX_PIN; + + // Configure UART + // 8 bit, no parity, 1 stop (UART_CR1/3 = 0 - reset value) + // 57600 on 16MHz: BRR1=0x11, BRR2=0x06 + UART2_BRR1 = 0x11; UART2_BRR2 = 0x06; + UART2_CR2 = UART_CR2_TEN | UART_CR2_REN | UART_CR2_RIEN; // Allow RX/TX, generate ints on rx + + // enable all interrupts + enableInterrupts(); + + set_stepper_speed(1000); + setup_stepper_pins(); + + // Loop + do{ + if((Global_time - T > paused_val) || (T > Global_time)){ + T = Global_time; + PORT(LED_PORT, ODR) ^= LED_PIN; // blink on-board LED + } + if(UART_read_byte(&rb)){ // buffer isn't empty + switch(rb){ + case 'h': // help + case 'H': + uart_write("\nPROTO:\n+/-\tLED period\nS/s\tset/get Mspeed\nm\tget steps\nx\tstop\np\tpause/resume\n0..4\tmove xth motor\na\tadd Nstps\n"); + break; + case '+': + paused_val += 100; + if(paused_val > 10000) + paused_val = 500; // but not more than 10s + break; + case '-': + paused_val -= 100; + if(paused_val < 100) // but not less than 0.1s + paused_val = 500; + break; + case 'S': // set stepper speed + if(readInt(&Ival) && Ival > MIN_STEP_LENGTH) + set_stepper_speed(Ival); + else + error_msg("bad speed"); + break; + case 's': // get stepper speed + printUint((U8*)&Stepper_speed, 2); + break; + case 'm': // how much steps there is to the end of moving + Ival = Nsteps >> Ustepping; + printUint((U8*)&Ival, 2); + break; + case 'x': // stop + stop_motor(); + break; + case 'p': // pause/resume + pause_resume(); + break; + case 'a': // add N steps + if(readInt(&Ival) && Ival){ + add_steps(Ival); + }else{ + error_msg("bad value"); + } + break; + default: + if(rb >= '0' && rb <= '4'){ // motor + if(Motor_number != 5){ + error_msg("moving!"); + break; + } + Motor_number = rb - '0'; + if(readInt(&Ival) && Ival) + move_motor(Ival); + else{ + error_msg("bad Nsteps"); + Motor_number = 5; + } + } + } + } + }while(1); +} + + diff --git a/stepper/main.h b/stepper/main.h new file mode 100644 index 0000000..77e2f9f --- /dev/null +++ b/stepper/main.h @@ -0,0 +1,41 @@ +/* + * blinky.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __MAIN_H__ +#define __MAIN_H__ + +extern unsigned long Global_time; // global time in ms + +#define UART_BUF_LEN 8 // max 7 bytes transmited in on operation +#define MIN_STEP_LENGTH 125 // max speed == 1/(125us*16) = 500 steps per second + +extern U8 UART_rx[]; +extern U8 UART_rx_start_i; +extern U8 UART_rx_cur_i; + +void UART_send_byte(U8 byte); +void uart_write(char *str); +void printUint(U8 *val, U8 len); +void error_msg(char *msg); + +#define check_UART_pointer(x) if(x == UART_BUF_LEN) x = 0; + +#endif // __MAIN_H__ diff --git a/stepper/ports_definition.h b/stepper/ports_definition.h new file mode 100644 index 0000000..1b3bdee --- /dev/null +++ b/stepper/ports_definition.h @@ -0,0 +1,50 @@ +/* + * ports_definition.h - definition of ports pins & so on + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __PORTS_DEFINITION_H__ +#define __PORTS_DEFINITION_H__ + +#include "stm8l.h" + +// macro for using in port constructions like PORT(LED_PORT, ODR) = xx +#define CONCAT(a, b) a ## _ ## b +#define PORT(a, b) CONCAT(a , b) + +// on-board LED +#define LED_PORT PC +#define LED_PIN GPIO_PIN2 + +// UART2_TX +#define UART_PORT PD +#define UART_TX_PIN GPIO_PIN5 + +/***** Stepper motor *****/ +// Clocking +#define STP_CLK_PORT PD +#define STP_CLK_PIN GPIO_PIN4 +// EN -- PB0..4 +#define STP_EN_PORT PB +#define STP_EN_MASK 0x1F // number & mask == enable! +// DIR -- PB5 +#define STP_DIR_PORT PB +#define STP_DIR_PIN GPIO_PIN5 +#endif // __PORTS_DEFINITION_H__ diff --git a/stepper/schematic/kicad.pro b/stepper/schematic/kicad.pro new file mode 100644 index 0000000..6affc30 --- /dev/null +++ b/stepper/schematic/kicad.pro @@ -0,0 +1,82 @@ +update=Вт 11 фев 2014 17:26:13 +version=1 +last_client=eeschema +[cvpcb] +version=1 +NetIExt=net +[cvpcb/libraries] +EquName1=devcms +[pcbnew] +version=1 +LastNetListRead= +PadDrlX=320 +PadDimH=550 +PadDimV=550 +BoardThickness=620 +TxtPcbV=600 +TxtPcbH=600 +TxtModV=500 +TxtModH=500 +TxtModW=100 +VEgarde=100 +DrawLar=120 +EdgeLar=80 +TxtLar=120 +MSegLar=120 +[pcbnew/libraries] +LibDir= +LibName1=sockets +LibName2=connect +LibName3=discret +LibName4=pin_array +LibName5=divers +LibName6=libcms +LibName7=display +LibName8=led +LibName9=dip_sockets +LibName10=pga_sockets +LibName11=valves +[general] +version=1 +[eeschema] +version=1 +LibDir= +NetFmtName= +RptD_X=0 +RptD_Y=100 +RptLab=1 +LabSize=60 +[eeschema/libraries] +LibName1=power +LibName2=device +LibName3=transistors +LibName4=conn +LibName5=linear +LibName6=regul +LibName7=74xx +LibName8=cmos4000 +LibName9=adc-dac +LibName10=memory +LibName11=xilinx +LibName12=special +LibName13=microcontrollers +LibName14=dsp +LibName15=microchip +LibName16=analog_switches +LibName17=motorola +LibName18=texas +LibName19=intel +LibName20=audio +LibName21=interface +LibName22=digital-audio +LibName23=philips +LibName24=display +LibName25=cypress +LibName26=siliconi +LibName27=opto +LibName28=atmel +LibName29=contrib +LibName30=valves +LibName31=stm8 +LibName32=st-microelectronics +LibName33=stm8s105k4t6c diff --git a/stepper/schematic/stepper-cache.lib b/stepper/schematic/stepper-cache.lib new file mode 100644 index 0000000..64b1098 --- /dev/null +++ b/stepper/schematic/stepper-cache.lib @@ -0,0 +1,237 @@ +EESchema-LIBRARY Version 2.3 Date: Ср 12 фев 2014 12:09:00 +#encoding utf-8 +# +# +3.3V +# +DEF +3.3V #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -40 30 H I C CNN +F1 "+3.3V" 0 110 30 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS +3,3V +DRAW +X +3.3V 1 0 0 0 U 30 30 0 0 W N +C 0 60 20 0 1 0 N +P 3 0 1 0 0 0 0 40 0 40 N +ENDDRAW +ENDDEF +# +# C +# +DEF C C 0 10 N Y 1 F N +F0 "C" 0 100 40 H V L CNN +F1 "C" 6 -85 40 H V L CNN +F2 "~" 38 -150 30 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + SM* + C? + C1-1 +$ENDFPLIST +DRAW +P 2 0 1 20 -80 -30 80 -30 N +P 2 0 1 20 -80 30 80 30 N +X ~ 1 0 200 170 D 40 40 1 1 P +X ~ 2 0 -200 170 U 40 40 1 1 P +ENDDRAW +ENDDEF +# +# CONN_14 +# +DEF CONN_14 P 0 40 Y N 1 F N +F0 "P" -30 0 60 V V C CNN +F1 "CONN_14" 80 0 60 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 700 150 -700 0 1 0 N +X P1 1 -350 650 250 R 50 50 1 1 P I +X P2 2 -350 550 250 R 50 50 1 1 P I +X P3 3 -350 450 250 R 50 50 1 1 P I +X P4 4 -350 350 250 R 50 50 1 1 P I +X P5 5 -350 250 250 R 50 50 1 1 P I +X P6 6 -350 150 250 R 50 50 1 1 P I +X P7 7 -350 50 250 R 50 50 1 1 P I +X P8 8 -350 -50 250 R 50 50 1 1 P I +X P9 9 -350 -150 250 R 50 50 1 1 P I +X P10 10 -350 -250 250 R 50 50 1 1 P I +X P11 11 -350 -350 250 R 50 50 1 1 P I +X P12 12 -350 -450 250 R 50 50 1 1 P I +X P13 13 -350 -550 250 R 50 50 1 1 P I +X P14 14 -350 -650 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_3 +# +DEF CONN_3 K 0 40 Y N 1 F N +F0 "K" -50 0 50 V V C CNN +F1 "CONN_3" 50 0 40 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 150 100 -150 0 1 0 N +X P1 1 -350 100 250 R 60 60 1 1 P I +X PM 2 -350 0 250 R 60 60 1 1 P I +X P3 3 -350 -100 250 R 60 60 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_4 +# +DEF CONN_4 P 0 40 Y N 1 F N +F0 "P" -50 0 50 V V C CNN +F1 "CONN_4" 50 0 50 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 200 100 -200 0 1 0 N +X P1 1 -350 150 250 R 50 50 1 1 P I +X P2 2 -350 50 250 R 50 50 1 1 P I +X P3 3 -350 -50 250 R 50 50 1 1 P I +X P4 4 -350 -150 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_6 +# +DEF CONN_6 P 0 30 Y N 1 F N +F0 "P" -50 0 60 V V C CNN +F1 "CONN_6" 50 0 60 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 300 100 -300 0 1 0 N +X 1 1 -350 250 250 R 60 60 1 1 P I +X 2 2 -350 150 250 R 60 60 1 1 P I +X 3 3 -350 50 250 R 60 60 1 1 P I +X 4 4 -350 -50 250 R 60 60 1 1 P I +X 5 5 -350 -150 250 R 60 60 1 1 P I +X 6 6 -350 -250 250 R 60 60 1 1 P I +ENDDRAW +ENDDEF +# +# GND +# +DEF ~GND #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 0 30 H I C CNN +F1 "GND" 0 -70 30 H I C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N +X GND 1 0 0 0 U 30 30 1 1 W N +ENDDRAW +ENDDEF +# +# LED +# +DEF LED D 0 40 Y N 1 F N +F0 "D" 0 100 50 H V C CNN +F1 "LED" 0 -100 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + LED-3MM + LED-5MM + LED-10MM + LED-0603 + LED-0805 + LED-1206 + LEDV +$ENDFPLIST +DRAW +P 2 0 1 0 50 50 50 -50 N +P 3 0 1 0 -50 50 50 0 -50 -50 F +P 3 0 1 0 65 -40 110 -80 105 -55 N +P 3 0 1 0 80 -25 125 -65 120 -40 N +X A 1 -200 0 150 R 40 40 1 1 P +X K 2 200 0 150 L 40 40 1 1 P +ENDDRAW +ENDDEF +# +# R +# +DEF R R 0 0 N Y 1 F N +F0 "R" 80 0 40 V V C CNN +F1 "R" 7 1 40 V V C CNN +F2 "~" -70 0 30 V V C CNN +F3 "~" 0 0 30 H V C CNN +$FPLIST + R? + SM0603 + SM0805 + R?-* + SM1206 +$ENDFPLIST +DRAW +S -40 150 40 -150 0 1 12 N +X ~ 1 0 250 100 D 60 60 1 1 P +X ~ 2 0 -250 100 U 60 60 1 1 P +ENDDRAW +ENDDEF +# +# STM8S105K4T6C +# +DEF STM8S105K4T6C U 0 40 Y Y 1 F N +F0 "U" 0 1050 60 H V C CNN +F1 "STM8S105K4T6C" 50 -850 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS stm8s105* +$FPLIST + lqfp32* +$ENDFPLIST +DRAW +S -1100 950 1100 -750 0 1 0 N +X NRST 1 -1400 850 300 R 50 50 1 1 I +X OSCIN/PA1 2 -1400 750 300 R 50 50 1 1 T +X OSCOUT/PA2 3 -1400 650 300 R 50 50 1 1 T +X VSS 4 -1400 550 300 R 50 50 1 1 W +X VCAP 5 -1400 450 300 R 50 50 1 1 w +X VDD(3.3-5v) 6 -1400 350 300 R 50 50 1 1 W +X VDDio 7 -1400 250 300 R 50 50 1 1 W +X PF4/AIN12 8 -1400 150 300 R 50 50 1 1 T +X VDDA 9 -1400 50 300 R 50 50 1 1 W +X VSSA 10 -1400 -50 300 R 50 50 1 1 W +X PC3(HS)/TIM1_CH3 20 1400 -350 300 L 50 50 1 1 T +X PD5/UART2_TX 30 1400 650 300 L 50 50 1 1 T +X PB5/AIN5[I2X_SDA] 11 -1400 -150 300 R 50 50 1 1 T +X PC4(HS)/TIM1_CH4 21 1400 -250 300 L 50 50 1 1 T +X PD6/UART2_RX 31 1400 750 300 L 50 50 1 1 T +X PB4/AIN4[I2C_SCL] 12 -1400 -250 300 R 50 50 1 1 T +X PC5(HS)/SPI_SCK 22 1400 -150 300 L 50 50 1 1 T +X PD7/TLI[TIM1_CH4] 32 1400 850 300 L 50 50 1 1 T +X PB3/AIN3[TIM1_ETR] 13 -1400 -350 300 R 50 50 1 1 T +X PC6(HS)/SPI_MOSI 23 1400 -50 300 L 50 50 1 1 T +X PB2/AIN2[TIM1_CH3N] 14 -1400 -450 300 R 50 50 1 1 T +X PC7(HS)/SPI_MISO 24 1400 50 300 L 50 50 1 1 T +X PB1/AIN1_[TIM1_CH2N] 15 -1400 -550 300 R 50 50 1 1 T +X PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO] 25 1400 150 300 L 50 50 1 1 T +X PB0/AIN0_[TIM1_CH1N] 16 -1400 -650 300 R 50 50 1 1 T +X PD1(HS)/SWIM 26 1400 250 300 L 50 50 1 1 T +X PE5/SPI_NSS 17 1400 -650 300 L 50 50 1 1 T +X PD2(HS)/TIM3_CH1[TIM2_CH3] 27 1400 350 300 L 50 50 1 1 T +X PC1(HS)/TIM1_CH1 18 1400 -550 300 L 50 50 1 1 T +X PD3(HS)/TIM2_CH2[ADC_ETR] 28 1400 450 300 L 50 50 1 1 T +X PC2(HS)/TIM1_CH2 19 1400 -450 300 L 50 50 1 1 T +X PD4(HS)/TIM2_CH1[BEEP] 29 1400 550 300 L 50 50 1 1 T +ENDDRAW +ENDDEF +# +# SW_PUSH +# +DEF SW_PUSH SW 0 40 N N 1 F N +F0 "SW" 150 110 50 H V C CNN +F1 "SW_PUSH" 0 -80 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -170 50 170 60 0 1 0 N +P 4 0 1 0 -40 60 -30 90 30 90 40 60 N +X 1 1 -300 0 200 R 60 60 0 1 P I +X 2 2 300 0 200 L 60 60 0 1 P I +ENDDRAW +ENDDEF +# +#End Library diff --git a/stepper/schematic/stepper.cmp b/stepper/schematic/stepper.cmp new file mode 100644 index 0000000..3cd2d4a --- /dev/null +++ b/stepper/schematic/stepper.cmp @@ -0,0 +1,108 @@ +Cmp-Mod V01 Created by CvPcb (2013-feb-26)-stable date = Ср 12 фев 2014 12:08:54 + +BeginCmp +TimeStamp = /52FB0413; +Reference = C1; +ValeurCmp = 1u; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0426; +Reference = C2; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F99; +Reference = C3; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0DD3; +Reference = D1; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ECD; +Reference = D2; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB2C32; +Reference = K1; +ValeurCmp = CONN_3; +IdModule = SIL-3; +EndCmp + +BeginCmp +TimeStamp = /52FB0A6A; +Reference = P1; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB0A49; +Reference = P2; +ValeurCmp = CONN_4; +IdModule = SIL-4; +EndCmp + +BeginCmp +TimeStamp = /52FB0A79; +Reference = P3; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB29A7; +Reference = P4; +ValeurCmp = CONN_5; +IdModule = SIL-5; +EndCmp + +BeginCmp +TimeStamp = /52FB0DE2; +Reference = R1; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ED3; +Reference = R2; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0EFD; +Reference = R3; +ValeurCmp = 10k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F3B; +Reference = SW1; +ValeurCmp = SW_PUSH; +IdModule = SM2010; +EndCmp + +BeginCmp +TimeStamp = /52FB03A2; +Reference = U1; +ValeurCmp = STM8S105K4T6C; +IdModule = TQFP32; +EndCmp + +EndListe diff --git a/stepper/schematic/stepper.net b/stepper/schematic/stepper.net new file mode 100644 index 0000000..3204d76 --- /dev/null +++ b/stepper/schematic/stepper.net @@ -0,0 +1,361 @@ +(export (version D) + (design + (source /home/eddy/Docs/SAO/ELECTRONICS/STM8/stepper/schematic/stepper.sch) + (date "Ср 12 фев 2014 12:08:20") + (tool "eeschema (2013-feb-26)-stable")) + (components + (comp (ref U1) + (value STM8S105K4T6C) + (libsource (lib stm8s105k4t6c) (part STM8S105K4T6C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB03A2)) + (comp (ref C1) + (value 1u) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0413)) + (comp (ref C2) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0426)) + (comp (ref P2) + (value CONN_4) + (libsource (lib conn) (part CONN_4)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A49)) + (comp (ref P1) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A6A)) + (comp (ref P3) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A79)) + (comp (ref D1) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DD3)) + (comp (ref R1) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DE2)) + (comp (ref D2) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ECD)) + (comp (ref R2) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ED3)) + (comp (ref R3) + (value 10k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0EFD)) + (comp (ref SW1) + (value SW_PUSH) + (libsource (lib device) (part SW_PUSH)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F3B)) + (comp (ref C3) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F99)) + (comp (ref P4) + (value CONN_5) + (libsource (lib conn) (part CONN_6)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB29A7)) + (comp (ref K1) + (value CONN_3) + (libsource (lib conn) (part CONN_3)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB2C32))) + (libparts + (libpart (lib device) (part C) + (description "Condensateur non polarise") + (footprints + (fp SM*) + (fp C?) + (fp C1-1)) + (fields + (field (name Reference) C) + (field (name Value) C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part LED) + (footprints + (fp LED-3MM) + (fp LED-5MM) + (fp LED-10MM) + (fp LED-0603) + (fp LED-0805) + (fp LED-1206) + (fp LEDV)) + (fields + (field (name Reference) D) + (field (name Value) LED) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name A) (type passive)) + (pin (num 2) (name K) (type passive)))) + (libpart (lib device) (part R) + (description Resistance) + (footprints + (fp R?) + (fp SM0603) + (fp SM0805) + (fp R?-*) + (fp SM1206)) + (fields + (field (name Reference) R) + (field (name Value) R) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part SW_PUSH) + (description "Push Button") + (fields + (field (name Reference) SW) + (field (name Value) SW_PUSH) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name 1) (type passive)) + (pin (num 2) (name 2) (type passive)))) + (libpart (lib conn) (part CONN_14) + (description "Symbole general de connexion") + (fields + (field (name Reference) P) + (field (name Value) CONN_14)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)) + (pin (num 5) (name P5) (type passive)) + (pin (num 6) (name P6) (type passive)) + (pin (num 7) (name P7) (type passive)) + (pin (num 8) (name P8) (type passive)) + (pin (num 9) (name P9) (type passive)) + (pin (num 10) (name P10) (type passive)) + (pin (num 11) (name P11) (type passive)) + (pin (num 12) (name P12) (type passive)) + (pin (num 13) (name P13) (type passive)) + (pin (num 14) (name P14) (type passive)))) + (libpart (lib conn) (part CONN_3) + (description "Symbole general de connecteur") + (fields + (field (name Reference) K) + (field (name Value) CONN_3)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name PM) (type passive)) + (pin (num 3) (name P3) (type passive)))) + (libpart (lib conn) (part CONN_4) + (description "Symbole general de connecteur") + (fields + (field (name Reference) P) + (field (name Value) CONN_4)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)))) + (libpart (lib conn) (part CONN_6) + (description "ymbole general de connecteur") + (fields + (field (name Reference) P) + (field (name Value) CONN_6)) + (pins + (pin (num 1) (name 1) (type passive)) + (pin (num 2) (name 2) (type passive)) + (pin (num 3) (name 3) (type passive)) + (pin (num 4) (name 4) (type passive)) + (pin (num 5) (name 5) (type passive)) + (pin (num 6) (name 6) (type passive)))) + (libpart (lib stm8s105k4t6c) (part STM8S105K4T6C) + (footprints + (fp lqfp32*)) + (fields + (field (name Reference) U) + (field (name Value) STM8S105K4T6C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name NRST) (type input)) + (pin (num 2) (name OSCIN/PA1) (type 3state)) + (pin (num 3) (name OSCOUT/PA2) (type 3state)) + (pin (num 4) (name VSS) (type power_in)) + (pin (num 5) (name VCAP) (type power_out)) + (pin (num 6) (name "VDD(3.3-5v)") (type power_in)) + (pin (num 7) (name VDDio) (type power_in)) + (pin (num 8) (name PF4/AIN12) (type 3state)) + (pin (num 9) (name VDDA) (type power_in)) + (pin (num 10) (name VSSA) (type power_in)) + (pin (num 11) (name PB5/AIN5[I2X_SDA]) (type 3state)) + (pin (num 12) (name PB4/AIN4[I2C_SCL]) (type 3state)) + (pin (num 13) (name PB3/AIN3[TIM1_ETR]) (type 3state)) + (pin (num 14) (name PB2/AIN2[TIM1_CH3N]) (type 3state)) + (pin (num 15) (name PB1/AIN1_[TIM1_CH2N]) (type 3state)) + (pin (num 16) (name PB0/AIN0_[TIM1_CH1N]) (type 3state)) + (pin (num 17) (name PE5/SPI_NSS) (type 3state)) + (pin (num 18) (name "PC1(HS)/TIM1_CH1") (type 3state)) + (pin (num 19) (name "PC2(HS)/TIM1_CH2") (type 3state)) + (pin (num 20) (name "PC3(HS)/TIM1_CH3") (type 3state)) + (pin (num 21) (name "PC4(HS)/TIM1_CH4") (type 3state)) + (pin (num 22) (name "PC5(HS)/SPI_SCK") (type 3state)) + (pin (num 23) (name "PC6(HS)/SPI_MOSI") (type 3state)) + (pin (num 24) (name "PC7(HS)/SPI_MISO") (type 3state)) + (pin (num 25) (name "PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO]") (type 3state)) + (pin (num 26) (name "PD1(HS)/SWIM") (type 3state)) + (pin (num 27) (name "PD2(HS)/TIM3_CH1[TIM2_CH3]") (type 3state)) + (pin (num 28) (name "PD3(HS)/TIM2_CH2[ADC_ETR]") (type 3state)) + (pin (num 29) (name "PD4(HS)/TIM2_CH1[BEEP]") (type 3state)) + (pin (num 30) (name PD5/UART2_TX) (type 3state)) + (pin (num 31) (name PD6/UART2_RX) (type 3state)) + (pin (num 32) (name PD7/TLI[TIM1_CH4]) (type 3state))))) + (libraries + (library (logical device) + (uri /usr/share/kicad/library/device.lib)) + (library (logical conn) + (uri /usr/share/kicad/library/conn.lib)) + (library (logical stm8s105k4t6c) + (uri stm8s105k4t6c.lib))) + (nets + (net (code 1) (name +3.3V) + (node (ref R3) (pin 1)) + (node (ref U1) (pin 6)) + (node (ref C2) (pin 2)) + (node (ref D1) (pin 1)) + (node (ref P2) (pin 1)) + (node (ref D2) (pin 1)) + (node (ref P1) (pin 1)) + (node (ref U1) (pin 7)) + (node (ref U1) (pin 9)) + (node (ref K1) (pin 1))) + (net (code 2) (name "") + (node (ref D1) (pin 2)) + (node (ref R1) (pin 1))) + (net (code 3) (name "") + (node (ref R2) (pin 1)) + (node (ref D2) (pin 2))) + (net (code 4) (name GND) + (node (ref C1) (pin 1)) + (node (ref SW1) (pin 1)) + (node (ref C3) (pin 2)) + (node (ref R2) (pin 2)) + (node (ref P2) (pin 4)) + (node (ref P1) (pin 2)) + (node (ref U1) (pin 10)) + (node (ref U1) (pin 4)) + (node (ref C2) (pin 1)) + (node (ref P4) (pin 6))) + (net (code 5) (name /PC2) + (node (ref R1) (pin 2)) + (node (ref U1) (pin 19)) + (node (ref P3) (pin 14))) + (net (code 6) (name "") + (node (ref U1) (pin 5)) + (node (ref C1) (pin 2))) + (net (code 7) (name /PC1) + (node (ref P1) (pin 14)) + (node (ref U1) (pin 18))) + (net (code 8) (name /OSC1IN) + (node (ref U1) (pin 2)) + (node (ref P1) (pin 4))) + (net (code 9) (name /OSC2IN) + (node (ref P1) (pin 5)) + (node (ref U1) (pin 3))) + (net (code 10) (name /PF4) + (node (ref P1) (pin 6)) + (node (ref U1) (pin 8))) + (net (code 11) (name /PB5) + (node (ref U1) (pin 11)) + (node (ref P1) (pin 7)) + (node (ref K1) (pin 2))) + (net (code 12) (name /PB4) + (node (ref U1) (pin 12)) + (node (ref P4) (pin 5)) + (node (ref P1) (pin 8))) + (net (code 13) (name /PB3) + (node (ref U1) (pin 13)) + (node (ref P1) (pin 9)) + (node (ref P4) (pin 4))) + (net (code 14) (name /PB2) + (node (ref P1) (pin 10)) + (node (ref P4) (pin 3)) + (node (ref U1) (pin 14))) + (net (code 15) (name /PB1) + (node (ref P4) (pin 2)) + (node (ref P1) (pin 11)) + (node (ref U1) (pin 15))) + (net (code 16) (name /PB0) + (node (ref P4) (pin 1)) + (node (ref U1) (pin 16)) + (node (ref P1) (pin 12))) + (net (code 17) (name /PE5) + (node (ref U1) (pin 17)) + (node (ref P1) (pin 13))) + (net (code 18) (name /PD7) + (node (ref U1) (pin 32)) + (node (ref P3) (pin 1))) + (net (code 19) (name /PD6) + (node (ref P3) (pin 2)) + (node (ref U1) (pin 31))) + (net (code 20) (name /PD5) + (node (ref U1) (pin 30)) + (node (ref P3) (pin 3))) + (net (code 21) (name /PD4) + (node (ref K1) (pin 3)) + (node (ref U1) (pin 29)) + (node (ref P3) (pin 4))) + (net (code 22) (name /PD3) + (node (ref U1) (pin 28)) + (node (ref P3) (pin 5))) + (net (code 23) (name /PD2) + (node (ref P3) (pin 6)) + (node (ref U1) (pin 27))) + (net (code 24) (name /PD0) + (node (ref U1) (pin 25)) + (node (ref P3) (pin 8))) + (net (code 25) (name /PC7) + (node (ref U1) (pin 24)) + (node (ref P3) (pin 9))) + (net (code 26) (name /PC6) + (node (ref P3) (pin 10)) + (node (ref U1) (pin 23))) + (net (code 27) (name /PC5) + (node (ref P3) (pin 11)) + (node (ref U1) (pin 22))) + (net (code 28) (name /PC4) + (node (ref U1) (pin 21)) + (node (ref P3) (pin 12))) + (net (code 29) (name /PC3) + (node (ref P3) (pin 13)) + (node (ref U1) (pin 20))) + (net (code 30) (name /SWIM/PD1) + (node (ref P2) (pin 2)) + (node (ref U1) (pin 26)) + (node (ref P3) (pin 7))) + (net (code 31) (name /NRST) + (node (ref R3) (pin 2)) + (node (ref P2) (pin 3)) + (node (ref SW1) (pin 2)) + (node (ref P1) (pin 3)) + (node (ref C3) (pin 1)) + (node (ref U1) (pin 1))))) \ No newline at end of file diff --git a/stepper/schematic/stepper.pro b/stepper/schematic/stepper.pro new file mode 100644 index 0000000..3c06fdf --- /dev/null +++ b/stepper/schematic/stepper.pro @@ -0,0 +1,42 @@ +update=Ср 12 фев 2014 11:53:02 +last_client=eeschema +[eeschema] +version=1 +LibDir= +NetFmtName= +RptD_X=0 +RptD_Y=100 +RptLab=1 +LabSize=60 +[eeschema/libraries] +LibName1=power +LibName2=device +LibName3=transistors +LibName4=conn +LibName5=linear +LibName6=regul +LibName7=74xx +LibName8=cmos4000 +LibName9=adc-dac +LibName10=memory +LibName11=xilinx +LibName12=special +LibName13=microcontrollers +LibName14=dsp +LibName15=microchip +LibName16=analog_switches +LibName17=motorola +LibName18=texas +LibName19=intel +LibName20=audio +LibName21=interface +LibName22=digital-audio +LibName23=philips +LibName24=display +LibName25=cypress +LibName26=siliconi +LibName27=opto +LibName28=atmel +LibName29=contrib +LibName30=valves +LibName31=stm8s105k4t6c diff --git a/stepper/schematic/stepper.sch b/stepper/schematic/stepper.sch new file mode 100644 index 0000000..baa4aa1 --- /dev/null +++ b/stepper/schematic/stepper.sch @@ -0,0 +1,612 @@ +EESchema Schematic File Version 2 date Ср 12 фев 2014 12:09:00 +LIBS:power +LIBS:device +LIBS:transistors +LIBS:conn +LIBS:linear +LIBS:regul +LIBS:74xx +LIBS:cmos4000 +LIBS:adc-dac +LIBS:memory +LIBS:xilinx +LIBS:special +LIBS:microcontrollers +LIBS:dsp +LIBS:microchip +LIBS:analog_switches +LIBS:motorola +LIBS:texas +LIBS:intel +LIBS:audio +LIBS:interface +LIBS:digital-audio +LIBS:philips +LIBS:display +LIBS:cypress +LIBS:siliconi +LIBS:opto +LIBS:atmel +LIBS:contrib +LIBS:valves +LIBS:stm8s105k4t6c +LIBS:stepper-cache +EELAYER 27 0 +EELAYER END +$Descr A4 11693 8268 +encoding utf-8 +Sheet 1 1 +Title "" +Date "12 feb 2014" +Rev "" +Comp "" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L STM8S105K4T6C U1 +U 1 1 52FB03A2 +P 4400 3100 +F 0 "U1" H 4400 4150 60 0000 C CNN +F 1 "STM8S105K4T6C" H 4450 2250 60 0000 C CNN +F 2 "~" H 4400 3100 60 0000 C CNN +F 3 "~" H 4400 3100 60 0000 C CNN + 1 4400 3100 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR01 +U 1 1 52FB03EF +P 2750 3200 +F 0 "#PWR01" H 2750 3200 30 0001 C CNN +F 1 "GND" H 2750 3130 30 0001 C CNN +F 2 "" H 2750 3200 60 0000 C CNN +F 3 "" H 2750 3200 60 0000 C CNN + 1 2750 3200 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 3200 2750 3150 +Wire Wire Line + 2750 3150 3000 3150 +$Comp +L GND #PWR02 +U 1 1 52FB0400 +P 2750 2600 +F 0 "#PWR02" H 2750 2600 30 0001 C CNN +F 1 "GND" H 2750 2530 30 0001 C CNN +F 2 "" H 2750 2600 60 0000 C CNN +F 3 "" H 2750 2600 60 0000 C CNN + 1 2750 2600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 2600 2750 2550 +Wire Wire Line + 2750 2550 3000 2550 +$Comp +L C C1 +U 1 1 52FB0413 +P 2250 2700 +F 0 "C1" H 2300 2800 50 0000 L CNN +F 1 "1u" H 2300 2600 50 0000 L CNN +F 2 "" H 2250 2700 60 0000 C CNN +F 3 "" H 2250 2700 60 0000 C CNN + 1 2250 2700 + 0 -1 -1 0 +$EndComp +$Comp +L C C2 +U 1 1 52FB0426 +P 2250 2950 +F 0 "C2" H 2300 3050 50 0000 L CNN +F 1 "104" H 2300 2850 50 0000 L CNN +F 2 "" H 2250 2950 60 0000 C CNN +F 3 "" H 2250 2950 60 0000 C CNN + 1 2250 2950 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 2450 2700 2850 2700 +Wire Wire Line + 2850 2700 2850 2650 +Wire Wire Line + 2850 2650 3000 2650 +Wire Wire Line + 3000 2750 3000 2850 +Wire Wire Line + 2450 2950 2450 2850 +Wire Wire Line + 2450 2850 3000 2850 +Wire Wire Line + 2050 2700 2050 3100 +$Comp +L GND #PWR03 +U 1 1 52FB0453 +P 2050 3100 +F 0 "#PWR03" H 2050 3100 30 0001 C CNN +F 1 "GND" H 2050 3030 30 0001 C CNN +F 2 "" H 2050 3100 60 0000 C CNN +F 3 "" H 2050 3100 60 0000 C CNN + 1 2050 3100 + 1 0 0 -1 +$EndComp +Connection ~ 2050 2800 +Connection ~ 2050 2950 +Text Label 3000 2250 2 60 ~ 0 +NRST +Text Label 3000 2350 2 60 ~ 0 +OSC1IN +Text Label 3000 2450 2 60 ~ 0 +OSC2IN +Text Label 3000 2950 2 60 ~ 0 +PF4 +Text Label 3000 3250 2 60 ~ 0 +PB5 +Text Label 3000 3350 2 60 ~ 0 +PB4 +Text Label 3000 3450 2 60 ~ 0 +PB3 +Text Label 3000 3550 2 60 ~ 0 +PB2 +Text Label 3000 3650 2 60 ~ 0 +PB1 +Text Label 3000 3750 2 60 ~ 0 +PB0 +Text Label 5800 3750 0 60 ~ 0 +PE5 +Text Label 5800 3650 0 60 ~ 0 +PC1 +Text Label 5800 3550 0 60 ~ 0 +PC2 +Text Label 5800 3450 0 60 ~ 0 +PC3 +Text Label 5800 3350 0 60 ~ 0 +PC4 +Text Label 5800 3250 0 60 ~ 0 +PC5 +Text Label 5800 3150 0 60 ~ 0 +PC6 +Text Label 5800 3050 0 60 ~ 0 +PC7 +Text Label 5800 2950 0 60 ~ 0 +PD0 +Text Label 5800 2850 0 60 ~ 0 +SWIM/PD1 +Text Label 5800 2750 0 60 ~ 0 +PD2 +Text Label 5800 2650 0 60 ~ 0 +PD3 +Text Label 5800 2550 0 60 ~ 0 +PD4 +Text Label 5800 2450 0 60 ~ 0 +PD5 +Text Label 5800 2350 0 60 ~ 0 +PD6 +Text Label 5800 2250 0 60 ~ 0 +PD7 +$Comp +L CONN_4 P2 +U 1 1 52FB0A49 +P 4350 1000 +F 0 "P2" V 4300 1000 50 0000 C CNN +F 1 "CONN_4" V 4400 1000 50 0000 C CNN +F 2 "" H 4350 1000 60 0000 C CNN +F 3 "" H 4350 1000 60 0000 C CNN + 1 4350 1000 + 1 0 0 -1 +$EndComp +$Comp +L CONN_14 P1 +U 1 1 52FB0A6A +P 1250 1500 +F 0 "P1" V 1220 1500 60 0000 C CNN +F 1 "CONN_14" V 1330 1500 60 0000 C CNN +F 2 "" H 1250 1500 60 0000 C CNN +F 3 "" H 1250 1500 60 0000 C CNN + 1 1250 1500 + -1 0 0 -1 +$EndComp +$Comp +L CONN_14 P3 +U 1 1 52FB0A79 +P 7100 1500 +F 0 "P3" V 7070 1500 60 0000 C CNN +F 1 "CONN_14" V 7180 1500 60 0000 C CNN +F 2 "" H 7100 1500 60 0000 C CNN +F 3 "" H 7100 1500 60 0000 C CNN + 1 7100 1500 + 1 0 0 -1 +$EndComp +Text Label 1600 1150 0 60 ~ 0 +OSC1IN +Text Label 1600 1250 0 60 ~ 0 +OSC2IN +Text Label 1600 1350 0 60 ~ 0 +PF4 +Text Label 1600 1450 0 60 ~ 0 +PB5 +Text Label 1600 1550 0 60 ~ 0 +PB4 +Text Label 1600 1650 0 60 ~ 0 +PB3 +Text Label 1600 1750 0 60 ~ 0 +PB2 +Text Label 1600 1850 0 60 ~ 0 +PB1 +Text Label 1600 1950 0 60 ~ 0 +PB0 +Text Label 1600 2050 0 60 ~ 0 +PE5 +Text Label 1600 2150 0 60 ~ 0 +PC1 +Text Label 1600 1050 0 60 ~ 0 +NRST +Text Label 4000 950 2 60 ~ 0 +SWIM/PD1 +Text Label 4000 1050 2 60 ~ 0 +NRST +Text Label 6750 850 2 60 ~ 0 +PD7 +Text Label 6750 950 2 60 ~ 0 +PD6 +Text Label 6750 1050 2 60 ~ 0 +PD5 +Text Label 6750 1150 2 60 ~ 0 +PD4 +Text Label 6750 1250 2 60 ~ 0 +PD3 +Text Label 6750 1350 2 60 ~ 0 +PD2 +Text Label 6750 1450 2 60 ~ 0 +SWIM/PD1 +Text Label 6750 1550 2 60 ~ 0 +PD0 +Text Label 6750 1650 2 60 ~ 0 +PC7 +Text Label 6750 1750 2 60 ~ 0 +PC6 +Text Label 6750 1850 2 60 ~ 0 +PC5 +Text Label 6750 1950 2 60 ~ 0 +PC4 +Text Label 6750 2050 2 60 ~ 0 +PC3 +Text Label 6750 2150 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR04 +U 1 1 52FB0DC4 +P 950 2800 +F 0 "#PWR04" H 950 2760 30 0001 C CNN +F 1 "+3.3V" H 950 2910 30 0000 C CNN +F 2 "" H 950 2800 60 0000 C CNN +F 3 "" H 950 2800 60 0000 C CNN + 1 950 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D1 +U 1 1 52FB0DD3 +P 950 3100 +F 0 "D1" H 950 3200 50 0000 C CNN +F 1 "LED" H 950 3000 50 0000 C CNN +F 2 "" H 950 3100 60 0000 C CNN +F 3 "" H 950 3100 60 0000 C CNN + 1 950 3100 + 0 1 1 0 +$EndComp +$Comp +L R R1 +U 1 1 52FB0DE2 +P 950 3600 +F 0 "R1" V 1030 3600 50 0000 C CNN +F 1 "1k" V 950 3600 50 0000 C CNN +F 2 "" H 950 3600 60 0000 C CNN +F 3 "" H 950 3600 60 0000 C CNN + 1 950 3600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 950 2800 950 2900 +Wire Wire Line + 950 3300 950 3350 +Wire Wire Line + 950 3850 950 3950 +$Comp +L +3.3V #PWR05 +U 1 1 52FB0EC7 +P 1300 2800 +F 0 "#PWR05" H 1300 2760 30 0001 C CNN +F 1 "+3.3V" H 1300 2910 30 0000 C CNN +F 2 "" H 1300 2800 60 0000 C CNN +F 3 "" H 1300 2800 60 0000 C CNN + 1 1300 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D2 +U 1 1 52FB0ECD +P 1300 3100 +F 0 "D2" H 1300 3200 50 0000 C CNN +F 1 "LED" H 1300 3000 50 0000 C CNN +F 2 "" H 1300 3100 60 0000 C CNN +F 3 "" H 1300 3100 60 0000 C CNN + 1 1300 3100 + 0 1 1 0 +$EndComp +$Comp +L R R2 +U 1 1 52FB0ED3 +P 1300 3600 +F 0 "R2" V 1380 3600 50 0000 C CNN +F 1 "1k" V 1300 3600 50 0000 C CNN +F 2 "" H 1300 3600 60 0000 C CNN +F 3 "" H 1300 3600 60 0000 C CNN + 1 1300 3600 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR06 +U 1 1 52FB0ED9 +P 1300 3950 +F 0 "#PWR06" H 1300 3950 30 0001 C CNN +F 1 "GND" H 1300 3880 30 0001 C CNN +F 2 "" H 1300 3950 60 0000 C CNN +F 3 "" H 1300 3950 60 0000 C CNN + 1 1300 3950 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1300 2800 1300 2900 +Wire Wire Line + 1300 3300 1300 3350 +Wire Wire Line + 1300 3850 1300 3950 +Text Label 950 3950 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR07 +U 1 1 52FB0EF1 +P 6500 2550 +F 0 "#PWR07" H 6500 2510 30 0001 C CNN +F 1 "+3.3V" H 6500 2660 30 0000 C CNN +F 2 "" H 6500 2550 60 0000 C CNN +F 3 "" H 6500 2550 60 0000 C CNN + 1 6500 2550 + 1 0 0 -1 +$EndComp +$Comp +L R R3 +U 1 1 52FB0EFD +P 6500 2900 +F 0 "R3" V 6580 2900 50 0000 C CNN +F 1 "10k" V 6500 2900 50 0000 C CNN +F 2 "" H 6500 2900 60 0000 C CNN +F 3 "" H 6500 2900 60 0000 C CNN + 1 6500 2900 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR08 +U 1 1 52FB0F03 +P 6500 4050 +F 0 "#PWR08" H 6500 4050 30 0001 C CNN +F 1 "GND" H 6500 3980 30 0001 C CNN +F 2 "" H 6500 4050 60 0000 C CNN +F 3 "" H 6500 4050 60 0000 C CNN + 1 6500 4050 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6500 2550 6500 2650 +Wire Wire Line + 6500 3850 6500 4050 +$Comp +L SW_PUSH SW1 +U 1 1 52FB0F3B +P 6500 3550 +F 0 "SW1" H 6650 3660 50 0000 C CNN +F 1 "SW_PUSH" H 6500 3470 50 0000 C CNN +F 2 "" H 6500 3550 60 0000 C CNN +F 3 "" H 6500 3550 60 0000 C CNN + 1 6500 3550 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 6500 3250 6500 3150 +$Comp +L C C3 +U 1 1 52FB0F99 +P 6900 3550 +F 0 "C3" H 6950 3650 50 0000 L CNN +F 1 "104" H 6950 3450 50 0000 L CNN +F 2 "" H 6900 3550 60 0000 C CNN +F 3 "" H 6900 3550 60 0000 C CNN + 1 6900 3550 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6900 3200 6900 3350 +Wire Wire Line + 6900 3750 6900 3900 +Wire Wire Line + 6900 3900 6500 3900 +Connection ~ 6500 3900 +Wire Wire Line + 6500 3200 6900 3200 +Connection ~ 6500 3200 +Text Label 6500 3200 2 60 ~ 0 +NRST +$Comp +L +3.3V #PWR09 +U 1 1 52FB2273 +P 2150 850 +F 0 "#PWR09" H 2150 810 30 0001 C CNN +F 1 "+3.3V" H 2150 960 30 0000 C CNN +F 2 "" H 2150 850 60 0000 C CNN +F 3 "" H 2150 850 60 0000 C CNN + 1 2150 850 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 850 2150 850 +$Comp +L GND #PWR010 +U 1 1 52FB2296 +P 2150 1000 +F 0 "#PWR010" H 2150 1000 30 0001 C CNN +F 1 "GND" H 2150 930 30 0001 C CNN +F 2 "" H 2150 1000 60 0000 C CNN +F 3 "" H 2150 1000 60 0000 C CNN + 1 2150 1000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 950 2150 950 +Wire Wire Line + 2150 950 2150 1000 +Wire Wire Line + 2600 3050 3000 3050 +Wire Wire Line + 2750 3050 2750 2850 +Connection ~ 2750 2850 +$Comp +L +3.3V #PWR011 +U 1 1 52FB26FA +P 2600 3000 +F 0 "#PWR011" H 2600 2960 30 0001 C CNN +F 1 "+3.3V" H 2600 3110 30 0000 C CNN +F 2 "" H 2600 3000 60 0000 C CNN +F 3 "" H 2600 3000 60 0000 C CNN + 1 2600 3000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2600 3000 2600 3050 +Connection ~ 2750 3050 +$Comp +L +3.3V #PWR012 +U 1 1 52FB286D +P 4000 750 +F 0 "#PWR012" H 4000 710 30 0001 C CNN +F 1 "+3.3V" H 4000 860 30 0000 C CNN +F 2 "" H 4000 750 60 0000 C CNN +F 3 "" H 4000 750 60 0000 C CNN + 1 4000 750 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR013 +U 1 1 52FB287C +P 4000 1300 +F 0 "#PWR013" H 4000 1300 30 0001 C CNN +F 1 "GND" H 4000 1230 30 0001 C CNN +F 2 "" H 4000 1300 60 0000 C CNN +F 3 "" H 4000 1300 60 0000 C CNN + 1 4000 1300 + 1 0 0 -1 +$EndComp +Wire Wire Line + 4000 1300 4000 1150 +Wire Wire Line + 4000 850 4000 750 +$Comp +L CONN_6 P4 +U 1 1 52FB29A7 +P 1050 5300 +F 0 "P4" V 1000 5300 50 0000 C CNN +F 1 "CONN_5" V 1100 5300 50 0000 C CNN +F 2 "" H 1050 5300 60 0000 C CNN +F 3 "" H 1050 5300 60 0000 C CNN + 1 1050 5300 + -1 0 0 1 +$EndComp +Text Notes 800 5750 0 60 ~ 0 +Motor N enable +Text Label 1400 5550 0 60 ~ 0 +PB0 +Text Label 1400 5450 0 60 ~ 0 +PB1 +Text Label 1400 5350 0 60 ~ 0 +PB2 +Text Label 1400 5250 0 60 ~ 0 +PB3 +Text Label 1400 5150 0 60 ~ 0 +PB4 +$Comp +L GND #PWR014 +U 1 1 52FB2B4C +P 1800 5150 +F 0 "#PWR014" H 1800 5150 30 0001 C CNN +F 1 "GND" H 1800 5080 30 0001 C CNN +F 2 "" H 1800 5150 60 0000 C CNN +F 3 "" H 1800 5150 60 0000 C CNN + 1 1800 5150 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1400 5050 1800 5050 +Wire Wire Line + 1800 5050 1800 5150 +$Comp +L CONN_3 K1 +U 1 1 52FB2C32 +P 1050 6100 +F 0 "K1" V 1000 6100 50 0000 C CNN +F 1 "CONN_3" V 1100 6100 40 0000 C CNN +F 2 "" H 1050 6100 60 0000 C CNN +F 3 "" H 1050 6100 60 0000 C CNN + 1 1050 6100 + -1 0 0 1 +$EndComp +Text Notes 700 6400 0 60 ~ 0 +All motors DIR/CLK +Text Label 1400 6000 0 60 ~ 0 +PD4 +Text Label 1400 6100 0 60 ~ 0 +PB5 +$Comp +L +3.3V #PWR015 +U 1 1 52FB2C41 +P 1850 6200 +F 0 "#PWR015" H 1850 6160 30 0001 C CNN +F 1 "+3.3V" H 1850 6310 30 0000 C CNN +F 2 "" H 1850 6200 60 0000 C CNN +F 3 "" H 1850 6200 60 0000 C CNN + 1 1850 6200 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1400 6200 1850 6200 +Text Notes 750 6000 0 60 ~ 0 +CLK +Text Notes 750 6100 0 60 ~ 0 +DIR +Text Notes 750 6250 0 60 ~ 0 +VDD +Text Notes 700 5050 0 60 ~ 0 +GND +Text Notes 700 5150 0 60 ~ 0 +EN4 +Text Notes 700 5250 0 60 ~ 0 +EN3 +Text Notes 700 5350 0 60 ~ 0 +EN2 +Text Notes 700 5450 0 60 ~ 0 +EN1 +Text Notes 700 5550 0 60 ~ 0 +EN0 +Wire Notes Line + 600 500 600 4200 +Wire Notes Line + 600 4200 7500 4200 +Wire Notes Line + 7500 4200 7500 500 +Wire Notes Line + 7500 500 600 500 +Text Notes 3550 4450 0 118 ~ 0 +STM8 board +$EndSCHEMATC diff --git a/stepper/schematic/stm8s105k4t6c.bck b/stepper/schematic/stm8s105k4t6c.bck new file mode 100644 index 0000000..5efbdbd --- /dev/null +++ b/stepper/schematic/stm8s105k4t6c.bck @@ -0,0 +1,9 @@ +EESchema-DOCLIB Version 2.0 Date: Вт 11 фев 2014 17:09:58 +# +$CMP STM8S003K3T +D STM8S003K3T, LQFP32 (7x7, 0.8mm pitch), 16MHz, 8K Flash, 1K RAM, 128 EEPROM +K STM8 Microcontroller Value Line +F http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00024550.pdf +$ENDCMP +# +#End Doc Library diff --git a/stepper/schematic/stm8s105k4t6c.dcm b/stepper/schematic/stm8s105k4t6c.dcm new file mode 100644 index 0000000..71362a5 --- /dev/null +++ b/stepper/schematic/stm8s105k4t6c.dcm @@ -0,0 +1,13 @@ +EESchema-DOCLIB Version 2.0 Date: Вт 11 фев 2014 17:26:38 +# +$CMP STM8S003K3T +D STM8S003K3T, LQFP32 (7x7, 0.8mm pitch), 16MHz, 8K Flash, 1K RAM, 128 EEPROM +K STM8 Microcontroller Value Line +F http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00024550.pdf +$ENDCMP +# +$CMP STM8S105K4T6C +K stm8 +$ENDCMP +# +#End Doc Library diff --git a/stepper/schematic/stm8s105k4t6c.lib b/stepper/schematic/stm8s105k4t6c.lib new file mode 100644 index 0000000..4b3ba70 --- /dev/null +++ b/stepper/schematic/stm8s105k4t6c.lib @@ -0,0 +1,99 @@ +EESchema-LIBRARY Version 2.3 Date: Вт 11 фев 2014 17:26:38 +#encoding utf-8 +# +# STM8S003K3T +# +DEF STM8S003K3T IC 0 40 Y Y 1 F N +F0 "IC" -800 1150 60 H V C CNN +F1 "STM8S003K3T" 550 -1100 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + LQFP32* +$ENDFPLIST +DRAW +S -850 1100 850 -1050 0 1 10 f +X NRST 1 -1000 1000 149 R 40 40 1 1 I +X OSCI/PA1 2 1000 1000 149 L 40 40 1 1 B +X OSCOUT/PA2 3 1000 900 149 L 40 40 1 1 B +X VSS 4 0 -1200 149 U 40 40 1 1 W +X Vcap 5 -1000 -950 149 R 40 40 1 1 I +X VDD 6 0 1250 149 D 40 40 1 1 W +X [SPI_NSS]TIM2_CH3/PA3 7 1000 800 149 L 40 40 1 1 B +X PF4 8 -1000 -350 149 R 40 40 1 1 B +X PB7 9 1000 -50 149 L 40 40 1 1 B +X PB6 10 1000 50 149 L 40 40 1 1 B +X TIM1_CH3/PC3 20 1000 -400 149 L 40 40 1 1 B +X PD5/UART1_TX 30 -1000 150 149 R 40 40 1 1 B +X I2C_SDA/PB5 11 1000 150 149 L 40 40 1 1 B +X CLK_CCO/TIM1_CH4/PC4 21 1000 -500 149 L 40 40 1 1 B +X PD6/UART1_RX 31 -1000 50 149 R 40 40 1 1 B +X I2C_SCL/PB4 12 1000 250 149 L 40 40 1 1 B +X SPI_SCK/PC5 22 1000 -600 149 L 40 40 1 1 B +X PD7/TLI[TIM1_CH4] 32 -1000 -50 148 R 40 40 1 1 B +X TIM1_ETR/AIN3/PB3 13 1000 350 149 L 40 40 1 1 B +X PI_MOSI/PC6 23 1000 -700 149 L 40 40 1 1 B +X TIM1_CH3N/AIN2/PB2 14 1000 450 149 L 40 40 1 1 B +X PI_MISO/PC7 24 1000 -800 149 L 40 40 1 1 B +X TIM1_CH2N/AIN1/PB1 15 1000 550 149 L 40 40 1 1 B +X PD0/TIM1_BKIN[CLK_CCO] 25 -1000 650 148 R 40 40 1 1 B +X TIM1_CH1N/AIN0/PB0 16 1000 650 149 L 40 40 1 1 B +X PD1/SWIM 26 -1000 550 149 R 40 40 1 1 B +X PE5/SPI_NSS 17 -1000 -200 148 R 40 40 1 1 B +X PD2[TIM2_CH3] 27 -1000 450 149 R 40 40 1 1 B +X UART1_CK/TIM1_CH1/PC1 18 1000 -200 149 L 40 40 1 1 B +X PD3/ADC_ETR/TIM2_CH2 28 -1000 350 149 R 40 40 1 1 B +X TIM1_CH2/PC2 19 1000 -300 149 L 40 40 1 1 B +X PD4/BEEP/TIM2_CH1 29 -1000 250 149 R 40 40 1 1 B +ENDDRAW +ENDDEF +# +# STM8S105K4T6C +# +DEF STM8S105K4T6C U 0 40 Y Y 1 F N +F0 "U" 0 1050 60 H V C CNN +F1 "STM8S105K4T6C" 50 -850 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS stm8s105* +$FPLIST + lqfp32* +$ENDFPLIST +DRAW +S -1100 950 1100 -750 0 1 0 N +X NRST 1 -1400 850 300 R 50 50 1 1 I +X OSCIN/PA1 2 -1400 750 300 R 50 50 1 1 T +X OSCOUT/PA2 3 -1400 650 300 R 50 50 1 1 T +X VSS 4 -1400 550 300 R 50 50 1 1 W +X VCAP 5 -1400 450 300 R 50 50 1 1 w +X VDD(3.3-5v) 6 -1400 350 300 R 50 50 1 1 W +X VDDio 7 -1400 250 300 R 50 50 1 1 W +X PF4/AIN12 8 -1400 150 300 R 50 50 1 1 T +X VDDA 9 -1400 50 300 R 50 50 1 1 W +X VSSA 10 -1400 -50 300 R 50 50 1 1 W +X PC3(HS)/TIM1_CH3 20 1400 -350 300 L 50 50 1 1 T +X PD5/UART2_TX 30 1400 650 300 L 50 50 1 1 T +X PB5/AIN5[I2X_SDA] 11 -1400 -150 300 R 50 50 1 1 T +X PC4(HS)/TIM1_CH4 21 1400 -250 300 L 50 50 1 1 T +X PD6/UART2_RX 31 1400 750 300 L 50 50 1 1 T +X PB4/AIN4[I2C_SCL] 12 -1400 -250 300 R 50 50 1 1 T +X PC5(HS)/SPI_SCK 22 1400 -150 300 L 50 50 1 1 T +X PD7/TLI[TIM1_CH4] 32 1400 850 300 L 50 50 1 1 T +X PB3/AIN3[TIM1_ETR] 13 -1400 -350 300 R 50 50 1 1 T +X PC6(HS)/SPI_MOSI 23 1400 -50 300 L 50 50 1 1 T +X PB2/AIN2[TIM1_CH3N] 14 -1400 -450 300 R 50 50 1 1 T +X PC7(HS)/SPI_MISO 24 1400 50 300 L 50 50 1 1 T +X PB1/AIN1_[TIM1_CH2N] 15 -1400 -550 300 R 50 50 1 1 T +X PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO] 25 1400 150 300 L 50 50 1 1 T +X PB0/AIN0_[TIM1_CH1N] 16 -1400 -650 300 R 50 50 1 1 T +X PD1(HS)/SWIM 26 1400 250 300 L 50 50 1 1 T +X PE5/SPI_NSS 17 1400 -650 300 L 50 50 1 1 T +X PD2(HS)/TIM3_CH1[TIM2_CH3] 27 1400 350 300 L 50 50 1 1 T +X PC1(HS)/TIM1_CH1 18 1400 -550 300 L 50 50 1 1 T +X PD3(HS)/TIM2_CH2[ADC_ETR] 28 1400 450 300 L 50 50 1 1 T +X PC2(HS)/TIM1_CH2 19 1400 -450 300 L 50 50 1 1 T +X PD4(HS)/TIM2_CH1[BEEP] 29 1400 550 300 L 50 50 1 1 T +ENDDRAW +ENDDEF +# +#End Library diff --git a/stepper/schematic/template-cache.lib b/stepper/schematic/template-cache.lib new file mode 100644 index 0000000..29610dc --- /dev/null +++ b/stepper/schematic/template-cache.lib @@ -0,0 +1,204 @@ +EESchema-LIBRARY Version 2.3 Date: Ср 12 фев 2014 11:37:03 +#encoding utf-8 +# +# +3.3V +# +DEF +3.3V #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -40 30 H I C CNN +F1 "+3.3V" 0 110 30 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS +3,3V +DRAW +X +3.3V 1 0 0 0 U 30 30 0 0 W N +C 0 60 20 0 1 0 N +P 3 0 1 0 0 0 0 40 0 40 N +ENDDRAW +ENDDEF +# +# C +# +DEF C C 0 10 N Y 1 F N +F0 "C" 0 100 40 H V L CNN +F1 "C" 6 -85 40 H V L CNN +F2 "~" 38 -150 30 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + SM* + C? + C1-1 +$ENDFPLIST +DRAW +P 2 0 1 20 -80 -30 80 -30 N +P 2 0 1 20 -80 30 80 30 N +X ~ 1 0 200 170 D 40 40 1 1 P +X ~ 2 0 -200 170 U 40 40 1 1 P +ENDDRAW +ENDDEF +# +# CONN_14 +# +DEF CONN_14 P 0 40 Y N 1 F N +F0 "P" -30 0 60 V V C CNN +F1 "CONN_14" 80 0 60 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 700 150 -700 0 1 0 N +X P1 1 -350 650 250 R 50 50 1 1 P I +X P2 2 -350 550 250 R 50 50 1 1 P I +X P3 3 -350 450 250 R 50 50 1 1 P I +X P4 4 -350 350 250 R 50 50 1 1 P I +X P5 5 -350 250 250 R 50 50 1 1 P I +X P6 6 -350 150 250 R 50 50 1 1 P I +X P7 7 -350 50 250 R 50 50 1 1 P I +X P8 8 -350 -50 250 R 50 50 1 1 P I +X P9 9 -350 -150 250 R 50 50 1 1 P I +X P10 10 -350 -250 250 R 50 50 1 1 P I +X P11 11 -350 -350 250 R 50 50 1 1 P I +X P12 12 -350 -450 250 R 50 50 1 1 P I +X P13 13 -350 -550 250 R 50 50 1 1 P I +X P14 14 -350 -650 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_4 +# +DEF CONN_4 P 0 40 Y N 1 F N +F0 "P" -50 0 50 V V C CNN +F1 "CONN_4" 50 0 50 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 200 100 -200 0 1 0 N +X P1 1 -350 150 250 R 50 50 1 1 P I +X P2 2 -350 50 250 R 50 50 1 1 P I +X P3 3 -350 -50 250 R 50 50 1 1 P I +X P4 4 -350 -150 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# GND +# +DEF ~GND #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 0 30 H I C CNN +F1 "GND" 0 -70 30 H I C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N +X GND 1 0 0 0 U 30 30 1 1 W N +ENDDRAW +ENDDEF +# +# LED +# +DEF LED D 0 40 Y N 1 F N +F0 "D" 0 100 50 H V C CNN +F1 "LED" 0 -100 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + LED-3MM + LED-5MM + LED-10MM + LED-0603 + LED-0805 + LED-1206 + LEDV +$ENDFPLIST +DRAW +P 2 0 1 0 50 50 50 -50 N +P 3 0 1 0 -50 50 50 0 -50 -50 F +P 3 0 1 0 65 -40 110 -80 105 -55 N +P 3 0 1 0 80 -25 125 -65 120 -40 N +X A 1 -200 0 150 R 40 40 1 1 P +X K 2 200 0 150 L 40 40 1 1 P +ENDDRAW +ENDDEF +# +# R +# +DEF R R 0 0 N Y 1 F N +F0 "R" 80 0 40 V V C CNN +F1 "R" 7 1 40 V V C CNN +F2 "~" -70 0 30 V V C CNN +F3 "~" 0 0 30 H V C CNN +$FPLIST + R? + SM0603 + SM0805 + R?-* + SM1206 +$ENDFPLIST +DRAW +S -40 150 40 -150 0 1 12 N +X ~ 1 0 250 100 D 60 60 1 1 P +X ~ 2 0 -250 100 U 60 60 1 1 P +ENDDRAW +ENDDEF +# +# STM8S105K4T6C +# +DEF STM8S105K4T6C U 0 40 Y Y 1 F N +F0 "U" 0 1050 60 H V C CNN +F1 "STM8S105K4T6C" 50 -850 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS stm8s105* +$FPLIST + lqfp32* +$ENDFPLIST +DRAW +S -1100 950 1100 -750 0 1 0 N +X NRST 1 -1400 850 300 R 50 50 1 1 I +X OSCIN/PA1 2 -1400 750 300 R 50 50 1 1 T +X OSCOUT/PA2 3 -1400 650 300 R 50 50 1 1 T +X VSS 4 -1400 550 300 R 50 50 1 1 W +X VCAP 5 -1400 450 300 R 50 50 1 1 w +X VDD(3.3-5v) 6 -1400 350 300 R 50 50 1 1 W +X VDDio 7 -1400 250 300 R 50 50 1 1 W +X PF4/AIN12 8 -1400 150 300 R 50 50 1 1 T +X VDDA 9 -1400 50 300 R 50 50 1 1 W +X VSSA 10 -1400 -50 300 R 50 50 1 1 W +X PC3(HS)/TIM1_CH3 20 1400 -350 300 L 50 50 1 1 T +X PD5/UART2_TX 30 1400 650 300 L 50 50 1 1 T +X PB5/AIN5[I2X_SDA] 11 -1400 -150 300 R 50 50 1 1 T +X PC4(HS)/TIM1_CH4 21 1400 -250 300 L 50 50 1 1 T +X PD6/UART2_RX 31 1400 750 300 L 50 50 1 1 T +X PB4/AIN4[I2C_SCL] 12 -1400 -250 300 R 50 50 1 1 T +X PC5(HS)/SPI_SCK 22 1400 -150 300 L 50 50 1 1 T +X PD7/TLI[TIM1_CH4] 32 1400 850 300 L 50 50 1 1 T +X PB3/AIN3[TIM1_ETR] 13 -1400 -350 300 R 50 50 1 1 T +X PC6(HS)/SPI_MOSI 23 1400 -50 300 L 50 50 1 1 T +X PB2/AIN2[TIM1_CH3N] 14 -1400 -450 300 R 50 50 1 1 T +X PC7(HS)/SPI_MISO 24 1400 50 300 L 50 50 1 1 T +X PB1/AIN1_[TIM1_CH2N] 15 -1400 -550 300 R 50 50 1 1 T +X PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO] 25 1400 150 300 L 50 50 1 1 T +X PB0/AIN0_[TIM1_CH1N] 16 -1400 -650 300 R 50 50 1 1 T +X PD1(HS)/SWIM 26 1400 250 300 L 50 50 1 1 T +X PE5/SPI_NSS 17 1400 -650 300 L 50 50 1 1 T +X PD2(HS)/TIM3_CH1[TIM2_CH3] 27 1400 350 300 L 50 50 1 1 T +X PC1(HS)/TIM1_CH1 18 1400 -550 300 L 50 50 1 1 T +X PD3(HS)/TIM2_CH2[ADC_ETR] 28 1400 450 300 L 50 50 1 1 T +X PC2(HS)/TIM1_CH2 19 1400 -450 300 L 50 50 1 1 T +X PD4(HS)/TIM2_CH1[BEEP] 29 1400 550 300 L 50 50 1 1 T +ENDDRAW +ENDDEF +# +# SW_PUSH +# +DEF SW_PUSH SW 0 40 N N 1 F N +F0 "SW" 150 110 50 H V C CNN +F1 "SW_PUSH" 0 -80 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -170 50 170 60 0 1 0 N +P 4 0 1 0 -40 60 -30 90 30 90 40 60 N +X 1 1 -300 0 200 R 60 60 0 1 P I +X 2 2 300 0 200 L 60 60 0 1 P I +ENDDRAW +ENDDEF +# +#End Library diff --git a/stepper/schematic/template.cmp b/stepper/schematic/template.cmp new file mode 100644 index 0000000..c1d5ca2 --- /dev/null +++ b/stepper/schematic/template.cmp @@ -0,0 +1,94 @@ +Cmp-Mod V01 Created by CvPcb (2013-feb-26)-stable date = Ср 12 фев 2014 11:23:52 + +BeginCmp +TimeStamp = /52FB0413; +Reference = C1; +ValeurCmp = 1u; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0426; +Reference = C2; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F99; +Reference = C3; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0DD3; +Reference = D1; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ECD; +Reference = D2; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0A6A; +Reference = P1; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB0A49; +Reference = P2; +ValeurCmp = CONN_4; +IdModule = SIL-4; +EndCmp + +BeginCmp +TimeStamp = /52FB0A79; +Reference = P3; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB0DE2; +Reference = R1; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ED3; +Reference = R2; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0EFD; +Reference = R3; +ValeurCmp = 10k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F3B; +Reference = SW1; +ValeurCmp = SW_PUSH; +IdModule = SM2010; +EndCmp + +BeginCmp +TimeStamp = /52FB03A2; +Reference = U1; +ValeurCmp = STM8S105K4T6C; +IdModule = TQFP32; +EndCmp + +EndListe diff --git a/stepper/schematic/template.net b/stepper/schematic/template.net new file mode 100644 index 0000000..b85b993 --- /dev/null +++ b/stepper/schematic/template.net @@ -0,0 +1,321 @@ +(export (version D) + (design + (source /home/eddy/Docs/SAO/ELECTRONICS/STM8/stepper/schematic/kicad.sch) + (date "Ср 12 фев 2014 11:38:18") + (tool "eeschema (2013-feb-26)-stable")) + (components + (comp (ref U1) + (value STM8S105K4T6C) + (libsource (lib stm8s105k4t6c) (part STM8S105K4T6C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB03A2)) + (comp (ref C1) + (value 1u) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0413)) + (comp (ref C2) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0426)) + (comp (ref P2) + (value CONN_4) + (libsource (lib conn) (part CONN_4)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A49)) + (comp (ref P1) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A6A)) + (comp (ref P3) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A79)) + (comp (ref D1) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DD3)) + (comp (ref R1) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DE2)) + (comp (ref D2) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ECD)) + (comp (ref R2) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ED3)) + (comp (ref R3) + (value 10k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0EFD)) + (comp (ref SW1) + (value SW_PUSH) + (libsource (lib device) (part SW_PUSH)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F3B)) + (comp (ref C3) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F99))) + (libparts + (libpart (lib device) (part C) + (description "Condensateur non polarise") + (footprints + (fp SM*) + (fp C?) + (fp C1-1)) + (fields + (field (name Reference) C) + (field (name Value) C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part LED) + (footprints + (fp LED-3MM) + (fp LED-5MM) + (fp LED-10MM) + (fp LED-0603) + (fp LED-0805) + (fp LED-1206) + (fp LEDV)) + (fields + (field (name Reference) D) + (field (name Value) LED) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name A) (type passive)) + (pin (num 2) (name K) (type passive)))) + (libpart (lib device) (part R) + (description Resistance) + (footprints + (fp R?) + (fp SM0603) + (fp SM0805) + (fp R?-*) + (fp SM1206)) + (fields + (field (name Reference) R) + (field (name Value) R) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part SW_PUSH) + (description "Push Button") + (fields + (field (name Reference) SW) + (field (name Value) SW_PUSH) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name 1) (type passive)) + (pin (num 2) (name 2) (type passive)))) + (libpart (lib conn) (part CONN_14) + (description "Symbole general de connexion") + (fields + (field (name Reference) P) + (field (name Value) CONN_14)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)) + (pin (num 5) (name P5) (type passive)) + (pin (num 6) (name P6) (type passive)) + (pin (num 7) (name P7) (type passive)) + (pin (num 8) (name P8) (type passive)) + (pin (num 9) (name P9) (type passive)) + (pin (num 10) (name P10) (type passive)) + (pin (num 11) (name P11) (type passive)) + (pin (num 12) (name P12) (type passive)) + (pin (num 13) (name P13) (type passive)) + (pin (num 14) (name P14) (type passive)))) + (libpart (lib conn) (part CONN_4) + (description "Symbole general de connecteur") + (fields + (field (name Reference) P) + (field (name Value) CONN_4)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)))) + (libpart (lib stm8s105k4t6c) (part STM8S105K4T6C) + (footprints + (fp lqfp32*)) + (fields + (field (name Reference) U) + (field (name Value) STM8S105K4T6C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name NRST) (type input)) + (pin (num 2) (name OSCIN/PA1) (type 3state)) + (pin (num 3) (name OSCOUT/PA2) (type 3state)) + (pin (num 4) (name VSS) (type power_in)) + (pin (num 5) (name VCAP) (type power_out)) + (pin (num 6) (name "VDD(3.3-5v)") (type power_in)) + (pin (num 7) (name VDDio) (type power_in)) + (pin (num 8) (name PF4/AIN12) (type 3state)) + (pin (num 9) (name VDDA) (type power_in)) + (pin (num 10) (name VSSA) (type power_in)) + (pin (num 11) (name PB5/AIN5[I2X_SDA]) (type 3state)) + (pin (num 12) (name PB4/AIN4[I2C_SCL]) (type 3state)) + (pin (num 13) (name PB3/AIN3[TIM1_ETR]) (type 3state)) + (pin (num 14) (name PB2/AIN2[TIM1_CH3N]) (type 3state)) + (pin (num 15) (name PB1/AIN1_[TIM1_CH2N]) (type 3state)) + (pin (num 16) (name PB0/AIN0_[TIM1_CH1N]) (type 3state)) + (pin (num 17) (name PE5/SPI_NSS) (type 3state)) + (pin (num 18) (name "PC1(HS)/TIM1_CH1") (type 3state)) + (pin (num 19) (name "PC2(HS)/TIM1_CH2") (type 3state)) + (pin (num 20) (name "PC3(HS)/TIM1_CH3") (type 3state)) + (pin (num 21) (name "PC4(HS)/TIM1_CH4") (type 3state)) + (pin (num 22) (name "PC5(HS)/SPI_SCK") (type 3state)) + (pin (num 23) (name "PC6(HS)/SPI_MOSI") (type 3state)) + (pin (num 24) (name "PC7(HS)/SPI_MISO") (type 3state)) + (pin (num 25) (name "PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO]") (type 3state)) + (pin (num 26) (name "PD1(HS)/SWIM") (type 3state)) + (pin (num 27) (name "PD2(HS)/TIM3_CH1[TIM2_CH3]") (type 3state)) + (pin (num 28) (name "PD3(HS)/TIM2_CH2[ADC_ETR]") (type 3state)) + (pin (num 29) (name "PD4(HS)/TIM2_CH1[BEEP]") (type 3state)) + (pin (num 30) (name PD5/UART2_TX) (type 3state)) + (pin (num 31) (name PD6/UART2_RX) (type 3state)) + (pin (num 32) (name PD7/TLI[TIM1_CH4]) (type 3state))))) + (libraries + (library (logical device) + (uri /usr/share/kicad/library/device.lib)) + (library (logical conn) + (uri /usr/share/kicad/library/conn.lib)) + (library (logical stm8s105k4t6c) + (uri stm8s105k4t6c.lib))) + (nets + (net (code 1) (name +3.3V) + (node (ref P1) (pin 1)) + (node (ref P2) (pin 1)) + (node (ref U1) (pin 9)) + (node (ref U1) (pin 7)) + (node (ref U1) (pin 6)) + (node (ref C2) (pin 2)) + (node (ref D2) (pin 1)) + (node (ref R3) (pin 1)) + (node (ref D1) (pin 1))) + (net (code 2) (name "") + (node (ref D1) (pin 2)) + (node (ref R1) (pin 1))) + (net (code 3) (name /PD4) + (node (ref U1) (pin 29)) + (node (ref P3) (pin 4))) + (net (code 4) (name /PD3) + (node (ref P3) (pin 5)) + (node (ref U1) (pin 28))) + (net (code 5) (name /PD2) + (node (ref U1) (pin 27)) + (node (ref P3) (pin 6))) + (net (code 6) (name /SWIM/PD1) + (node (ref U1) (pin 26)) + (node (ref P3) (pin 7)) + (node (ref P2) (pin 2))) + (net (code 7) (name /PD0) + (node (ref P3) (pin 8)) + (node (ref U1) (pin 25))) + (net (code 8) (name /PC7) + (node (ref P3) (pin 9)) + (node (ref U1) (pin 24))) + (net (code 9) (name /PC6) + (node (ref U1) (pin 23)) + (node (ref P3) (pin 10))) + (net (code 10) (name /PC5) + (node (ref P3) (pin 11)) + (node (ref U1) (pin 22))) + (net (code 11) (name /PC4) + (node (ref P3) (pin 12)) + (node (ref U1) (pin 21))) + (net (code 12) (name /PC3) + (node (ref U1) (pin 20)) + (node (ref P3) (pin 13))) + (net (code 13) (name /PC2) + (node (ref P3) (pin 14)) + (node (ref U1) (pin 19)) + (node (ref R1) (pin 2))) + (net (code 14) (name GND) + (node (ref P2) (pin 4)) + (node (ref C1) (pin 1)) + (node (ref C2) (pin 1)) + (node (ref U1) (pin 10)) + (node (ref U1) (pin 4)) + (node (ref R2) (pin 2)) + (node (ref SW1) (pin 1)) + (node (ref C3) (pin 2)) + (node (ref P1) (pin 2))) + (net (code 15) (name "") + (node (ref R2) (pin 1)) + (node (ref D2) (pin 2))) + (net (code 16) (name /PD5) + (node (ref P3) (pin 3)) + (node (ref U1) (pin 30))) + (net (code 17) (name "") + (node (ref C1) (pin 2)) + (node (ref U1) (pin 5))) + (net (code 18) (name /OSC2IN) + (node (ref P1) (pin 5)) + (node (ref U1) (pin 3))) + (net (code 19) (name /NRST) + (node (ref U1) (pin 1)) + (node (ref R3) (pin 2)) + (node (ref SW1) (pin 2)) + (node (ref C3) (pin 1)) + (node (ref P1) (pin 3)) + (node (ref P2) (pin 3))) + (net (code 20) (name /OSC1IN) + (node (ref U1) (pin 2)) + (node (ref P1) (pin 4))) + (net (code 21) (name /PF4) + (node (ref P1) (pin 6)) + (node (ref U1) (pin 8))) + (net (code 22) (name /PB5) + (node (ref P1) (pin 7)) + (node (ref U1) (pin 11))) + (net (code 23) (name /PB4) + (node (ref P1) (pin 8)) + (node (ref U1) (pin 12))) + (net (code 24) (name /PB3) + (node (ref U1) (pin 13)) + (node (ref P1) (pin 9))) + (net (code 25) (name /PB2) + (node (ref P1) (pin 10)) + (node (ref U1) (pin 14))) + (net (code 26) (name /PB1) + (node (ref P1) (pin 11)) + (node (ref U1) (pin 15))) + (net (code 27) (name /PB0) + (node (ref P1) (pin 12)) + (node (ref U1) (pin 16))) + (net (code 28) (name /PE5) + (node (ref P1) (pin 13)) + (node (ref U1) (pin 17))) + (net (code 29) (name /PC1) + (node (ref P1) (pin 14)) + (node (ref U1) (pin 18))) + (net (code 30) (name /PD7) + (node (ref U1) (pin 32)) + (node (ref P3) (pin 1))) + (net (code 31) (name /PD6) + (node (ref U1) (pin 31)) + (node (ref P3) (pin 2))))) \ No newline at end of file diff --git a/stepper/schematic/template.sch b/stepper/schematic/template.sch new file mode 100644 index 0000000..cb79ec3 --- /dev/null +++ b/stepper/schematic/template.sch @@ -0,0 +1,518 @@ +EESchema Schematic File Version 2 date Ср 12 фев 2014 11:37:03 +LIBS:power +LIBS:device +LIBS:transistors +LIBS:conn +LIBS:linear +LIBS:regul +LIBS:74xx +LIBS:cmos4000 +LIBS:adc-dac +LIBS:memory +LIBS:xilinx +LIBS:special +LIBS:microcontrollers +LIBS:dsp +LIBS:microchip +LIBS:analog_switches +LIBS:motorola +LIBS:texas +LIBS:intel +LIBS:audio +LIBS:interface +LIBS:digital-audio +LIBS:philips +LIBS:display +LIBS:cypress +LIBS:siliconi +LIBS:opto +LIBS:atmel +LIBS:contrib +LIBS:valves +LIBS:stm8 +LIBS:st-microelectronics +LIBS:stm8s105k4t6c +LIBS:kicad-cache +EELAYER 27 0 +EELAYER END +$Descr A4 11693 8268 +encoding utf-8 +Sheet 1 1 +Title "" +Date "12 feb 2014" +Rev "" +Comp "" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L STM8S105K4T6C U1 +U 1 1 52FB03A2 +P 4400 3100 +F 0 "U1" H 4400 4150 60 0000 C CNN +F 1 "STM8S105K4T6C" H 4450 2250 60 0000 C CNN +F 2 "~" H 4400 3100 60 0000 C CNN +F 3 "~" H 4400 3100 60 0000 C CNN + 1 4400 3100 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR01 +U 1 1 52FB03EF +P 2750 3200 +F 0 "#PWR01" H 2750 3200 30 0001 C CNN +F 1 "GND" H 2750 3130 30 0001 C CNN +F 2 "" H 2750 3200 60 0000 C CNN +F 3 "" H 2750 3200 60 0000 C CNN + 1 2750 3200 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 3200 2750 3150 +Wire Wire Line + 2750 3150 3000 3150 +$Comp +L GND #PWR02 +U 1 1 52FB0400 +P 2750 2600 +F 0 "#PWR02" H 2750 2600 30 0001 C CNN +F 1 "GND" H 2750 2530 30 0001 C CNN +F 2 "" H 2750 2600 60 0000 C CNN +F 3 "" H 2750 2600 60 0000 C CNN + 1 2750 2600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 2600 2750 2550 +Wire Wire Line + 2750 2550 3000 2550 +$Comp +L C C1 +U 1 1 52FB0413 +P 2250 2700 +F 0 "C1" H 2300 2800 50 0000 L CNN +F 1 "1u" H 2300 2600 50 0000 L CNN +F 2 "" H 2250 2700 60 0000 C CNN +F 3 "" H 2250 2700 60 0000 C CNN + 1 2250 2700 + 0 -1 -1 0 +$EndComp +$Comp +L C C2 +U 1 1 52FB0426 +P 2250 2950 +F 0 "C2" H 2300 3050 50 0000 L CNN +F 1 "104" H 2300 2850 50 0000 L CNN +F 2 "" H 2250 2950 60 0000 C CNN +F 3 "" H 2250 2950 60 0000 C CNN + 1 2250 2950 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 2450 2700 2850 2700 +Wire Wire Line + 2850 2700 2850 2650 +Wire Wire Line + 2850 2650 3000 2650 +Wire Wire Line + 3000 2750 3000 2850 +Wire Wire Line + 2450 2950 2450 2850 +Wire Wire Line + 2450 2850 3000 2850 +Wire Wire Line + 2050 2700 2050 3100 +$Comp +L GND #PWR03 +U 1 1 52FB0453 +P 2050 3100 +F 0 "#PWR03" H 2050 3100 30 0001 C CNN +F 1 "GND" H 2050 3030 30 0001 C CNN +F 2 "" H 2050 3100 60 0000 C CNN +F 3 "" H 2050 3100 60 0000 C CNN + 1 2050 3100 + 1 0 0 -1 +$EndComp +Connection ~ 2050 2800 +Connection ~ 2050 2950 +Text Label 3000 2250 2 60 ~ 0 +NRST +Text Label 3000 2350 2 60 ~ 0 +OSC1IN +Text Label 3000 2450 2 60 ~ 0 +OSC2IN +Text Label 3000 2950 2 60 ~ 0 +PF4 +Text Label 3000 3250 2 60 ~ 0 +PB5 +Text Label 3000 3350 2 60 ~ 0 +PB4 +Text Label 3000 3450 2 60 ~ 0 +PB3 +Text Label 3000 3550 2 60 ~ 0 +PB2 +Text Label 3000 3650 2 60 ~ 0 +PB1 +Text Label 3000 3750 2 60 ~ 0 +PB0 +Text Label 5800 3750 0 60 ~ 0 +PE5 +Text Label 5800 3650 0 60 ~ 0 +PC1 +Text Label 5800 3550 0 60 ~ 0 +PC2 +Text Label 5800 3450 0 60 ~ 0 +PC3 +Text Label 5800 3350 0 60 ~ 0 +PC4 +Text Label 5800 3250 0 60 ~ 0 +PC5 +Text Label 5800 3150 0 60 ~ 0 +PC6 +Text Label 5800 3050 0 60 ~ 0 +PC7 +Text Label 5800 2950 0 60 ~ 0 +PD0 +Text Label 5800 2850 0 60 ~ 0 +SWIM/PD1 +Text Label 5800 2750 0 60 ~ 0 +PD2 +Text Label 5800 2650 0 60 ~ 0 +PD3 +Text Label 5800 2550 0 60 ~ 0 +PD4 +Text Label 5800 2450 0 60 ~ 0 +PD5 +Text Label 5800 2350 0 60 ~ 0 +PD6 +Text Label 5800 2250 0 60 ~ 0 +PD7 +$Comp +L CONN_4 P2 +U 1 1 52FB0A49 +P 4350 1000 +F 0 "P2" V 4300 1000 50 0000 C CNN +F 1 "CONN_4" V 4400 1000 50 0000 C CNN +F 2 "" H 4350 1000 60 0000 C CNN +F 3 "" H 4350 1000 60 0000 C CNN + 1 4350 1000 + 1 0 0 -1 +$EndComp +$Comp +L CONN_14 P1 +U 1 1 52FB0A6A +P 1250 1500 +F 0 "P1" V 1220 1500 60 0000 C CNN +F 1 "CONN_14" V 1330 1500 60 0000 C CNN +F 2 "" H 1250 1500 60 0000 C CNN +F 3 "" H 1250 1500 60 0000 C CNN + 1 1250 1500 + -1 0 0 -1 +$EndComp +$Comp +L CONN_14 P3 +U 1 1 52FB0A79 +P 7100 1500 +F 0 "P3" V 7070 1500 60 0000 C CNN +F 1 "CONN_14" V 7180 1500 60 0000 C CNN +F 2 "" H 7100 1500 60 0000 C CNN +F 3 "" H 7100 1500 60 0000 C CNN + 1 7100 1500 + 1 0 0 -1 +$EndComp +Text Label 1600 1150 0 60 ~ 0 +OSC1IN +Text Label 1600 1250 0 60 ~ 0 +OSC2IN +Text Label 1600 1350 0 60 ~ 0 +PF4 +Text Label 1600 1450 0 60 ~ 0 +PB5 +Text Label 1600 1550 0 60 ~ 0 +PB4 +Text Label 1600 1650 0 60 ~ 0 +PB3 +Text Label 1600 1750 0 60 ~ 0 +PB2 +Text Label 1600 1850 0 60 ~ 0 +PB1 +Text Label 1600 1950 0 60 ~ 0 +PB0 +Text Label 1600 2050 0 60 ~ 0 +PE5 +Text Label 1600 2150 0 60 ~ 0 +PC1 +Text Label 1600 1050 0 60 ~ 0 +NRST +Text Label 4000 950 2 60 ~ 0 +SWIM/PD1 +Text Label 4000 1050 2 60 ~ 0 +NRST +Text Label 6750 850 2 60 ~ 0 +PD7 +Text Label 6750 950 2 60 ~ 0 +PD6 +Text Label 6750 1050 2 60 ~ 0 +PD5 +Text Label 6750 1150 2 60 ~ 0 +PD4 +Text Label 6750 1250 2 60 ~ 0 +PD3 +Text Label 6750 1350 2 60 ~ 0 +PD2 +Text Label 6750 1450 2 60 ~ 0 +SWIM/PD1 +Text Label 6750 1550 2 60 ~ 0 +PD0 +Text Label 6750 1650 2 60 ~ 0 +PC7 +Text Label 6750 1750 2 60 ~ 0 +PC6 +Text Label 6750 1850 2 60 ~ 0 +PC5 +Text Label 6750 1950 2 60 ~ 0 +PC4 +Text Label 6750 2050 2 60 ~ 0 +PC3 +Text Label 6750 2150 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR04 +U 1 1 52FB0DC4 +P 950 2800 +F 0 "#PWR04" H 950 2760 30 0001 C CNN +F 1 "+3.3V" H 950 2910 30 0000 C CNN +F 2 "" H 950 2800 60 0000 C CNN +F 3 "" H 950 2800 60 0000 C CNN + 1 950 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D1 +U 1 1 52FB0DD3 +P 950 3100 +F 0 "D1" H 950 3200 50 0000 C CNN +F 1 "LED" H 950 3000 50 0000 C CNN +F 2 "" H 950 3100 60 0000 C CNN +F 3 "" H 950 3100 60 0000 C CNN + 1 950 3100 + 0 1 1 0 +$EndComp +$Comp +L R R1 +U 1 1 52FB0DE2 +P 950 3600 +F 0 "R1" V 1030 3600 50 0000 C CNN +F 1 "1k" V 950 3600 50 0000 C CNN +F 2 "" H 950 3600 60 0000 C CNN +F 3 "" H 950 3600 60 0000 C CNN + 1 950 3600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 950 2800 950 2900 +Wire Wire Line + 950 3300 950 3350 +Wire Wire Line + 950 3850 950 3950 +$Comp +L +3.3V #PWR05 +U 1 1 52FB0EC7 +P 1300 2800 +F 0 "#PWR05" H 1300 2760 30 0001 C CNN +F 1 "+3.3V" H 1300 2910 30 0000 C CNN +F 2 "" H 1300 2800 60 0000 C CNN +F 3 "" H 1300 2800 60 0000 C CNN + 1 1300 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D2 +U 1 1 52FB0ECD +P 1300 3100 +F 0 "D2" H 1300 3200 50 0000 C CNN +F 1 "LED" H 1300 3000 50 0000 C CNN +F 2 "" H 1300 3100 60 0000 C CNN +F 3 "" H 1300 3100 60 0000 C CNN + 1 1300 3100 + 0 1 1 0 +$EndComp +$Comp +L R R2 +U 1 1 52FB0ED3 +P 1300 3600 +F 0 "R2" V 1380 3600 50 0000 C CNN +F 1 "1k" V 1300 3600 50 0000 C CNN +F 2 "" H 1300 3600 60 0000 C CNN +F 3 "" H 1300 3600 60 0000 C CNN + 1 1300 3600 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR06 +U 1 1 52FB0ED9 +P 1300 3950 +F 0 "#PWR06" H 1300 3950 30 0001 C CNN +F 1 "GND" H 1300 3880 30 0001 C CNN +F 2 "" H 1300 3950 60 0000 C CNN +F 3 "" H 1300 3950 60 0000 C CNN + 1 1300 3950 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1300 2800 1300 2900 +Wire Wire Line + 1300 3300 1300 3350 +Wire Wire Line + 1300 3850 1300 3950 +Text Label 950 3950 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR07 +U 1 1 52FB0EF1 +P 6500 2550 +F 0 "#PWR07" H 6500 2510 30 0001 C CNN +F 1 "+3.3V" H 6500 2660 30 0000 C CNN +F 2 "" H 6500 2550 60 0000 C CNN +F 3 "" H 6500 2550 60 0000 C CNN + 1 6500 2550 + 1 0 0 -1 +$EndComp +$Comp +L R R3 +U 1 1 52FB0EFD +P 6500 2900 +F 0 "R3" V 6580 2900 50 0000 C CNN +F 1 "10k" V 6500 2900 50 0000 C CNN +F 2 "" H 6500 2900 60 0000 C CNN +F 3 "" H 6500 2900 60 0000 C CNN + 1 6500 2900 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR08 +U 1 1 52FB0F03 +P 6500 4050 +F 0 "#PWR08" H 6500 4050 30 0001 C CNN +F 1 "GND" H 6500 3980 30 0001 C CNN +F 2 "" H 6500 4050 60 0000 C CNN +F 3 "" H 6500 4050 60 0000 C CNN + 1 6500 4050 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6500 2550 6500 2650 +Wire Wire Line + 6500 3850 6500 4050 +$Comp +L SW_PUSH SW1 +U 1 1 52FB0F3B +P 6500 3550 +F 0 "SW1" H 6650 3660 50 0000 C CNN +F 1 "SW_PUSH" H 6500 3470 50 0000 C CNN +F 2 "" H 6500 3550 60 0000 C CNN +F 3 "" H 6500 3550 60 0000 C CNN + 1 6500 3550 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 6500 3250 6500 3150 +$Comp +L C C3 +U 1 1 52FB0F99 +P 6900 3550 +F 0 "C3" H 6950 3650 50 0000 L CNN +F 1 "104" H 6950 3450 50 0000 L CNN +F 2 "" H 6900 3550 60 0000 C CNN +F 3 "" H 6900 3550 60 0000 C CNN + 1 6900 3550 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6900 3200 6900 3350 +Wire Wire Line + 6900 3750 6900 3900 +Wire Wire Line + 6900 3900 6500 3900 +Connection ~ 6500 3900 +Wire Wire Line + 6500 3200 6900 3200 +Connection ~ 6500 3200 +Text Label 6500 3200 2 60 ~ 0 +NRST +$Comp +L +3.3V #PWR09 +U 1 1 52FB2273 +P 2150 850 +F 0 "#PWR09" H 2150 810 30 0001 C CNN +F 1 "+3.3V" H 2150 960 30 0000 C CNN +F 2 "" H 2150 850 60 0000 C CNN +F 3 "" H 2150 850 60 0000 C CNN + 1 2150 850 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 850 2150 850 +$Comp +L GND #PWR010 +U 1 1 52FB2296 +P 2150 1000 +F 0 "#PWR010" H 2150 1000 30 0001 C CNN +F 1 "GND" H 2150 930 30 0001 C CNN +F 2 "" H 2150 1000 60 0000 C CNN +F 3 "" H 2150 1000 60 0000 C CNN + 1 2150 1000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 950 2150 950 +Wire Wire Line + 2150 950 2150 1000 +Wire Wire Line + 2600 3050 3000 3050 +Wire Wire Line + 2750 3050 2750 2850 +Connection ~ 2750 2850 +$Comp +L +3.3V #PWR011 +U 1 1 52FB26FA +P 2600 3000 +F 0 "#PWR011" H 2600 2960 30 0001 C CNN +F 1 "+3.3V" H 2600 3110 30 0000 C CNN +F 2 "" H 2600 3000 60 0000 C CNN +F 3 "" H 2600 3000 60 0000 C CNN + 1 2600 3000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2600 3000 2600 3050 +Connection ~ 2750 3050 +$Comp +L +3.3V #PWR012 +U 1 1 52FB286D +P 4000 750 +F 0 "#PWR012" H 4000 710 30 0001 C CNN +F 1 "+3.3V" H 4000 860 30 0000 C CNN +F 2 "" H 4000 750 60 0000 C CNN +F 3 "" H 4000 750 60 0000 C CNN + 1 4000 750 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR013 +U 1 1 52FB287C +P 4000 1300 +F 0 "#PWR013" H 4000 1300 30 0001 C CNN +F 1 "GND" H 4000 1230 30 0001 C CNN +F 2 "" H 4000 1300 60 0000 C CNN +F 3 "" H 4000 1300 60 0000 C CNN + 1 4000 1300 + 1 0 0 -1 +$EndComp +Wire Wire Line + 4000 1300 4000 1150 +Wire Wire Line + 4000 850 4000 750 +$EndSCHEMATC diff --git a/stepper/stepper.c b/stepper/stepper.c new file mode 100644 index 0000000..70291d3 --- /dev/null +++ b/stepper/stepper.c @@ -0,0 +1,126 @@ +/* + * stepper.c + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "ports_definition.h" +#include "stepper.h" + +U8 Ustepping = 4; // 2^Ustepping = N of microsteps +volatile long Nsteps = 0; // Number of steps +U8 Motor_number = 5; // Number of motor to move, 5 -- not moving +U16 Stepper_speed = 0; // length of one MICROstep in us + +/** + * Setup pins of stepper motor (all - PP out) + */ +void setup_stepper_pins(){ + // CLK + PORT(STP_CLK_PORT, DDR) |= STP_CLK_PIN; + PORT(STP_CLK_PORT, CR1) |= STP_CLK_PIN; + // EN + PORT(STP_EN_PORT, DDR) |= STP_EN_MASK; + PORT(STP_EN_PORT, CR1) |= STP_EN_MASK; + // DIR + PORT(STP_DIR_PORT, DDR) |= STP_DIR_PIN; + PORT(STP_DIR_PORT, CR1) |= STP_DIR_PIN; +} + +/** + * Set speed of stepper motor + * @param Sps - period (in us) of one MICROstep + */ +void set_stepper_speed(U16 SpS){ + Stepper_speed = SpS; + // Configure timer 2 to generate signals for CLK + TIM2_PSCR = 4; // 1MHz + //SpS >>= Ustepping; // divide to microsteps + TIM2_ARRH = SpS >> 8; // set speed + TIM2_ARRL = SpS & 0xff; + SpS >>= 1;// divide to 2 - 50% duty cycle + TIM2_CCR1H = SpS >> 8; + TIM2_CCR1L = SpS & 0xff; + // channel 1 generates PWM pulses + TIM2_CCMR1 = 0x60; // OC1M = 110b - PWM mode 1 ( 1 -> 0) + TIM2_CCER1 = 1; // Channel 1 is on. Active is high + //TIM2_IER = TIM_IER_UIE | TIM_IER_CC1IE; // update interrupt enable + TIM2_IER = TIM_IER_UIE; // update interrupt enable + TIM2_CR1 |= TIM_CR1_APRE | TIM_CR1_URS; // auto reload + interrupt on overflow & RUN +} + +void move_motor(int Steps){ + if(Motor_number > 4) return; + if(Steps < 0){ + PORT(STP_DIR_PORT, ODR) &= ~STP_DIR_PIN; // dir to left + Steps *= -1; + } + Nsteps = (long)Steps << Ustepping; + PORT(STP_EN_PORT, ODR) |= 1 << Motor_number; // enable moving + TIM2_CR1 |= TIM_CR1_CEN; // turn on timer +} + +void stop_motor(){ + TIM2_CR1 &= ~TIM_CR1_CEN; // Turn off timer + PORT(STP_EN_PORT, ODR) &= ~STP_EN_MASK; // disable moving + PORT(STP_DIR_PORT, ODR) |= STP_DIR_PIN; // turn off DIR + Nsteps = 0; + Motor_number = 5; // All OK. Motors are stopped + uart_write("stop\n"); +} + +void pause_resume(){ + if(Nsteps == 0) return; // motor is stopped + if(TIM2_CR1 & TIM_CR1_CEN){ // pause + TIM2_CR1 &= ~TIM_CR1_CEN; + uart_write("pause\n"); + }else{ // resume + TIM2_CR1 |= TIM_CR1_CEN; + uart_write("resume\n"); + } +} + +void add_steps(int Steps){ + long S; + U8 sign = 0; + // pause + TIM2_CR1 &= ~TIM_CR1_CEN; + if(Motor_number == 5){ // motors are stopped - just move last active motor + move_motor(Steps); + return; + } +// if(PORT(STP_DIR_PORT, IDR) & STP_DIR_PIN) // left direction +// Nsteps *= -1L; + if(Steps < 0){ + sign = 1; + Steps *= -1; + } + S = (long)Steps << Ustepping; + if(sign) + S *= -1L; + Nsteps += S; + // now change direction + if(Nsteps < 0){ + uart_write("reverce\n"); + PORT(STP_DIR_PORT, ODR) ^= STP_DIR_PIN; // go to the opposite side + Nsteps *= -1L; + } + // resume if Nsteps != 0 + if(Nsteps) + TIM2_CR1 |= TIM_CR1_CEN; +} diff --git a/stepper/stepper.h b/stepper/stepper.h new file mode 100644 index 0000000..1763601 --- /dev/null +++ b/stepper/stepper.h @@ -0,0 +1,41 @@ +/* + * stepper.h + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __STEPPER_H__ +#define __STEPPER_H__ + +#include "ports_definition.h" +#include "main.h" + +extern U8 Ustepping; +extern volatile long Nsteps; +extern U8 Motor_number; +extern U16 Stepper_speed; + +void setup_stepper_pins(); +void set_stepper_speed(U16 SpS); +void move_motor(int Steps); +void stop_motor(); +void pause_resume(); +void add_steps(int Steps); + +#endif // __STEPPER_H__ diff --git a/stepper/testproj.bin b/stepper/testproj.bin new file mode 100644 index 0000000000000000000000000000000000000000..da455169b2448b2a035ff252cd30c3e0fc064caf GIT binary patch literal 2958 zcmZuzU2NOd6~6qFNQ$y7Y9cMmxmRv%5ozk5t__MLDDqdMX&p}*on?*XLUC)M4LC1` z>;%DxCYIu4^7cY(kOl0)uANj!Jb>8ap0;HVE)du;umRonFeFc2v6ppTD$WZU?_A1F zvLD0e@ZGMc$oMhKNr`3s=G18o8Q1LzUZmp~05uW94k{S)4|%jjAPs1xWN zptC?D&up&c;C&S6U7%k9{Tk>u&-64-lh$s?E)tDkF@w-ZdfP>b&PHL^yXi>^Y0o zOl`p(Ztbb*0{Ty(y&H!h8jv6bo?lAIle5taET9)`1&S3r~ zLcI|;D>QCB0PbNvOL&dXJMX^8jI1JQ$Ot&^oP9g}FDOCTKr*$g))|X|07Hf#GH<6J zFSIk%6+$;wpbX^AmMFgUgknGRLthWBE6|hR74s+zqyUA0N&|)2^tGLarqELdZts*(WRCm_| z6c8B{%fRGi)cc}a{!6nc+Wl?6XX@@`GrvWl8Zh}e-?TuRm1*hCmU2>QYWl*Yj3&n} zP8DQSEKFUT@Sm3o#rFZseEsK|-)X$jm4w)_;vEEgqTWGJTl5a1@nah(3Km!401mSa zSj1ksh^*&#vP{jPV%o~GZ%((DuDuB5q`CFdPnuaw-ZhUlEZ*inNf}w!Jl25q;BUHGcEk0&JzKZm_s4cC+6T~_^mc%p<`wg&d7q;binuTUK z*|kmMab8K|oW_umd@3Ahtcb2T;5iLv6imF-!;(o8-bH$v%cKlVpd~;%I+Wn&q9rg5 zhnDbl&N>4}%k0P#*kQYKiQmhuU8jIcQxNX-AM+hZAjwR=R(zbidTL4O{t_oUkX)BN zuw;xD;H=R>-HpyvKPC+;o{y-6wd1fps>P%_G~ztT(^Hg+VzS9uiB0y2MN=j$zAjnO zK{-D+h;VQY{?{vC<;2AbI3{Q1X#SYpehl*dyx;o|qq!gCM8fF|=F&W7jDQ_o+Ii`h zcJ!2AW%HQjI!b0c90C%!kD`Rn6NSi;mIxbRpd$`!wsPzc?eMnEE%l^Zu#%RsoDRUZ z(2_b2vi>em-UD!uuFE};v+(7>f3uYJA0?oOgs$6MB%XI_cHF5Jw-bwrw%S5MuNIe4 z|Kc*TS{Ig)u2{0&YK7dZJ254rhBB($6>Jv7_~&#h0LN4ns&GtIzUJICs26zC3X)+a z&4*dKtL?T@v0E&8))K=lhJeK^5%C^P+<}d3FS(U-&CW6H4yMMSyngNOY{^veBtUpK zyL#0%&jF3qBc5x%SLcAgU;iBVX*vtdZ2dZnCZ(|gwhExIkHUapRKo|mJE{S}s5Xz+ z;oUq@4*(yizvTUF@bf`#edfuQ-HRLR)OpfV} zf?cfHyKmCeN)m@VY=^w!gOkAYO+ummnS6pGBsV8oRTj~{y3kM{CVEDJI?!i zdta3%E?g?4E>C}$nz%51p(u|@W8>qgZ%s{u7kY1OJmm-T(WSBPT`VB5KmYv?I(-S4 zL3CvD^gFjhCo^virF*q74#9=3he-%av9K+wiXBu#U16#??VO>Cl&COpxY*P^o3;4o z&AMZnRNV5tYSgW&OCzw0X7N=F~*@ zeoZKD`LC8j1-f8ywgU6EZH0kJq&rnxgMn0~8D%!i8r<64b*yXgoLVxEI`hsb%)k?{ z9HC7P(3>QV<3z_gIf9Q=HksP&ac2iEPnPOI6U9*y!!eS;iOMGDYv)Hv5+@th9vo`a zw79d$9bZiD!AXw_G59gQlm#gUDNXs)CxlQ11nk6}WG~)Jx^Z_iVDT|=cEG>@0~QSS z;eBL3-cR~)UuBbpjK#->v!l_1srqI7GI<5RLJr^q&2kqV4~Is{YgF&laD0<T_$cY2D&Lj`+nyZ^Up;pfhbW&Pg= literal 0 HcmV?d00001 diff --git a/stepper_independent/Makefile b/stepper_independent/Makefile new file mode 100644 index 0000000..b739ed5 --- /dev/null +++ b/stepper_independent/Makefile @@ -0,0 +1,39 @@ +NAME=testproj +SDCC=sdcc +HEX2BIN=hex2bin + +CCFLAGS=-DSTM8S105 -I../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx +LDFLAGS= -mstm8 --out-fmt-ihx -lstm8 +FLASHFLAGS=-cstlinkv2 -pstm8s105 + +SRC=$(wildcard *.c) +# ATTENTION: FIRST in list should be file with main() +OBJ=$(SRC:%.c=%.rel) +TRASH=$(OBJ) $(SRC:%.c=%.rst) $(SRC:%.c=%.asm) $(SRC:%.c=%.lst) +TRASH+=$(SRC:%.c=%.sym) $(NAME).ihx $(NAME).lk $(NAME).map +INDEPENDENT_HEADERS=../stm8l.h Makefile + +all: $(NAME).bin + +$(SRC) : %.c : %.h $(INDEPENDENT_HEADERS) + @touch $@ + @echo $@ + +%.h: ; + +clean: + rm -f $(TRASH) + +load: $(NAME).bin + stm8flash $(FLASHFLAGS) -wf $(NAME).bin + +%.rel: %.c + $(SDCC) $(CCFLAGS) -c $< + +$(NAME).ihx: $(OBJ) + $(SDCC) $(LDFLAGS) $(OBJ) -o $(NAME).ihx + +$(NAME).bin: $(NAME).ihx + $(HEX2BIN) -p 00 $< + +.PHONY: all diff --git a/stepper_independent/README b/stepper_independent/README new file mode 100644 index 0000000..cdc9dd0 --- /dev/null +++ b/stepper_independent/README @@ -0,0 +1,13 @@ +This is a simple example of INDEPENDENT management of 3 stepper motors. +All motors have independent lines DIR and CLK and common line EN. +Communication with MCU realized through simple USB<->TTL converter. +Just connect lines Rx/Tx of converter to Tx/Rx of evaluation boart, +connect together lines GND and +3.3V. +Communication speed: 57600, proto: 8N1 +Comminication with MCU don't need special soft: you can even run screen session +or some terminal client like _com_. Another wariant is a simple client - client-term. +MCU itself can print to terminal a short help about its protocol, just sent letter 'h' +to it. + +!!! ALL "steps" suppose to be single pulses, you should convert them into real !!! +!!! steps (dividing by microstepping) in your own soft !!! diff --git a/stepper_independent/client-term/Makefile b/stepper_independent/client-term/Makefile new file mode 100644 index 0000000..19bac1f --- /dev/null +++ b/stepper_independent/client-term/Makefile @@ -0,0 +1,22 @@ +PROGRAM = client +LDFLAGS = +SRCS = client.c +CC = gcc +DEFINES = -D_XOPEN_SOURCE=501 +CXX = gcc +CFLAGS = -Wall -Werror $(DEFINES) +OBJS = $(SRCS:.c=.o) +all : $(PROGRAM) clean +$(PROGRAM) : $(OBJS) + $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(PROGRAM) + +# some addition dependencies +# %.o: %.c +# $(CC) $(LDFLAGS) $(CFLAGS) $< -o $@ +#$(SRCS) : %.c : %.h $(INDEPENDENT_HEADERS) +# @touch $@ + +clean: + /bin/rm -f *.o *~ +depend: + $(CXX) -MM $(CXX.SRCS) diff --git a/stepper_independent/client-term/client.c b/stepper_independent/client-term/client.c new file mode 100644 index 0000000..453ad22 --- /dev/null +++ b/stepper_independent/client-term/client.c @@ -0,0 +1,222 @@ +/* + * client.c - simple terminal client + * + * Copyright 2013 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include // tcsetattr +#include // tcsetattr, close, read, write +#include // ioctl +#include // printf, getchar, fopen, perror +#include // exit +#include // read +#include // read +#include // signal +#include // time +#include // memcpy +#include // int types +#include // gettimeofday + +double t0; // start time + +FILE *fout = NULL; // file for messages duplicating +char *comdev = "/dev/ttyUSB0"; +int BAUD_RATE = B57600; +struct termio oldtty, tty; // TTY flags +struct termios oldt, newt; // terminal flags +int comfd; // TTY fd + +/** + * function for different purposes that need to know time intervals + * @return double value: time in seconds + */ +double dtime(){ + double t; + struct timeval tv; + gettimeofday(&tv, NULL); + t = tv.tv_sec + ((double)tv.tv_usec)/1e6; + return t; +} + +/** + * Exit & return terminal to old state + * @param ex_stat - status (return code) + */ +void quit(int ex_stat){ + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // return terminal to previous state + ioctl(comfd, TCSANOW, &oldtty ); // return TTY to previous state + close(comfd); + if(fout) fclose(fout); + printf("Exit! (%d)\n", ex_stat); + exit(ex_stat); +} + +/** + * Open & setup TTY, terminal + */ +void tty_init(){ + // terminal without echo + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + if(tcsetattr(STDIN_FILENO, TCSANOW, &newt) < 0) quit(-2); + printf("\nOpen port...\n"); + if ((comfd = open(comdev,O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0){ + fprintf(stderr,"Can't use port %s\n",comdev); + quit(1); + } + printf(" OK\nGet current settings...\n"); + if(ioctl(comfd,TCGETA,&oldtty) < 0) exit(-1); // Get settings + tty = oldtty; + tty.c_lflag = 0; // ~(ICANON | ECHO | ECHOE | ISIG) + tty.c_oflag = 0; + tty.c_cflag = BAUD_RATE|CS8|CREAD|CLOCAL; // 9.6k, 8N1, RW, ignore line ctrl + tty.c_cc[VMIN] = 0; // non-canonical mode + tty.c_cc[VTIME] = 5; + if(ioctl(comfd,TCSETA,&tty) < 0) exit(-1); // set new mode + printf(" OK\n"); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); +} + +/** + * Read character from console without echo + * @return char readed + */ +int read_console(){ + int rb; + struct timeval tv; + int retval; + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(STDIN_FILENO, &rfds); + tv.tv_sec = 0; tv.tv_usec = 10000; + retval = select(1, &rfds, NULL, NULL, &tv); + if(!retval) rb = 0; + else { + if(FD_ISSET(STDIN_FILENO, &rfds)) rb = getchar(); + else rb = 0; + } + return rb; +} + +/** + * getchar() without echo + * wait until at least one character pressed + * @return character readed + */ +int mygetchar(){ // аналог getchar() без необходимости жать Enter + int ret; + do ret = read_console(); + while(ret == 0); + return ret; +} + +/** + * Read data from TTY + * @param buff (o) - buffer for data read + * @param length - buffer len + * @return amount of readed bytes + */ +size_t read_tty(uint8_t *buff, size_t length){ + ssize_t L = 0; + fd_set rfds; + struct timeval tv; + int retval; + FD_ZERO(&rfds); + FD_SET(comfd, &rfds); + tv.tv_sec = 0; tv.tv_usec = 10000; // wait for 10ms + retval = select(comfd + 1, &rfds, NULL, NULL, &tv); + if (!retval) return 0; + if(FD_ISSET(comfd, &rfds)){ + if((L = read(comfd, buff, length)) < 1) return 0; + } + return (size_t)L; +} + +void help(){ + printf("Use this commands:\n" + "h\tShow this help\n" + "q\tQuit\n" + ); +} + +#define dup_pr(...) do{printf(__VA_ARGS__); if(fout) fprintf(fout, __VA_ARGS__);}while(0) + +void con_sig(int rb){ + uint8_t cmd; + if(rb < 1) return; + if(rb == 'q') quit(0); // q == exit + cmd = (uint8_t) rb; + write(comfd, &cmd, 1); + /*switch(rb){ + case 'h': + help(); + break; + default: + cmd = (uint8_t) rb; + write(comfd, &cmd, 1); + }*/ +} + +/** + * Get integer value from buffer + * @param buff (i) - buffer with int + * @param len - length of data in buffer (could be 2 or 4) + * @return + */ +uint32_t get_int(uint8_t *buff, size_t len){ + if(len != 2 && len != 4){ + fprintf(stdout, "Bad data length!\n"); + return 0xffffffff; + } + uint32_t data = 0; + uint8_t *i8 = (uint8_t*) &data; + if(len == 2) memcpy(i8, buff, 2); + else memcpy(i8, buff, 4); + return data; +} + +int main(int argc, char *argv[]){ + int rb; + uint8_t buff[128]; + size_t L; + if(argc == 2){ + fout = fopen(argv[1], "a"); + if(!fout){ + perror("Can't open output file"); + exit(-1); + } + setbuf(fout, NULL); + } + tty_init(); + signal(SIGTERM, quit); // kill (-15) + signal(SIGINT, quit); // ctrl+C + signal(SIGQUIT, SIG_IGN); // ctrl+\ . + signal(SIGTSTP, SIG_IGN); // ctrl+Z + setbuf(stdout, NULL); + t0 = dtime(); + while(1){ + rb = read_console(); + if(rb > 0) con_sig(rb); + L = read_tty(buff, 127); + if(L){ + buff[L] = 0; + printf("%s", buff); + if(fout) fprintf(fout, "%zd\t%s\n", time(NULL), buff); + } + } +} diff --git a/stepper_independent/interrupts.c b/stepper_independent/interrupts.c new file mode 100644 index 0000000..b2fb41d --- /dev/null +++ b/stepper_independent/interrupts.c @@ -0,0 +1,181 @@ +/* + * interrupts.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "ports_definition.h" +#include "main.h" +#include "stepper.h" + +#define TREG(N, R) TIM##N##_##R + +#define STPR_INTR(X) \ + if(TREG(X, SR1) & TIM_SR1_UIF){ \ + TREG(X, SR1) &= ~TIM_SR1_UIF; \ + if(Nsteps[X-1]){ \ + if(--Nsteps[X-1] == 0){ \ + stop_motor(X-1); \ + } \ + } \ + } + + +// Top Level Interrupt +INTERRUPT_HANDLER(TLI_IRQHandler, 0){} + +// Auto Wake Up Interrupt +INTERRUPT_HANDLER(AWU_IRQHandler, 1){} + +// Clock Controller Interrupt +INTERRUPT_HANDLER(CLK_IRQHandler, 2){} + +// External Interrupt PORTA +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3){} + +// External Interrupt PORTB +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4){} + +// External Interrupt PORTC +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5){} + +// External Interrupt PORTD +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6){ +} + +// External Interrupt PORTE +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7){} + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8){} +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8){} + +// CAN TX Interrupt routine. +INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9){} +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_HANDLER(SPI_IRQHandler, 10){} + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11){ + STPR_INTR(1); +} + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12){} + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13){} + +// Timer5 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14){} + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13){ // generate pulses for stepper CLK + STPR_INTR(2); +} + +// Timer2 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14){ +} +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15){ + STPR_INTR(3); +} + +// Timer3 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16){} +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17){} + +// UART1 RX Interrupt +INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18){} +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_HANDLER(I2C_IRQHandler, 19){} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){} + +// UART2 RX interrupt +INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21){ + U8 rb; + if(UART2_SR & UART_SR_RXNE){ // data received + rb = UART2_DR; // read received byte & clear RXNE flag + while(!(UART2_SR & UART_SR_TXE)); + UART2_DR = rb; // echo received symbol + UART_rx[UART_rx_cur_i++] = rb; // put received byte into cycled buffer + if(UART_rx_cur_i == UART_rx_start_i){ // Oops: buffer overflow! Just forget old data + UART_rx_start_i++; + check_UART_pointer(UART_rx_start_i); + } + check_UART_pointer(UART_rx_cur_i); + } +} +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20){} + +// UART3 RX interrupt +INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21){} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_HANDLER(ADC2_IRQHandler, 22){} +#else +// ADC1 interrupt +INTERRUPT_HANDLER(ADC1_IRQHandler, 22){ +} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23){} +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23){ + if(TIM4_SR & TIM_SR1_UIF){ // update interrupt + Global_time++; // increase timer + } + TIM4_SR = 0; // clear all interrupt flags +} +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24){} diff --git a/stepper_independent/interrupts.h b/stepper_independent/interrupts.h new file mode 100644 index 0000000..6edf384 --- /dev/null +++ b/stepper_independent/interrupts.h @@ -0,0 +1,144 @@ +/* + * interrupts.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __INTERRUPTS_H__ +#define __INTERRUPTS_H__ + +#include "stm8l.h" + +// Top Level Interrupt +INTERRUPT_DEFINITION(TLI_IRQHandler, 0); + +// Auto Wake Up Interrupt +INTERRUPT_DEFINITION(AWU_IRQHandler, 1); + +// Clock Controller Interrupt +INTERRUPT_DEFINITION(CLK_IRQHandler, 2); + +// External Interrupt PORTA +INTERRUPT_DEFINITION(EXTI_PORTA_IRQHandler, 3); + +// External Interrupt PORTB +INTERRUPT_DEFINITION(EXTI_PORTB_IRQHandler, 4); + +// External Interrupt PORTC +INTERRUPT_DEFINITION(EXTI_PORTC_IRQHandler, 5); + +// External Interrupt PORTD +INTERRUPT_DEFINITION(EXTI_PORTD_IRQHandler, 6); + +// External Interrupt PORTE +INTERRUPT_DEFINITION(EXTI_PORTE_IRQHandler, 7); + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_DEFINITION(EXTI_PORTF_IRQHandler, 8); +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_DEFINITION(CAN_RX_IRQHandler, 8); + +// CAN TX Interrupt routine. +INTERRUPT_DEFINITION(CAN_TX_IRQHandler, 9); +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_DEFINITION(SPI_IRQHandler, 10); + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_DEFINITION(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_DEFINITION(TIM1_CAP_COM_IRQHandler, 12); + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_DEFINITION(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); + +// Timer5 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM5_CAP_COM_IRQHandler, 14); + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM2_UPD_OVF_BRK_IRQHandler, 13); + +// Timer2 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM2_CAP_COM_IRQHandler, 14); +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM3_UPD_OVF_BRK_IRQHandler, 15); + +// Timer3 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM3_CAP_COM_IRQHandler, 16); +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_DEFINITION(UART1_TX_IRQHandler, 17); + +// UART1 RX Interrupt +INTERRUPT_DEFINITION(UART1_RX_IRQHandler, 18); +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_DEFINITION(I2C_IRQHandler, 19); + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_DEFINITION(UART2_TX_IRQHandler, 20); + +// UART2 RX interrupt +INTERRUPT_DEFINITION(UART2_RX_IRQHandler, 21); +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_DEFINITION(UART3_TX_IRQHandler, 20); + +// UART3 RX interrupt +INTERRUPT_DEFINITION(UART3_RX_IRQHandler, 21); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_DEFINITION(ADC2_IRQHandler, 22); +#else // STM8S105, STM8S103 or STM8S903 or STM8AF626x +// ADC1 interrupt +INTERRUPT_DEFINITION(ADC1_IRQHandler, 22); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_DEFINITION(TIM6_UPD_OVF_TRG_IRQHandler, 23); +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_DEFINITION(TIM4_UPD_OVF_IRQHandler, 23); +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_DEFINITION(EEPROM_EEC_IRQHandler, 24); + +#endif // __INTERRUPTS_H__ diff --git a/stepper_independent/main.c b/stepper_independent/main.c new file mode 100644 index 0000000..3a93bc3 --- /dev/null +++ b/stepper_independent/main.c @@ -0,0 +1,260 @@ +/* + * blinky.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#include "ports_definition.h" +#include "interrupts.h" +#include "main.h" +#include "stepper.h" + +/* + * 0 0000 + * 1 0001 + * 2 0010 + * 3 0011 + * 4 0100 + * 5 0101 + * 6 0110 + * 7 0111 + * 8 1000 + * 9 1001 + * a 1010 + * b 1011 + * c 1100 + * d 1101 + * e 1110 + * f 1111 + */ + +unsigned long Global_time = 0L; // global time in ms +U16 paused_val = 500; // interval between LED flashing + +U8 UART_rx[UART_BUF_LEN]; // cycle buffer for received data +U8 UART_rx_start_i = 0; // started index of received data (from which reading starts) +U8 UART_rx_cur_i = 0; // index of current first byte in rx array (to which data will be written) + +/** + * Send one byte through UART + * @param byte - data to send + */ +void UART_send_byte(U8 byte){ + while(!(UART2_SR & UART_SR_TXE)); // wait until previous byte transmitted + UART2_DR = byte; +} + +void uart_write(char *str){ + while(*str){ + while(!(UART2_SR & UART_SR_TXE)); + //UART2_CR2 |= UART_CR2_TEN; + UART2_DR = *str++; + } +} + + +/** + * Read one byte from Rx buffer + * @param byte - where to store readed data + * @return 1 in case of non-empty buffer + */ +U8 UART_read_byte(U8 *byte){ + if(UART_rx_start_i == UART_rx_cur_i) // buffer is empty + return 0; + *byte = UART_rx[UART_rx_start_i++]; + check_UART_pointer(UART_rx_start_i); + return 1; +} + +void printUint(U8 *val, U8 len){ + unsigned long Number = 0; + U8 i = len; + char ch; + U8 decimal_buff[12]; // max len of U32 == 10 + \n + \0 + if(len > 4 || len == 3 || len == 0) return; + for(i = 0; i < 12; i++) + decimal_buff[i] = 0; + decimal_buff[10] = '\n'; + ch = 9; + switch(len){ + case 1: + Number = *((U8*)val); + break; + case 2: + Number = *((U16*)val); + break; + case 4: + Number = *((unsigned long*)val); + break; + } + do{ + i = Number % 10L; + decimal_buff[ch--] = i + '0'; + Number /= 10L; + }while(Number && ch > -1); + uart_write((char*)&decimal_buff[ch+1]); +} + +U8 readInt(int *val){ + unsigned long T = Global_time; + unsigned long R = 0; + int readed; + U8 sign = 0, rb, ret = 0, bad = 0; + do{ + if(!UART_read_byte(&rb)) continue; + if(rb == '-' && R == 0){ // negative number + sign = 1; + continue; + } + if(rb < '0' || rb > '9') break; // number ends with any non-digit symbol that will be omitted + ret = 1; // there's at least one digit + R = R * 10L + rb - '0'; + if(R > 0x7fff){ // bad value + R = 0; + bad = 0; + } + }while(Global_time - T < 10000); // wait no longer than 10s + if(bad || !ret) return 0; + readed = (int) R; + if(sign) readed *= -1; + *val = readed; + return 1; +} + +void error_msg(char *msg){ + uart_write("\nERROR: "); + uart_write(msg); + UART_send_byte('\n'); +} + +/** + * read motor number + * @param N - readed Number + * @return 0 in case of error + */ +U8 get_motor_number(U8 *N){ + int Ival; + if(readInt(&Ival) && Ival > -1 && Ival < 4){ + *N = (U8) Ival; + UART_send_byte('*'); // OK + return 1; + }else{ + error_msg("bad motor"); + return 0; + } +} + +int main() { + unsigned long T = 0L; + int Ival; + U8 rb, Num; + CFG_GCR |= 1; // disable SWIM + // Configure clocking + CLK_CKDIVR = 0; // F_HSI = 16MHz, f_CPU = 16MHz + + // Timer 4 (8 bit) used as system tick timer + // prescaler == 128 (2^7), Tfreq = 125kHz + // period = 1ms, so ARR = 125 + TIM4_PSCR = 7; + TIM4_ARR = 125; + // interrupts: update + TIM4_IER = TIM_IER_UIE; + // auto-reload + interrupt on overflow + enable + TIM4_CR1 = TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN; + + // Configure pins + // PC2 - PP output (on-board LED) + PORT(LED_PORT, DDR) |= LED_PIN; + PORT(LED_PORT, CR1) |= LED_PIN; + // PD5 - UART2_TX + PORT(UART_PORT, DDR) |= UART_TX_PIN; + PORT(UART_PORT, CR1) |= UART_TX_PIN; + + // Configure UART + // 8 bit, no parity, 1 stop (UART_CR1/3 = 0 - reset value) + // 57600 on 16MHz: BRR1=0x11, BRR2=0x06 + UART2_BRR1 = 0x11; UART2_BRR2 = 0x06; + UART2_CR2 = UART_CR2_TEN | UART_CR2_REN | UART_CR2_RIEN; // Allow RX/TX, generate ints on rx + + // enable all interrupts + enableInterrupts(); + + setup_stepper_pins(); + + // Loop + do{ + if((Global_time - T > paused_val) || (T > Global_time)){ + T = Global_time; + PORT(LED_PORT, ODR) ^= LED_PIN; // blink on-board LED + } + if(UART_read_byte(&rb)){ // buffer isn't empty + switch(rb){ + case 'h': // help + case 'H': + uart_write("\nPROTO:\n+/-\tLED period\nSx/sx\tset/get Mspeed\nmx\tget steps\nXx\tstop\nPx\tpause/resume\n0..3\tmove xth motor\n"); + break; + case '+': + paused_val += 100; + if(paused_val > 10000) + paused_val = 500; // but not more than 10s + break; + case '-': + paused_val -= 100; + if(paused_val < 100) // but not less than 0.1s + paused_val = 500; + break; + case 'S': // set stepper speed + if(get_motor_number(&Num)){ + if(readInt(&Ival) && Ival > MIN_STEP_LENGTH) + set_stepper_speed(Num, Ival); + else + error_msg("bad speed"); + } + break; + case 's': // get stepper speed + if(get_motor_number(&Num)) + printUint((U8*)&Stepper_speed[Num], 2); + break; + case 'm': // how much steps there is to the end of moving + if(get_motor_number(&Num)) + printUint((U8*)&Nsteps[Num], 2); + break; + case 'X': // stop + if(get_motor_number(&Num)) + stop_motor(Num); + break; + case 'P': // pause/resume + if(get_motor_number(&Num)) + pause_resume(Num); + break; + default: + if(rb >= '0' && rb <= '2'){ // run motor + Num = rb - '0'; + if(readInt(&Ival) && Ival) + move_motor(Num, Ival); + else{ + error_msg("bad Nsteps"); + } + } + } + } + }while(1); +} + + diff --git a/stepper_independent/main.h b/stepper_independent/main.h new file mode 100644 index 0000000..77e2f9f --- /dev/null +++ b/stepper_independent/main.h @@ -0,0 +1,41 @@ +/* + * blinky.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __MAIN_H__ +#define __MAIN_H__ + +extern unsigned long Global_time; // global time in ms + +#define UART_BUF_LEN 8 // max 7 bytes transmited in on operation +#define MIN_STEP_LENGTH 125 // max speed == 1/(125us*16) = 500 steps per second + +extern U8 UART_rx[]; +extern U8 UART_rx_start_i; +extern U8 UART_rx_cur_i; + +void UART_send_byte(U8 byte); +void uart_write(char *str); +void printUint(U8 *val, U8 len); +void error_msg(char *msg); + +#define check_UART_pointer(x) if(x == UART_BUF_LEN) x = 0; + +#endif // __MAIN_H__ diff --git a/stepper_independent/ports_definition.h b/stepper_independent/ports_definition.h new file mode 100644 index 0000000..da7f0e1 --- /dev/null +++ b/stepper_independent/ports_definition.h @@ -0,0 +1,55 @@ +/* + * ports_definition.h - definition of ports pins & so on + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __PORTS_DEFINITION_H__ +#define __PORTS_DEFINITION_H__ + +#include "stm8l.h" + +// macro for using in port constructions like PORT(LED_PORT, ODR) = xx +#define CONCAT(a,b) a##_##b +#define PORT(a,b) CONCAT(a,b) + +// on-board LED +#define LED_PORT PC +#define LED_PIN GPIO_PIN2 + +// UART2_TX +#define UART_PORT PD +#define UART_TX_PIN GPIO_PIN5 + +/***** Stepper motor *****/ +// Clocking +#define STP0_CLK_PORT PC +#define STP0_CLK_PIN GPIO_PIN1 +#define STP1_CLK_PORT PD +#define STP1_CLK_PIN GPIO_PIN4 +#define STP2_CLK_PORT PD +#define STP2_CLK_PIN GPIO_PIN2 +// Direction +#define STP0_DIR_PORT PB +#define STP0_DIR_PIN GPIO_PIN0 +#define STP1_DIR_PORT PB +#define STP1_DIR_PIN GPIO_PIN1 +#define STP2_DIR_PORT PB +#define STP2_DIR_PIN GPIO_PIN2 +#endif // __PORTS_DEFINITION_H__ diff --git a/stepper_independent/schematic/kicad.kicad_pcb b/stepper_independent/schematic/kicad.kicad_pcb new file mode 100644 index 0000000..97857c9 --- /dev/null +++ b/stepper_independent/schematic/kicad.kicad_pcb @@ -0,0 +1,961 @@ +(kicad_pcb (version 3) (host pcbnew "(2013-feb-26)-stable") + + (general + (links 70) + (no_connects 70) + (area 0 0 0 0) + (thickness 1.6) + (drawings 0) + (tracks 0) + (zones 0) + (modules 15) + (nets 32) + ) + + (page A3) + (layers + (15 F.Cu signal) + (0 B.Cu signal) + (16 B.Adhes user) + (17 F.Adhes user) + (18 B.Paste user) + (19 F.Paste user) + (20 B.SilkS user) + (21 F.SilkS user) + (22 B.Mask user) + (23 F.Mask user) + (24 Dwgs.User user) + (25 Cmts.User user) + (26 Eco1.User user) + (27 Eco2.User user) + (28 Edge.Cuts user) + ) + + (setup + (last_trace_width 0.254) + (trace_clearance 0.254) + (zone_clearance 0.508) + (zone_45_only no) + (trace_min 0.254) + (segment_width 0.2) + (edge_width 0.15) + (via_size 0.889) + (via_drill 0.635) + (via_min_size 0.889) + (via_min_drill 0.508) + (uvia_size 0.508) + (uvia_drill 0.127) + (uvias_allowed no) + (uvia_min_size 0.508) + (uvia_min_drill 0.127) + (pcb_text_width 0.3) + (pcb_text_size 1 1) + (mod_edge_width 0.15) + (mod_text_size 1 1) + (mod_text_width 0.15) + (pad_size 1 1) + (pad_drill 0.6) + (pad_to_mask_clearance 0) + (aux_axis_origin 0 0) + (visible_elements FFFFFFBF) + (pcbplotparams + (layerselection 3178497) + (usegerberextensions true) + (excludeedgelayer true) + (linewidth 152400) + (plotframeref false) + (viasonmask false) + (mode 1) + (useauxorigin false) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15) + (hpglpenoverlay 2) + (psnegative false) + (psa4output false) + (plotreference true) + (plotvalue true) + (plotothertext true) + (plotinvisibletext false) + (padsonsilk false) + (subtractmaskfromsilk false) + (outputformat 1) + (mirror false) + (drillshape 1) + (scaleselection 1) + (outputdirectory "")) + ) + + (net 0 "") + (net 1 +3.3V) + (net 2 "/A DIR") + (net 3 /NRST) + (net 4 /OSC1IN) + (net 5 /OSC2IN) + (net 6 /PB0) + (net 7 /PB1) + (net 8 /PB2) + (net 9 /PB4) + (net 10 /PB5) + (net 11 /PC1) + (net 12 /PC2) + (net 13 /PC3) + (net 14 /PC4) + (net 15 /PC5) + (net 16 /PC6) + (net 17 /PC7) + (net 18 /PD0) + (net 19 /PD2) + (net 20 /PD3) + (net 21 /PD4) + (net 22 /PD5) + (net 23 /PD6) + (net 24 /PD7) + (net 25 /PE5) + (net 26 /PF4) + (net 27 /SWIM/PD1) + (net 28 GND) + (net 29 N-0000021) + (net 30 N-0000026) + (net 31 N-0000042) + + (net_class Default "This is the default net class." + (clearance 0.254) + (trace_width 0.254) + (via_dia 0.889) + (via_drill 0.635) + (uvia_dia 0.508) + (uvia_drill 0.127) + (add_net "") + (add_net +3.3V) + (add_net "/A DIR") + (add_net /NRST) + (add_net /OSC1IN) + (add_net /OSC2IN) + (add_net /PB0) + (add_net /PB1) + (add_net /PB2) + (add_net /PB4) + (add_net /PB5) + (add_net /PC1) + (add_net /PC2) + (add_net /PC3) + (add_net /PC4) + (add_net /PC5) + (add_net /PC6) + (add_net /PC7) + (add_net /PD0) + (add_net /PD2) + (add_net /PD3) + (add_net /PD4) + (add_net /PD5) + (add_net /PD6) + (add_net /PD7) + (add_net /PE5) + (add_net /PF4) + (add_net /SWIM/PD1) + (add_net GND) + (add_net N-0000021) + (add_net N-0000026) + (add_net N-0000042) + ) + + (module TQFP32 (layer F.Cu) (tedit 43A670DA) (tstamp 52FB46F3) + (at 239.268 53.34) + (path /52FB03A2) + (fp_text reference U1 (at 0 -1.27) (layer F.SilkS) + (effects (font (size 1.27 1.016) (thickness 0.2032))) + ) + (fp_text value STM8S105K4T6C (at 0 1.905) (layer F.SilkS) + (effects (font (size 1.27 1.016) (thickness 0.2032))) + ) + (fp_line (start 5.0292 2.7686) (end 3.8862 2.7686) (layer F.SilkS) (width 0.1524)) + (fp_line (start 5.0292 -2.7686) (end 3.9116 -2.7686) (layer F.SilkS) (width 0.1524)) + (fp_line (start 5.0292 2.7686) (end 5.0292 -2.7686) (layer F.SilkS) (width 0.1524)) + (fp_line (start 2.794 3.9624) (end 2.794 5.0546) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.8194 3.9878) (end -2.8194 5.0546) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.8448 5.0546) (end 2.794 5.08) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.794 -5.0292) (end 2.7178 -5.0546) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.8862 -3.2766) (end -3.8862 3.9116) (layer F.SilkS) (width 0.1524)) + (fp_line (start 2.7432 -5.0292) (end 2.7432 -3.9878) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.2512 -3.8862) (end 3.81 -3.8862) (layer F.SilkS) (width 0.1524)) + (fp_line (start 3.8608 3.937) (end 3.8608 -3.7846) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.8862 3.937) (end 3.7338 3.937) (layer F.SilkS) (width 0.1524)) + (fp_line (start -5.0292 -2.8448) (end -5.0292 2.794) (layer F.SilkS) (width 0.1524)) + (fp_line (start -5.0292 2.794) (end -3.8862 2.794) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.87604 -3.302) (end -3.29184 -3.8862) (layer F.SilkS) (width 0.1524)) + (fp_line (start -5.02412 -2.8448) (end -3.87604 -2.8448) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.794 -3.8862) (end -2.794 -5.03428) (layer F.SilkS) (width 0.1524)) + (fp_circle (center -2.83972 -2.86004) (end -2.43332 -2.60604) (layer F.SilkS) (width 0.1524)) + (pad 8 smd rect (at -4.81584 2.77622) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 26 /PF4) + ) + (pad 7 smd rect (at -4.81584 1.97612) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 6 smd rect (at -4.81584 1.17602) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 5 smd rect (at -4.81584 0.37592) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 30 N-0000026) + ) + (pad 4 smd rect (at -4.81584 -0.42418) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 3 smd rect (at -4.81584 -1.22428) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 5 /OSC2IN) + ) + (pad 2 smd rect (at -4.81584 -2.02438) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 4 /OSC1IN) + ) + (pad 1 smd rect (at -4.81584 -2.82448) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (pad 24 smd rect (at 4.7498 -2.8194) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 17 /PC7) + ) + (pad 17 smd rect (at 4.7498 2.794) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 25 /PE5) + ) + (pad 18 smd rect (at 4.7498 1.9812) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 11 /PC1) + ) + (pad 19 smd rect (at 4.7498 1.1684) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 12 /PC2) + ) + (pad 20 smd rect (at 4.7498 0.381) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 13 /PC3) + ) + (pad 21 smd rect (at 4.7498 -0.4318) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 14 /PC4) + ) + (pad 22 smd rect (at 4.7498 -1.2192) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 15 /PC5) + ) + (pad 23 smd rect (at 4.7498 -2.032) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 16 /PC6) + ) + (pad 32 smd rect (at -2.82448 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 24 /PD7) + ) + (pad 31 smd rect (at -2.02692 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 23 /PD6) + ) + (pad 30 smd rect (at -1.22428 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 22 /PD5) + ) + (pad 29 smd rect (at -0.42672 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 21 /PD4) + ) + (pad 28 smd rect (at 0.37592 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 20 /PD3) + ) + (pad 27 smd rect (at 1.17348 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 19 /PD2) + ) + (pad 26 smd rect (at 1.97612 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 27 /SWIM/PD1) + ) + (pad 25 smd rect (at 2.77368 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 18 /PD0) + ) + (pad 9 smd rect (at -2.8194 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 10 smd rect (at -2.032 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 11 smd rect (at -1.2192 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 10 /PB5) + ) + (pad 12 smd rect (at -0.4318 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 9 /PB4) + ) + (pad 13 smd rect (at 0.3556 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 2 "/A DIR") + ) + (pad 14 smd rect (at 1.1684 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 8 /PB2) + ) + (pad 15 smd rect (at 1.9812 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 7 /PB1) + ) + (pad 16 smd rect (at 2.794 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 6 /PB0) + ) + (model smd/tqfp32.wrl + (at (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM2010 (layer F.Cu) (tedit 4EFC4DD5) (tstamp 52FB4700) + (at 207.518 73.66) + (tags "CMS SM") + (path /52FB0F3B) + (attr smd) + (fp_text reference SW1 (at -0.50038 0 90) (layer F.SilkS) + (effects (font (size 0.70104 0.70104) (thickness 0.127))) + ) + (fp_text value SW_PUSH (at 0.8001 0 90) (layer F.SilkS) + (effects (font (size 0.70104 0.70104) (thickness 0.127))) + ) + (fp_line (start 3.50012 -1.6002) (end 3.50012 1.6002) (layer F.SilkS) (width 0.11938)) + (fp_line (start -3.50012 -1.6002) (end -3.50012 1.6002) (layer F.SilkS) (width 0.11938)) + (fp_text user + (at -4.30022 1.80086) (layer F.SilkS) + (effects (font (size 1.524 1.524) (thickness 0.29972))) + ) + (fp_line (start 1.19634 1.60528) (end 3.48234 1.60528) (layer F.SilkS) (width 0.11938)) + (fp_line (start 3.48234 -1.60528) (end 1.19634 -1.60528) (layer F.SilkS) (width 0.11938)) + (fp_line (start -1.19888 -1.60528) (end -3.48488 -1.60528) (layer F.SilkS) (width 0.11938)) + (fp_line (start -3.48488 1.60528) (end -1.19888 1.60528) (layer F.SilkS) (width 0.11938)) + (pad 1 smd rect (at -2.4003 0) (size 1.80086 2.70002) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 2 smd rect (at 2.4003 0) (size 1.80086 2.70002) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (model smd\chip_smd_pol_wide.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.35 0.35 0.35)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB470C) + (at 214.884 73.406) + (path /52FB0413) + (attr smd) + (fp_text reference C1 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 1u (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 30 N-0000026) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4718) + (at 220.98 73.406) + (path /52FB0426) + (attr smd) + (fp_text reference C2 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 104 (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4724) + (at 227.076 73.406) + (path /52FB0DD3) + (attr smd) + (fp_text reference D1 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value LED (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 31 N-0000042) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4730) + (at 233.172 73.406) + (path /52FB0DE2) + (attr smd) + (fp_text reference R1 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 1k (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 31 N-0000042) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 12 /PC2) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB473C) + (at 182.626 76.962) + (path /52FB0ECD) + (attr smd) + (fp_text reference D2 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value LED (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 29 N-0000021) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4748) + (at 188.722 76.962) + (path /52FB0ED3) + (attr smd) + (fp_text reference R2 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 1k (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 29 N-0000021) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4754) + (at 194.818 76.962) + (path /52FB0EFD) + (attr smd) + (fp_text reference R3 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 10k (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4760) + (at 200.914 76.962) + (path /52FB0F99) + (attr smd) + (fp_text reference C3 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 104 (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SIL-5 (layer F.Cu) (tedit 200000) (tstamp 52FB476E) + (at 187.452 73.66) + (descr "Connecteur 5 pins") + (tags "CONN DEV") + (path /52FB4AA7) + (fp_text reference P4 (at -0.635 -2.54) (layer F.SilkS) + (effects (font (size 1.72974 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_5 (at 0 -2.54) (layer F.SilkS) hide + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -7.62 1.27) (end -7.62 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -7.62 -1.27) (end 5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 -1.27) (end 5.08 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 1.27) (end -7.62 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 1 +3.3V) + ) + (pad 2 thru_hole circle (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 3 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 23 /PD6) + ) + (pad 4 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 22 /PD5) + ) + (pad 5 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + ) + + (module SIL-4 (layer F.Cu) (tedit 200000) (tstamp 52FB477D) + (at 198.12 73.66) + (descr "Connecteur 4 pibs") + (tags "CONN DEV") + (path /52FB0A49) + (fp_text reference P2 (at 0 -2.54) (layer F.SilkS) + (effects (font (size 1.73482 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_4 (at 0 -2.54) (layer F.SilkS) hide + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -5.08 -1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 -1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 -1.27) (end 5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 -1.27) (end 5.08 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 1.27) (end -5.08 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -2.54 1.27) (end -2.54 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 1 +3.3V) + ) + (pad 2 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 27 /SWIM/PD1) + ) + (pad 3 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 3 /NRST) + ) + (pad 4 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + ) + + (module SIL-14 (layer F.Cu) (tedit 200000) (tstamp 52FB4793) + (at 197.612 70.358) + (descr "Connecteur 14 pins") + (tags "CONN DEV") + (path /52FB0A6A) + (fp_text reference P1 (at -10.16 -2.54) (layer F.SilkS) + (effects (font (size 1.72974 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_14 (at 7.62 -2.54) (layer F.SilkS) + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -17.78 -1.27) (end 17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 -1.27) (end 17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 1.27) (end -17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -17.78 1.27) (end -17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 1 +3.3V) + ) + (pad 2 thru_hole circle (at -13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 3 thru_hole circle (at -11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 3 /NRST) + ) + (pad 4 thru_hole circle (at -8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 4 /OSC1IN) + ) + (pad 5 thru_hole circle (at -6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 5 /OSC2IN) + ) + (pad 6 thru_hole circle (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 26 /PF4) + ) + (pad 7 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 10 /PB5) + ) + (pad 8 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 9 /PB4) + ) + (pad 9 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 2 "/A DIR") + ) + (pad 10 thru_hole circle (at 6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 8 /PB2) + ) + (pad 11 thru_hole circle (at 8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 7 /PB1) + ) + (pad 12 thru_hole circle (at 11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 6 /PB0) + ) + (pad 13 thru_hole circle (at 13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 25 /PE5) + ) + (pad 14 thru_hole circle (at 16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 11 /PC1) + ) + ) + + (module SIL-14 (layer F.Cu) (tedit 200000) (tstamp 52FB47A9) + (at 233.68 70.358) + (descr "Connecteur 14 pins") + (tags "CONN DEV") + (path /52FB0A79) + (fp_text reference P3 (at -10.16 -2.54) (layer F.SilkS) + (effects (font (size 1.72974 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_14 (at 7.62 -2.54) (layer F.SilkS) + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -17.78 -1.27) (end 17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 -1.27) (end 17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 1.27) (end -17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -17.78 1.27) (end -17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 24 /PD7) + ) + (pad 2 thru_hole circle (at -13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 23 /PD6) + ) + (pad 3 thru_hole circle (at -11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 22 /PD5) + ) + (pad 4 thru_hole circle (at -8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 21 /PD4) + ) + (pad 5 thru_hole circle (at -6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 20 /PD3) + ) + (pad 6 thru_hole circle (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 19 /PD2) + ) + (pad 7 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 27 /SWIM/PD1) + ) + (pad 8 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 18 /PD0) + ) + (pad 9 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 17 /PC7) + ) + (pad 10 thru_hole circle (at 6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 16 /PC6) + ) + (pad 11 thru_hole circle (at 8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 15 /PC5) + ) + (pad 12 thru_hole circle (at 11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 14 /PC4) + ) + (pad 13 thru_hole circle (at 13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 13 /PC3) + ) + (pad 14 thru_hole circle (at 16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 12 /PC2) + ) + ) + + (module DB25FC (layer F.Cu) (tedit 200000) (tstamp 52FB47DC) + (at 206.502 66.04) + (descr "Connecteur DB25 femelle couche") + (tags "CONN DB25") + (path /52FB403E) + (fp_text reference J1 (at 0 -15.24) (layer F.SilkS) + (effects (font (size 1.524 1.524) (thickness 0.3048))) + ) + (fp_text value DB25 (at 0 -6.35) (layer F.SilkS) + (effects (font (size 1.524 1.524) (thickness 0.3048))) + ) + (fp_line (start 26.67 -11.43) (end 26.67 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start 19.05 -6.35) (end 19.05 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start 20.955 -11.43) (end 20.955 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.955 -11.43) (end -20.955 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start -19.05 -6.35) (end -19.05 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 2.54) (end -26.67 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start 26.67 -6.35) (end 19.05 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 -6.35) (end -19.05 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start 20.32 -8.255) (end 20.32 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -8.255) (end -20.32 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start 20.32 -18.415) (end 20.32 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -18.415) (end -20.32 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start 26.67 -11.43) (end 26.67 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start 26.67 -12.7) (end -26.67 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 -12.7) (end -26.67 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 -11.43) (end 26.67 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start 19.05 2.54) (end 26.67 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -8.255) (end 20.32 -8.255) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -18.415) (end 20.32 -18.415) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 2.54) (end -19.05 2.54) (layer F.SilkS) (width 0.3048)) + (pad "" thru_hole circle (at 23.495 -1.27) (size 3.81 3.81) (drill 3.048) + (layers *.Cu *.Mask F.SilkS) + ) + (pad "" thru_hole circle (at -23.495 -1.27) (size 3.81 3.81) (drill 3.048) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 1 thru_hole rect (at -16.51 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 2 thru_hole circle (at -13.716 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 11 /PC1) + ) + (pad 3 thru_hole circle (at -11.049 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 6 /PB0) + ) + (pad 4 thru_hole circle (at -8.255 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 21 /PD4) + ) + (pad 5 thru_hole circle (at -5.461 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 7 /PB1) + ) + (pad 6 thru_hole circle (at -2.667 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 19 /PD2) + ) + (pad 7 thru_hole circle (at 0 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 8 /PB2) + ) + (pad 8 thru_hole circle (at 2.794 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 9 thru_hole circle (at 5.588 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 2 "/A DIR") + ) + (pad 10 thru_hole circle (at 8.382 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 11 thru_hole circle (at 11.049 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 12 thru_hole circle (at 13.843 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 13 thru_hole circle (at 16.637 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 14 thru_hole circle (at -14.9352 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 15 thru_hole circle (at -12.3952 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 16 thru_hole circle (at -9.6012 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 17 thru_hole circle (at -6.858 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 18 thru_hole circle (at -4.1148 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 19 thru_hole circle (at -1.3208 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 20 thru_hole circle (at 1.4224 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 21 thru_hole circle (at 4.1656 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 22 thru_hole circle (at 7.0104 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 23 thru_hole circle (at 9.7028 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 24 thru_hole circle (at 12.446 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 25 thru_hole circle (at 15.24 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (model conn_DBxx/db25_female_pin90deg.wrl + (at (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + +) diff --git a/stepper_independent/schematic/kicad.pro b/stepper_independent/schematic/kicad.pro new file mode 100644 index 0000000..6affc30 --- /dev/null +++ b/stepper_independent/schematic/kicad.pro @@ -0,0 +1,82 @@ +update=Вт 11 фев 2014 17:26:13 +version=1 +last_client=eeschema +[cvpcb] +version=1 +NetIExt=net +[cvpcb/libraries] +EquName1=devcms +[pcbnew] +version=1 +LastNetListRead= +PadDrlX=320 +PadDimH=550 +PadDimV=550 +BoardThickness=620 +TxtPcbV=600 +TxtPcbH=600 +TxtModV=500 +TxtModH=500 +TxtModW=100 +VEgarde=100 +DrawLar=120 +EdgeLar=80 +TxtLar=120 +MSegLar=120 +[pcbnew/libraries] +LibDir= +LibName1=sockets +LibName2=connect +LibName3=discret +LibName4=pin_array +LibName5=divers +LibName6=libcms +LibName7=display +LibName8=led +LibName9=dip_sockets +LibName10=pga_sockets +LibName11=valves +[general] +version=1 +[eeschema] +version=1 +LibDir= +NetFmtName= +RptD_X=0 +RptD_Y=100 +RptLab=1 +LabSize=60 +[eeschema/libraries] +LibName1=power +LibName2=device +LibName3=transistors +LibName4=conn +LibName5=linear +LibName6=regul +LibName7=74xx +LibName8=cmos4000 +LibName9=adc-dac +LibName10=memory +LibName11=xilinx +LibName12=special +LibName13=microcontrollers +LibName14=dsp +LibName15=microchip +LibName16=analog_switches +LibName17=motorola +LibName18=texas +LibName19=intel +LibName20=audio +LibName21=interface +LibName22=digital-audio +LibName23=philips +LibName24=display +LibName25=cypress +LibName26=siliconi +LibName27=opto +LibName28=atmel +LibName29=contrib +LibName30=valves +LibName31=stm8 +LibName32=st-microelectronics +LibName33=stm8s105k4t6c diff --git a/stepper_independent/schematic/stepper-cache.lib b/stepper_independent/schematic/stepper-cache.lib new file mode 100644 index 0000000..67c9a98 --- /dev/null +++ b/stepper_independent/schematic/stepper-cache.lib @@ -0,0 +1,318 @@ +EESchema-LIBRARY Version 2.3 Date: Ср 12 фев 2014 14:02:01 +#encoding utf-8 +# +# +3.3V +# +DEF +3.3V #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -40 30 H I C CNN +F1 "+3.3V" 0 110 30 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS +3,3V +DRAW +X +3.3V 1 0 0 0 U 30 30 0 0 W N +C 0 60 20 0 1 0 N +P 3 0 1 0 0 0 0 40 0 40 N +ENDDRAW +ENDDEF +# +# C +# +DEF C C 0 10 N Y 1 F N +F0 "C" 0 100 40 H V L CNN +F1 "C" 6 -85 40 H V L CNN +F2 "~" 38 -150 30 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + SM* + C? + C1-1 +$ENDFPLIST +DRAW +P 2 0 1 20 -80 -30 80 -30 N +P 2 0 1 20 -80 30 80 30 N +X ~ 1 0 200 170 D 40 40 1 1 P +X ~ 2 0 -200 170 U 40 40 1 1 P +ENDDRAW +ENDDEF +# +# CONN_14 +# +DEF CONN_14 P 0 40 Y N 1 F N +F0 "P" -30 0 60 V V C CNN +F1 "CONN_14" 80 0 60 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 700 150 -700 0 1 0 N +X P1 1 -350 650 250 R 50 50 1 1 P I +X P2 2 -350 550 250 R 50 50 1 1 P I +X P3 3 -350 450 250 R 50 50 1 1 P I +X P4 4 -350 350 250 R 50 50 1 1 P I +X P5 5 -350 250 250 R 50 50 1 1 P I +X P6 6 -350 150 250 R 50 50 1 1 P I +X P7 7 -350 50 250 R 50 50 1 1 P I +X P8 8 -350 -50 250 R 50 50 1 1 P I +X P9 9 -350 -150 250 R 50 50 1 1 P I +X P10 10 -350 -250 250 R 50 50 1 1 P I +X P11 11 -350 -350 250 R 50 50 1 1 P I +X P12 12 -350 -450 250 R 50 50 1 1 P I +X P13 13 -350 -550 250 R 50 50 1 1 P I +X P14 14 -350 -650 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_4 +# +DEF CONN_4 P 0 40 Y N 1 F N +F0 "P" -50 0 50 V V C CNN +F1 "CONN_4" 50 0 50 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 200 100 -200 0 1 0 N +X P1 1 -350 150 250 R 50 50 1 1 P I +X P2 2 -350 50 250 R 50 50 1 1 P I +X P3 3 -350 -50 250 R 50 50 1 1 P I +X P4 4 -350 -150 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_5 +# +DEF CONN_5 P 0 40 Y Y 1 F N +F0 "P" -50 0 50 V V C CNN +F1 "CONN_5" 50 0 50 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 250 100 -250 0 1 0 f +X ~ 1 -400 200 300 R 60 60 1 1 w I +X ~ 2 -400 100 300 R 60 60 1 1 P I +X ~ 3 -400 0 300 R 60 60 1 1 P I +X ~ 4 -400 -100 300 R 60 60 1 1 P I +X ~ 5 -400 -200 300 R 60 60 1 1 w I +ENDDRAW +ENDDEF +# +# DB25 +# +DEF DB25 J 0 40 Y N 1 F N +F0 "J" 50 1350 70 H V C CNN +F1 "DB25" -50 -1350 70 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + DB25* +$ENDFPLIST +DRAW +A -109 1270 41 1799 774 0 1 8 N -150 1270 -100 1310 +A -108 -1259 42 -1787 -788 0 1 8 N -150 -1260 -100 -1300 +A 116 -1169 34 -657 -15 0 1 8 N 130 -1200 150 -1170 +A 117 1170 32 664 1 0 1 8 N 130 1199 149 1170 +C -70 -1200 30 0 1 0 N +C -70 -1000 30 0 1 0 N +C -70 -800 30 0 1 0 N +C -70 -600 30 0 1 0 N +C -70 -400 30 0 1 0 N +C -70 -200 30 0 1 0 N +C -70 0 30 0 1 0 N +C -70 200 30 0 1 0 N +C -70 400 30 0 1 0 N +C -70 600 30 0 1 0 N +C -70 800 30 0 1 0 N +C -70 1000 30 0 1 0 N +C -70 1200 30 0 1 0 N +C 50 -1100 30 0 1 0 N +C 50 -900 30 0 1 0 N +C 50 -700 30 0 1 0 N +C 50 -500 30 0 1 0 N +C 50 -300 30 0 1 0 N +C 50 -100 30 0 1 0 N +C 50 100 30 0 1 0 N +C 50 300 30 0 1 0 N +C 50 500 30 0 1 0 N +C 50 700 30 0 1 0 N +C 50 900 30 0 1 0 N +C 50 1100 30 0 1 0 N +P 2 0 1 8 -150 -1260 -150 1270 N +P 2 0 1 0 -150 -1200 -100 -1200 N +P 2 0 1 0 -150 -1100 20 -1100 N +P 2 0 1 0 -150 -1000 -100 -1000 N +P 2 0 1 0 -150 -900 20 -900 N +P 2 0 1 0 -150 -800 -100 -800 N +P 2 0 1 0 -150 -700 20 -700 N +P 2 0 1 0 -150 -600 -100 -600 N +P 2 0 1 0 -150 -500 20 -500 N +P 2 0 1 0 -150 -400 -100 -400 N +P 2 0 1 0 -150 -300 20 -300 N +P 2 0 1 0 -150 -200 -100 -200 N +P 2 0 1 0 -150 -100 20 -100 N +P 2 0 1 0 -150 0 -100 0 N +P 2 0 1 0 -150 100 20 100 N +P 2 0 1 0 -150 200 -100 200 N +P 2 0 1 0 -150 300 20 300 N +P 2 0 1 0 -150 400 -100 400 N +P 2 0 1 0 -150 500 20 500 N +P 2 0 1 0 -150 600 -100 600 N +P 2 0 1 0 -150 700 20 700 N +P 2 0 1 0 -150 800 -100 800 N +P 2 0 1 0 -150 900 20 900 N +P 2 0 1 0 -150 1000 -100 1000 N +P 2 0 1 0 -150 1100 20 1100 N +P 2 0 1 0 -150 1200 -100 1200 N +P 2 0 1 8 -100 -1300 130 -1200 N +P 2 0 1 8 130 1200 -100 1310 N +P 2 0 1 8 150 -1170 150 1170 N +X 1 1 -450 -1200 300 R 60 60 1 1 P +X 2 2 -450 -1000 300 R 60 60 1 1 P +X 3 3 -450 -800 300 R 60 60 1 1 P +X 4 4 -450 -600 300 R 60 60 1 1 P +X 5 5 -450 -400 300 R 60 60 1 1 P +X 6 6 -450 -200 300 R 60 60 1 1 P +X 7 7 -450 0 300 R 60 60 1 1 P +X 8 8 -450 200 300 R 60 60 1 1 P +X 9 9 -450 400 300 R 60 60 1 1 P +X 10 10 -450 600 300 R 60 60 1 1 P +X P20 20 -450 100 300 R 60 60 1 1 P +X 11 11 -450 800 300 R 60 60 1 1 P +X P21 21 -450 300 300 R 60 60 1 1 P +X 12 12 -450 1000 300 R 60 60 1 1 P +X P22 22 -450 500 300 R 60 60 1 1 P +X 13 13 -450 1200 300 R 60 60 1 1 P +X P23 23 -450 700 300 R 60 60 1 1 P +X P14 14 -450 -1100 300 R 60 60 1 1 P +X P24 24 -450 900 300 R 60 60 1 1 P +X P15 15 -450 -900 300 R 60 60 1 1 P +X P25 25 -450 1100 300 R 60 60 1 1 P +X P16 16 -450 -700 300 R 60 60 1 1 P +X P17 17 -450 -500 300 R 60 60 1 1 P +X P18 18 -450 -300 300 R 60 60 1 1 P +X P19 19 -450 -100 300 R 60 60 1 1 P +ENDDRAW +ENDDEF +# +# GND +# +DEF ~GND #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 0 30 H I C CNN +F1 "GND" 0 -70 30 H I C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N +X GND 1 0 0 0 U 30 30 1 1 W N +ENDDRAW +ENDDEF +# +# LED +# +DEF LED D 0 40 Y N 1 F N +F0 "D" 0 100 50 H V C CNN +F1 "LED" 0 -100 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + LED-3MM + LED-5MM + LED-10MM + LED-0603 + LED-0805 + LED-1206 + LEDV +$ENDFPLIST +DRAW +P 2 0 1 0 50 50 50 -50 N +P 3 0 1 0 -50 50 50 0 -50 -50 F +P 3 0 1 0 65 -40 110 -80 105 -55 N +P 3 0 1 0 80 -25 125 -65 120 -40 N +X A 1 -200 0 150 R 40 40 1 1 P +X K 2 200 0 150 L 40 40 1 1 P +ENDDRAW +ENDDEF +# +# R +# +DEF R R 0 0 N Y 1 F N +F0 "R" 80 0 40 V V C CNN +F1 "R" 7 1 40 V V C CNN +F2 "~" -70 0 30 V V C CNN +F3 "~" 0 0 30 H V C CNN +$FPLIST + R? + SM0603 + SM0805 + R?-* + SM1206 +$ENDFPLIST +DRAW +S -40 150 40 -150 0 1 12 N +X ~ 1 0 250 100 D 60 60 1 1 P +X ~ 2 0 -250 100 U 60 60 1 1 P +ENDDRAW +ENDDEF +# +# STM8S105K4T6C +# +DEF STM8S105K4T6C U 0 40 Y Y 1 F N +F0 "U" 0 1050 60 H V C CNN +F1 "STM8S105K4T6C" 50 -850 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS stm8s105* +$FPLIST + lqfp32* +$ENDFPLIST +DRAW +S -1100 950 1100 -750 0 1 0 N +X NRST 1 -1400 850 300 R 50 50 1 1 I +X OSCIN/PA1 2 -1400 750 300 R 50 50 1 1 T +X OSCOUT/PA2 3 -1400 650 300 R 50 50 1 1 T +X VSS 4 -1400 550 300 R 50 50 1 1 W +X VCAP 5 -1400 450 300 R 50 50 1 1 w +X VDD(3.3-5v) 6 -1400 350 300 R 50 50 1 1 W +X VDDio 7 -1400 250 300 R 50 50 1 1 W +X PF4/AIN12 8 -1400 150 300 R 50 50 1 1 T +X VDDA 9 -1400 50 300 R 50 50 1 1 W +X VSSA 10 -1400 -50 300 R 50 50 1 1 W +X PC3(HS)/TIM1_CH3 20 1400 -350 300 L 50 50 1 1 T +X PD5/UART2_TX 30 1400 650 300 L 50 50 1 1 T +X PB5/AIN5[I2X_SDA] 11 -1400 -150 300 R 50 50 1 1 T +X PC4(HS)/TIM1_CH4 21 1400 -250 300 L 50 50 1 1 T +X PD6/UART2_RX 31 1400 750 300 L 50 50 1 1 T +X PB4/AIN4[I2C_SCL] 12 -1400 -250 300 R 50 50 1 1 T +X PC5(HS)/SPI_SCK 22 1400 -150 300 L 50 50 1 1 T +X PD7/TLI[TIM1_CH4] 32 1400 850 300 L 50 50 1 1 T +X PB3/AIN3[TIM1_ETR] 13 -1400 -350 300 R 50 50 1 1 T +X PC6(HS)/SPI_MOSI 23 1400 -50 300 L 50 50 1 1 T +X PB2/AIN2[TIM1_CH3N] 14 -1400 -450 300 R 50 50 1 1 T +X PC7(HS)/SPI_MISO 24 1400 50 300 L 50 50 1 1 T +X PB1/AIN1_[TIM1_CH2N] 15 -1400 -550 300 R 50 50 1 1 T +X PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO] 25 1400 150 300 L 50 50 1 1 T +X PB0/AIN0_[TIM1_CH1N] 16 -1400 -650 300 R 50 50 1 1 T +X PD1(HS)/SWIM 26 1400 250 300 L 50 50 1 1 T +X PE5/SPI_NSS 17 1400 -650 300 L 50 50 1 1 T +X PD2(HS)/TIM3_CH1[TIM2_CH3] 27 1400 350 300 L 50 50 1 1 T +X PC1(HS)/TIM1_CH1 18 1400 -550 300 L 50 50 1 1 T +X PD3(HS)/TIM2_CH2[ADC_ETR] 28 1400 450 300 L 50 50 1 1 T +X PC2(HS)/TIM1_CH2 19 1400 -450 300 L 50 50 1 1 T +X PD4(HS)/TIM2_CH1[BEEP] 29 1400 550 300 L 50 50 1 1 T +ENDDRAW +ENDDEF +# +# SW_PUSH +# +DEF SW_PUSH SW 0 40 N N 1 F N +F0 "SW" 150 110 50 H V C CNN +F1 "SW_PUSH" 0 -80 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -170 50 170 60 0 1 0 N +P 4 0 1 0 -40 60 -30 90 30 90 40 60 N +X 1 1 -300 0 200 R 60 60 0 1 P I +X 2 2 300 0 200 L 60 60 0 1 P I +ENDDRAW +ENDDEF +# +#End Library diff --git a/stepper_independent/schematic/stepper.cmp b/stepper_independent/schematic/stepper.cmp new file mode 100644 index 0000000..90be011 --- /dev/null +++ b/stepper_independent/schematic/stepper.cmp @@ -0,0 +1,108 @@ +Cmp-Mod V01 Created by CvPcb (2013-feb-26)-stable date = Ср 12 фев 2014 14:01:35 + +BeginCmp +TimeStamp = /52FB0413; +Reference = C1; +ValeurCmp = 1u; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0426; +Reference = C2; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F99; +Reference = C3; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0DD3; +Reference = D1; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ECD; +Reference = D2; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB403E; +Reference = J1; +ValeurCmp = DB25; +IdModule = DB25FC; +EndCmp + +BeginCmp +TimeStamp = /52FB0A6A; +Reference = P1; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB0A49; +Reference = P2; +ValeurCmp = CONN_4; +IdModule = SIL-4; +EndCmp + +BeginCmp +TimeStamp = /52FB0A79; +Reference = P3; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB4AA7; +Reference = P4; +ValeurCmp = CONN_5; +IdModule = SIL-5; +EndCmp + +BeginCmp +TimeStamp = /52FB0DE2; +Reference = R1; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ED3; +Reference = R2; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0EFD; +Reference = R3; +ValeurCmp = 10k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F3B; +Reference = SW1; +ValeurCmp = SW_PUSH; +IdModule = SM2010; +EndCmp + +BeginCmp +TimeStamp = /52FB03A2; +Reference = U1; +ValeurCmp = STM8S105K4T6C; +IdModule = TQFP32; +EndCmp + +EndListe diff --git a/stepper_independent/schematic/stepper.net b/stepper_independent/schematic/stepper.net new file mode 100644 index 0000000..818b2b3 --- /dev/null +++ b/stepper_independent/schematic/stepper.net @@ -0,0 +1,415 @@ +(export (version D) + (design + (source /home/eddy/Docs/SAO/ELECTRONICS/STM8/stepper_independent/schematic/stepper.sch) + (date "Ср 12 фев 2014 14:00:57") + (tool "eeschema (2013-feb-26)-stable")) + (components + (comp (ref U1) + (value STM8S105K4T6C) + (libsource (lib stm8s105k4t6c) (part STM8S105K4T6C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB03A2)) + (comp (ref C1) + (value 1u) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0413)) + (comp (ref C2) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0426)) + (comp (ref P2) + (value CONN_4) + (libsource (lib conn) (part CONN_4)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A49)) + (comp (ref P1) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A6A)) + (comp (ref P3) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A79)) + (comp (ref D1) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DD3)) + (comp (ref R1) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DE2)) + (comp (ref D2) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ECD)) + (comp (ref R2) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ED3)) + (comp (ref R3) + (value 10k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0EFD)) + (comp (ref SW1) + (value SW_PUSH) + (libsource (lib device) (part SW_PUSH)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F3B)) + (comp (ref C3) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F99)) + (comp (ref J1) + (value DB25) + (libsource (lib conn) (part DB25)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB403E)) + (comp (ref P4) + (value CONN_5) + (libsource (lib conn) (part CONN_5)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB4AA7))) + (libparts + (libpart (lib device) (part C) + (description "Condensateur non polarise") + (footprints + (fp SM*) + (fp C?) + (fp C1-1)) + (fields + (field (name Reference) C) + (field (name Value) C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part LED) + (footprints + (fp LED-3MM) + (fp LED-5MM) + (fp LED-10MM) + (fp LED-0603) + (fp LED-0805) + (fp LED-1206) + (fp LEDV)) + (fields + (field (name Reference) D) + (field (name Value) LED) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name A) (type passive)) + (pin (num 2) (name K) (type passive)))) + (libpart (lib device) (part R) + (description Resistance) + (footprints + (fp R?) + (fp SM0603) + (fp SM0805) + (fp R?-*) + (fp SM1206)) + (fields + (field (name Reference) R) + (field (name Value) R) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part SW_PUSH) + (description "Push Button") + (fields + (field (name Reference) SW) + (field (name Value) SW_PUSH) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name 1) (type passive)) + (pin (num 2) (name 2) (type passive)))) + (libpart (lib conn) (part CONN_14) + (description "Symbole general de connexion") + (fields + (field (name Reference) P) + (field (name Value) CONN_14)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)) + (pin (num 5) (name P5) (type passive)) + (pin (num 6) (name P6) (type passive)) + (pin (num 7) (name P7) (type passive)) + (pin (num 8) (name P8) (type passive)) + (pin (num 9) (name P9) (type passive)) + (pin (num 10) (name P10) (type passive)) + (pin (num 11) (name P11) (type passive)) + (pin (num 12) (name P12) (type passive)) + (pin (num 13) (name P13) (type passive)) + (pin (num 14) (name P14) (type passive)))) + (libpart (lib conn) (part CONN_4) + (description "Symbole general de connecteur") + (fields + (field (name Reference) P) + (field (name Value) CONN_4)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)))) + (libpart (lib conn) (part DB25) + (footprints + (fp DB25*)) + (fields + (field (name Reference) J) + (field (name Value) DB25)) + (pins + (pin (num 1) (name 1) (type passive)) + (pin (num 2) (name 2) (type passive)) + (pin (num 3) (name 3) (type passive)) + (pin (num 4) (name 4) (type passive)) + (pin (num 5) (name 5) (type passive)) + (pin (num 6) (name 6) (type passive)) + (pin (num 7) (name 7) (type passive)) + (pin (num 8) (name 8) (type passive)) + (pin (num 9) (name 9) (type passive)) + (pin (num 10) (name 10) (type passive)) + (pin (num 11) (name 11) (type passive)) + (pin (num 12) (name 12) (type passive)) + (pin (num 13) (name 13) (type passive)) + (pin (num 14) (name P14) (type passive)) + (pin (num 15) (name P15) (type passive)) + (pin (num 16) (name P16) (type passive)) + (pin (num 17) (name P17) (type passive)) + (pin (num 18) (name P18) (type passive)) + (pin (num 19) (name P19) (type passive)) + (pin (num 20) (name P20) (type passive)) + (pin (num 21) (name P21) (type passive)) + (pin (num 22) (name P22) (type passive)) + (pin (num 23) (name P23) (type passive)) + (pin (num 24) (name P24) (type passive)) + (pin (num 25) (name P25) (type passive)))) + (libpart (lib stm8s105k4t6c) (part STM8S105K4T6C) + (footprints + (fp lqfp32*)) + (fields + (field (name Reference) U) + (field (name Value) STM8S105K4T6C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name NRST) (type input)) + (pin (num 2) (name OSCIN/PA1) (type 3state)) + (pin (num 3) (name OSCOUT/PA2) (type 3state)) + (pin (num 4) (name VSS) (type power_in)) + (pin (num 5) (name VCAP) (type power_out)) + (pin (num 6) (name "VDD(3.3-5v)") (type power_in)) + (pin (num 7) (name VDDio) (type power_in)) + (pin (num 8) (name PF4/AIN12) (type 3state)) + (pin (num 9) (name VDDA) (type power_in)) + (pin (num 10) (name VSSA) (type power_in)) + (pin (num 11) (name PB5/AIN5[I2X_SDA]) (type 3state)) + (pin (num 12) (name PB4/AIN4[I2C_SCL]) (type 3state)) + (pin (num 13) (name PB3/AIN3[TIM1_ETR]) (type 3state)) + (pin (num 14) (name PB2/AIN2[TIM1_CH3N]) (type 3state)) + (pin (num 15) (name PB1/AIN1_[TIM1_CH2N]) (type 3state)) + (pin (num 16) (name PB0/AIN0_[TIM1_CH1N]) (type 3state)) + (pin (num 17) (name PE5/SPI_NSS) (type 3state)) + (pin (num 18) (name "PC1(HS)/TIM1_CH1") (type 3state)) + (pin (num 19) (name "PC2(HS)/TIM1_CH2") (type 3state)) + (pin (num 20) (name "PC3(HS)/TIM1_CH3") (type 3state)) + (pin (num 21) (name "PC4(HS)/TIM1_CH4") (type 3state)) + (pin (num 22) (name "PC5(HS)/SPI_SCK") (type 3state)) + (pin (num 23) (name "PC6(HS)/SPI_MOSI") (type 3state)) + (pin (num 24) (name "PC7(HS)/SPI_MISO") (type 3state)) + (pin (num 25) (name "PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO]") (type 3state)) + (pin (num 26) (name "PD1(HS)/SWIM") (type 3state)) + (pin (num 27) (name "PD2(HS)/TIM3_CH1[TIM2_CH3]") (type 3state)) + (pin (num 28) (name "PD3(HS)/TIM2_CH2[ADC_ETR]") (type 3state)) + (pin (num 29) (name "PD4(HS)/TIM2_CH1[BEEP]") (type 3state)) + (pin (num 30) (name PD5/UART2_TX) (type 3state)) + (pin (num 31) (name PD6/UART2_RX) (type 3state)) + (pin (num 32) (name PD7/TLI[TIM1_CH4]) (type 3state)))) + (libpart (lib conn) (part CONN_5) + (description "Symbole general de connecteur") + (fields + (field (name Reference) P) + (field (name Value) CONN_5)) + (pins + (pin (num 1) (name ~) (type power_out)) + (pin (num 2) (name ~) (type passive)) + (pin (num 3) (name ~) (type passive)) + (pin (num 4) (name ~) (type passive)) + (pin (num 5) (name ~) (type power_out))))) + (libraries + (library (logical device) + (uri /usr/share/kicad/library/device.lib)) + (library (logical conn) + (uri /usr/share/kicad/library/conn.lib)) + (library (logical stm8s105k4t6c) + (uri stm8s105k4t6c.lib))) + (nets + (net (code 1) (name "") + (node (ref J1) (pin 14))) + (net (code 2) (name /PC1) + (node (ref P1) (pin 14)) + (node (ref J1) (pin 2)) + (node (ref U1) (pin 18))) + (net (code 3) (name GND) + (node (ref C2) (pin 1)) + (node (ref P1) (pin 2)) + (node (ref P4) (pin 5)) + (node (ref SW1) (pin 1)) + (node (ref U1) (pin 10)) + (node (ref R2) (pin 2)) + (node (ref J1) (pin 24)) + (node (ref J1) (pin 25)) + (node (ref J1) (pin 18)) + (node (ref J1) (pin 19)) + (node (ref C1) (pin 1)) + (node (ref P2) (pin 4)) + (node (ref J1) (pin 20)) + (node (ref U1) (pin 4)) + (node (ref J1) (pin 21)) + (node (ref J1) (pin 22)) + (node (ref J1) (pin 23)) + (node (ref C3) (pin 2))) + (net (code 4) (name /NRST) + (node (ref SW1) (pin 2)) + (node (ref P2) (pin 3)) + (node (ref U1) (pin 1)) + (node (ref R3) (pin 2)) + (node (ref C3) (pin 1)) + (node (ref P1) (pin 3))) + (net (code 5) (name +3.3V) + (node (ref D1) (pin 1)) + (node (ref P1) (pin 1)) + (node (ref D2) (pin 1)) + (node (ref P2) (pin 1)) + (node (ref C2) (pin 2)) + (node (ref U1) (pin 9)) + (node (ref R3) (pin 1)) + (node (ref U1) (pin 7)) + (node (ref P4) (pin 1)) + (node (ref U1) (pin 6))) + (net (code 6) (name /PC2) + (node (ref P3) (pin 14)) + (node (ref R1) (pin 2)) + (node (ref U1) (pin 19))) + (net (code 7) (name "/1st out") + (node (ref J1) (pin 17))) + (net (code 8) (name /5.0V) + (node (ref P4) (pin 2))) + (net (code 9) (name /IN4) + (node (ref J1) (pin 13))) + (net (code 10) (name /IN3) + (node (ref J1) (pin 12))) + (net (code 11) (name /IN2) + (node (ref J1) (pin 11))) + (net (code 12) (name /IN1) + (node (ref J1) (pin 10))) + (net (code 13) (name /EN) + (node (ref J1) (pin 16))) + (net (code 14) (name /IN5) + (node (ref J1) (pin 15))) + (net (code 15) (name "/2nd out") + (node (ref J1) (pin 1))) + (net (code 16) (name /PD5) + (node (ref P3) (pin 3)) + (node (ref U1) (pin 30)) + (node (ref P4) (pin 4))) + (net (code 17) (name /PD6) + (node (ref P4) (pin 3)) + (node (ref P3) (pin 2)) + (node (ref U1) (pin 31))) + (net (code 18) (name "/A CLK") + (node (ref J1) (pin 8))) + (net (code 19) (name /PD2) + (node (ref J1) (pin 6)) + (node (ref P3) (pin 6)) + (node (ref U1) (pin 27))) + (net (code 20) (name /PD4) + (node (ref U1) (pin 29)) + (node (ref J1) (pin 4)) + (node (ref P3) (pin 4))) + (net (code 21) (name "") + (node (ref R2) (pin 1)) + (node (ref D2) (pin 2))) + (net (code 22) (name "/A DIR") + (node (ref J1) (pin 9)) + (node (ref U1) (pin 13)) + (node (ref P1) (pin 9))) + (net (code 23) (name /PB2) + (node (ref U1) (pin 14)) + (node (ref P1) (pin 10)) + (node (ref J1) (pin 7))) + (net (code 24) (name /PB1) + (node (ref P1) (pin 11)) + (node (ref U1) (pin 15)) + (node (ref J1) (pin 5))) + (net (code 25) (name /PB0) + (node (ref U1) (pin 16)) + (node (ref P1) (pin 12)) + (node (ref J1) (pin 3))) + (net (code 26) (name "") + (node (ref C1) (pin 2)) + (node (ref U1) (pin 5))) + (net (code 27) (name /PC3) + (node (ref U1) (pin 20)) + (node (ref P3) (pin 13))) + (net (code 28) (name /PC6) + (node (ref U1) (pin 23)) + (node (ref P3) (pin 10))) + (net (code 29) (name /PD7) + (node (ref P3) (pin 1)) + (node (ref U1) (pin 32))) + (net (code 30) (name /PC5) + (node (ref P3) (pin 11)) + (node (ref U1) (pin 22))) + (net (code 31) (name /PB4) + (node (ref P1) (pin 8)) + (node (ref U1) (pin 12))) + (net (code 32) (name /PC4) + (node (ref P3) (pin 12)) + (node (ref U1) (pin 21))) + (net (code 33) (name /PB5) + (node (ref U1) (pin 11)) + (node (ref P1) (pin 7))) + (net (code 34) (name /PF4) + (node (ref U1) (pin 8)) + (node (ref P1) (pin 6))) + (net (code 35) (name /OSC2IN) + (node (ref U1) (pin 3)) + (node (ref P1) (pin 5))) + (net (code 36) (name /OSC1IN) + (node (ref P1) (pin 4)) + (node (ref U1) (pin 2))) + (net (code 37) (name /PD3) + (node (ref P3) (pin 5)) + (node (ref U1) (pin 28))) + (net (code 38) (name /PE5) + (node (ref U1) (pin 17)) + (node (ref P1) (pin 13))) + (net (code 39) (name /SWIM/PD1) + (node (ref P3) (pin 7)) + (node (ref P2) (pin 2)) + (node (ref U1) (pin 26))) + (net (code 40) (name /PD0) + (node (ref P3) (pin 8)) + (node (ref U1) (pin 25))) + (net (code 41) (name /PC7) + (node (ref U1) (pin 24)) + (node (ref P3) (pin 9))) + (net (code 42) (name "") + (node (ref R1) (pin 1)) + (node (ref D1) (pin 2))))) \ No newline at end of file diff --git a/stepper_independent/schematic/stepper.sch b/stepper_independent/schematic/stepper.sch new file mode 100644 index 0000000..3134f8a --- /dev/null +++ b/stepper_independent/schematic/stepper.sch @@ -0,0 +1,731 @@ +EESchema Schematic File Version 2 date Ср 12 фев 2014 14:02:01 +LIBS:power +LIBS:device +LIBS:transistors +LIBS:conn +LIBS:linear +LIBS:regul +LIBS:74xx +LIBS:cmos4000 +LIBS:adc-dac +LIBS:memory +LIBS:xilinx +LIBS:special +LIBS:microcontrollers +LIBS:dsp +LIBS:microchip +LIBS:analog_switches +LIBS:motorola +LIBS:texas +LIBS:intel +LIBS:audio +LIBS:interface +LIBS:digital-audio +LIBS:philips +LIBS:display +LIBS:cypress +LIBS:siliconi +LIBS:opto +LIBS:atmel +LIBS:contrib +LIBS:valves +LIBS:stm8 +LIBS:st-microelectronics +LIBS:stm8s105k4t6c +LIBS:stepper-cache +EELAYER 27 0 +EELAYER END +$Descr A4 11693 8268 +encoding utf-8 +Sheet 1 1 +Title "" +Date "12 feb 2014" +Rev "" +Comp "" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L STM8S105K4T6C U1 +U 1 1 52FB03A2 +P 4400 3100 +F 0 "U1" H 4400 4150 60 0000 C CNN +F 1 "STM8S105K4T6C" H 4450 2250 60 0000 C CNN +F 2 "~" H 4400 3100 60 0000 C CNN +F 3 "~" H 4400 3100 60 0000 C CNN + 1 4400 3100 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR01 +U 1 1 52FB03EF +P 2750 3200 +F 0 "#PWR01" H 2750 3200 30 0001 C CNN +F 1 "GND" H 2750 3130 30 0001 C CNN +F 2 "" H 2750 3200 60 0000 C CNN +F 3 "" H 2750 3200 60 0000 C CNN + 1 2750 3200 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 3200 2750 3150 +Wire Wire Line + 2750 3150 3000 3150 +$Comp +L GND #PWR02 +U 1 1 52FB0400 +P 2750 2600 +F 0 "#PWR02" H 2750 2600 30 0001 C CNN +F 1 "GND" H 2750 2530 30 0001 C CNN +F 2 "" H 2750 2600 60 0000 C CNN +F 3 "" H 2750 2600 60 0000 C CNN + 1 2750 2600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 2600 2750 2550 +Wire Wire Line + 2750 2550 3000 2550 +$Comp +L C C1 +U 1 1 52FB0413 +P 2250 2700 +F 0 "C1" H 2300 2800 50 0000 L CNN +F 1 "1u" H 2300 2600 50 0000 L CNN +F 2 "" H 2250 2700 60 0000 C CNN +F 3 "" H 2250 2700 60 0000 C CNN + 1 2250 2700 + 0 -1 -1 0 +$EndComp +$Comp +L C C2 +U 1 1 52FB0426 +P 2250 2950 +F 0 "C2" H 2300 3050 50 0000 L CNN +F 1 "104" H 2300 2850 50 0000 L CNN +F 2 "" H 2250 2950 60 0000 C CNN +F 3 "" H 2250 2950 60 0000 C CNN + 1 2250 2950 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 2450 2700 2850 2700 +Wire Wire Line + 2850 2700 2850 2650 +Wire Wire Line + 2850 2650 3000 2650 +Wire Wire Line + 3000 2750 3000 2850 +Wire Wire Line + 2450 2950 2450 2850 +Wire Wire Line + 2450 2850 3000 2850 +Wire Wire Line + 2050 2700 2050 3100 +$Comp +L GND #PWR03 +U 1 1 52FB0453 +P 2050 3100 +F 0 "#PWR03" H 2050 3100 30 0001 C CNN +F 1 "GND" H 2050 3030 30 0001 C CNN +F 2 "" H 2050 3100 60 0000 C CNN +F 3 "" H 2050 3100 60 0000 C CNN + 1 2050 3100 + 1 0 0 -1 +$EndComp +Connection ~ 2050 2800 +Connection ~ 2050 2950 +Text Label 3000 2250 2 60 ~ 0 +NRST +Text Label 3000 2350 2 60 ~ 0 +OSC1IN +Text Label 3000 2450 2 60 ~ 0 +OSC2IN +Text Label 3000 2950 2 60 ~ 0 +PF4 +Text Label 3000 3250 2 60 ~ 0 +PB5 +Text Label 3000 3350 2 60 ~ 0 +PB4 +Text Label 3000 3450 2 60 ~ 0 +PB3 +Text Label 3000 3550 2 60 ~ 0 +PB2 +Text Label 3000 3650 2 60 ~ 0 +PB1 +Text Label 3000 3750 2 60 ~ 0 +PB0 +Text Label 5800 3750 0 60 ~ 0 +PE5 +Text Label 5800 3650 0 60 ~ 0 +PC1 +Text Label 5800 3550 0 60 ~ 0 +PC2 +Text Label 5800 3450 0 60 ~ 0 +PC3 +Text Label 5800 3350 0 60 ~ 0 +PC4 +Text Label 5800 3250 0 60 ~ 0 +PC5 +Text Label 5800 3150 0 60 ~ 0 +PC6 +Text Label 5800 3050 0 60 ~ 0 +PC7 +Text Label 5800 2950 0 60 ~ 0 +PD0 +Text Label 5800 2850 0 60 ~ 0 +SWIM/PD1 +Text Label 5800 2750 0 60 ~ 0 +PD2 +Text Label 5800 2650 0 60 ~ 0 +PD3 +Text Label 5800 2550 0 60 ~ 0 +PD4 +Text Label 5800 2450 0 60 ~ 0 +PD5 +Text Label 5800 2350 0 60 ~ 0 +PD6 +Text Label 5800 2250 0 60 ~ 0 +PD7 +$Comp +L CONN_4 P2 +U 1 1 52FB0A49 +P 4350 1000 +F 0 "P2" V 4300 1000 50 0000 C CNN +F 1 "CONN_4" V 4400 1000 50 0000 C CNN +F 2 "" H 4350 1000 60 0000 C CNN +F 3 "" H 4350 1000 60 0000 C CNN + 1 4350 1000 + 1 0 0 -1 +$EndComp +$Comp +L CONN_14 P1 +U 1 1 52FB0A6A +P 1250 1500 +F 0 "P1" V 1220 1500 60 0000 C CNN +F 1 "CONN_14" V 1330 1500 60 0000 C CNN +F 2 "" H 1250 1500 60 0000 C CNN +F 3 "" H 1250 1500 60 0000 C CNN + 1 1250 1500 + -1 0 0 -1 +$EndComp +$Comp +L CONN_14 P3 +U 1 1 52FB0A79 +P 7100 1500 +F 0 "P3" V 7070 1500 60 0000 C CNN +F 1 "CONN_14" V 7180 1500 60 0000 C CNN +F 2 "" H 7100 1500 60 0000 C CNN +F 3 "" H 7100 1500 60 0000 C CNN + 1 7100 1500 + 1 0 0 -1 +$EndComp +Text Label 1600 1150 0 60 ~ 0 +OSC1IN +Text Label 1600 1250 0 60 ~ 0 +OSC2IN +Text Label 1600 1350 0 60 ~ 0 +PF4 +Text Label 1600 1450 0 60 ~ 0 +PB5 +Text Label 1600 1550 0 60 ~ 0 +PB4 +Text Label 1600 1650 0 60 ~ 0 +PB3 +Text Label 1600 1750 0 60 ~ 0 +PB2 +Text Label 1600 1850 0 60 ~ 0 +PB1 +Text Label 1600 1950 0 60 ~ 0 +PB0 +Text Label 1600 2050 0 60 ~ 0 +PE5 +Text Label 1600 2150 0 60 ~ 0 +PC1 +Text Label 1600 1050 0 60 ~ 0 +NRST +Text Label 4000 950 2 60 ~ 0 +SWIM/PD1 +Text Label 4000 1050 2 60 ~ 0 +NRST +Text Label 6750 850 2 60 ~ 0 +PD7 +Text Label 6750 950 2 60 ~ 0 +PD6 +Text Label 6750 1050 2 60 ~ 0 +PD5 +Text Label 6750 1150 2 60 ~ 0 +PD4 +Text Label 6750 1250 2 60 ~ 0 +PD3 +Text Label 6750 1350 2 60 ~ 0 +PD2 +Text Label 6750 1450 2 60 ~ 0 +SWIM/PD1 +Text Label 6750 1550 2 60 ~ 0 +PD0 +Text Label 6750 1650 2 60 ~ 0 +PC7 +Text Label 6750 1750 2 60 ~ 0 +PC6 +Text Label 6750 1850 2 60 ~ 0 +PC5 +Text Label 6750 1950 2 60 ~ 0 +PC4 +Text Label 6750 2050 2 60 ~ 0 +PC3 +Text Label 6750 2150 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR04 +U 1 1 52FB0DC4 +P 950 2800 +F 0 "#PWR04" H 950 2760 30 0001 C CNN +F 1 "+3.3V" H 950 2910 30 0000 C CNN +F 2 "" H 950 2800 60 0000 C CNN +F 3 "" H 950 2800 60 0000 C CNN + 1 950 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D1 +U 1 1 52FB0DD3 +P 950 3100 +F 0 "D1" H 950 3200 50 0000 C CNN +F 1 "LED" H 950 3000 50 0000 C CNN +F 2 "" H 950 3100 60 0000 C CNN +F 3 "" H 950 3100 60 0000 C CNN + 1 950 3100 + 0 1 1 0 +$EndComp +$Comp +L R R1 +U 1 1 52FB0DE2 +P 950 3600 +F 0 "R1" V 1030 3600 50 0000 C CNN +F 1 "1k" V 950 3600 50 0000 C CNN +F 2 "" H 950 3600 60 0000 C CNN +F 3 "" H 950 3600 60 0000 C CNN + 1 950 3600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 950 2800 950 2900 +Wire Wire Line + 950 3300 950 3350 +Wire Wire Line + 950 3850 950 3950 +$Comp +L +3.3V #PWR05 +U 1 1 52FB0EC7 +P 1300 2800 +F 0 "#PWR05" H 1300 2760 30 0001 C CNN +F 1 "+3.3V" H 1300 2910 30 0000 C CNN +F 2 "" H 1300 2800 60 0000 C CNN +F 3 "" H 1300 2800 60 0000 C CNN + 1 1300 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D2 +U 1 1 52FB0ECD +P 1300 3100 +F 0 "D2" H 1300 3200 50 0000 C CNN +F 1 "LED" H 1300 3000 50 0000 C CNN +F 2 "" H 1300 3100 60 0000 C CNN +F 3 "" H 1300 3100 60 0000 C CNN + 1 1300 3100 + 0 1 1 0 +$EndComp +$Comp +L R R2 +U 1 1 52FB0ED3 +P 1300 3600 +F 0 "R2" V 1380 3600 50 0000 C CNN +F 1 "1k" V 1300 3600 50 0000 C CNN +F 2 "" H 1300 3600 60 0000 C CNN +F 3 "" H 1300 3600 60 0000 C CNN + 1 1300 3600 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR06 +U 1 1 52FB0ED9 +P 1300 3950 +F 0 "#PWR06" H 1300 3950 30 0001 C CNN +F 1 "GND" H 1300 3880 30 0001 C CNN +F 2 "" H 1300 3950 60 0000 C CNN +F 3 "" H 1300 3950 60 0000 C CNN + 1 1300 3950 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1300 2800 1300 2900 +Wire Wire Line + 1300 3300 1300 3350 +Wire Wire Line + 1300 3850 1300 3950 +Text Label 950 3950 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR07 +U 1 1 52FB0EF1 +P 6500 2550 +F 0 "#PWR07" H 6500 2510 30 0001 C CNN +F 1 "+3.3V" H 6500 2660 30 0000 C CNN +F 2 "" H 6500 2550 60 0000 C CNN +F 3 "" H 6500 2550 60 0000 C CNN + 1 6500 2550 + 1 0 0 -1 +$EndComp +$Comp +L R R3 +U 1 1 52FB0EFD +P 6500 2900 +F 0 "R3" V 6580 2900 50 0000 C CNN +F 1 "10k" V 6500 2900 50 0000 C CNN +F 2 "" H 6500 2900 60 0000 C CNN +F 3 "" H 6500 2900 60 0000 C CNN + 1 6500 2900 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR08 +U 1 1 52FB0F03 +P 6500 4050 +F 0 "#PWR08" H 6500 4050 30 0001 C CNN +F 1 "GND" H 6500 3980 30 0001 C CNN +F 2 "" H 6500 4050 60 0000 C CNN +F 3 "" H 6500 4050 60 0000 C CNN + 1 6500 4050 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6500 2550 6500 2650 +Wire Wire Line + 6500 3850 6500 4050 +$Comp +L SW_PUSH SW1 +U 1 1 52FB0F3B +P 6500 3550 +F 0 "SW1" H 6650 3660 50 0000 C CNN +F 1 "SW_PUSH" H 6500 3470 50 0000 C CNN +F 2 "" H 6500 3550 60 0000 C CNN +F 3 "" H 6500 3550 60 0000 C CNN + 1 6500 3550 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 6500 3250 6500 3150 +$Comp +L C C3 +U 1 1 52FB0F99 +P 6900 3550 +F 0 "C3" H 6950 3650 50 0000 L CNN +F 1 "104" H 6950 3450 50 0000 L CNN +F 2 "" H 6900 3550 60 0000 C CNN +F 3 "" H 6900 3550 60 0000 C CNN + 1 6900 3550 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6900 3200 6900 3350 +Wire Wire Line + 6900 3750 6900 3900 +Wire Wire Line + 6900 3900 6500 3900 +Connection ~ 6500 3900 +Wire Wire Line + 6500 3200 6900 3200 +Connection ~ 6500 3200 +Text Label 6500 3200 2 60 ~ 0 +NRST +$Comp +L +3.3V #PWR09 +U 1 1 52FB2273 +P 2150 850 +F 0 "#PWR09" H 2150 810 30 0001 C CNN +F 1 "+3.3V" H 2150 960 30 0000 C CNN +F 2 "" H 2150 850 60 0000 C CNN +F 3 "" H 2150 850 60 0000 C CNN + 1 2150 850 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 850 2150 850 +$Comp +L GND #PWR010 +U 1 1 52FB2296 +P 2150 1000 +F 0 "#PWR010" H 2150 1000 30 0001 C CNN +F 1 "GND" H 2150 930 30 0001 C CNN +F 2 "" H 2150 1000 60 0000 C CNN +F 3 "" H 2150 1000 60 0000 C CNN + 1 2150 1000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 950 2150 950 +Wire Wire Line + 2150 950 2150 1000 +Wire Wire Line + 2600 3050 3000 3050 +Wire Wire Line + 2750 3050 2750 2850 +Connection ~ 2750 2850 +$Comp +L +3.3V #PWR011 +U 1 1 52FB26FA +P 2600 3000 +F 0 "#PWR011" H 2600 2960 30 0001 C CNN +F 1 "+3.3V" H 2600 3110 30 0000 C CNN +F 2 "" H 2600 3000 60 0000 C CNN +F 3 "" H 2600 3000 60 0000 C CNN + 1 2600 3000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2600 3000 2600 3050 +Connection ~ 2750 3050 +$Comp +L +3.3V #PWR012 +U 1 1 52FB286D +P 4000 750 +F 0 "#PWR012" H 4000 710 30 0001 C CNN +F 1 "+3.3V" H 4000 860 30 0000 C CNN +F 2 "" H 4000 750 60 0000 C CNN +F 3 "" H 4000 750 60 0000 C CNN + 1 4000 750 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR013 +U 1 1 52FB287C +P 4000 1300 +F 0 "#PWR013" H 4000 1300 30 0001 C CNN +F 1 "GND" H 4000 1230 30 0001 C CNN +F 2 "" H 4000 1300 60 0000 C CNN +F 3 "" H 4000 1300 60 0000 C CNN + 1 4000 1300 + 1 0 0 -1 +$EndComp +Wire Wire Line + 4000 1300 4000 1150 +Wire Wire Line + 4000 850 4000 750 +Wire Notes Line + 600 500 600 4200 +Wire Notes Line + 600 4200 7500 4200 +Wire Notes Line + 7500 4200 7500 500 +Wire Notes Line + 7500 500 600 500 +Text Notes 3550 4450 0 118 ~ 0 +STM8 board +$Comp +L DB25 J1 +U 1 1 52FB403E +P 1150 6100 +F 0 "J1" H 1200 7450 70 0000 C CNN +F 1 "DB25" H 1100 4750 70 0000 C CNN +F 2 "" H 1150 6100 60 0000 C CNN +F 3 "" H 1150 6100 60 0000 C CNN + 1 1150 6100 + -1 0 0 1 +$EndComp +$Comp +L GND #PWR014 +U 1 1 52FB40A4 +P 2200 7500 +F 0 "#PWR014" H 2200 7500 30 0001 C CNN +F 1 "GND" H 2200 7430 30 0001 C CNN +F 2 "" H 2200 7500 60 0000 C CNN +F 3 "" H 2200 7500 60 0000 C CNN + 1 2200 7500 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 7200 2200 7200 +Wire Wire Line + 2200 5800 2200 7500 +Wire Wire Line + 1600 7000 2200 7000 +Connection ~ 2200 7200 +Wire Wire Line + 2200 6800 1600 6800 +Connection ~ 2200 7000 +Wire Wire Line + 1600 6600 2200 6600 +Connection ~ 2200 6800 +Wire Wire Line + 1600 6400 2200 6400 +Connection ~ 2200 6600 +Wire Wire Line + 1600 6200 2200 6200 +Connection ~ 2200 6400 +Wire Wire Line + 1600 6000 2200 6000 +Connection ~ 2200 6200 +Wire Wire Line + 1600 5800 2200 5800 +Connection ~ 2200 6000 +Text Label 1600 4900 0 60 ~ 0 +2nd out +Text Label 1600 5100 0 60 ~ 0 +X CLK +Text Label 1600 5300 0 60 ~ 0 +X DIR +Text Label 1600 5500 0 60 ~ 0 +Y CLK +Text Label 1600 5700 0 60 ~ 0 +Y DIR +Text Label 1600 5900 0 60 ~ 0 +Z CLK +Text Label 1600 6100 0 60 ~ 0 +Z DIR +Text Label 1600 6300 0 60 ~ 0 +A CLK +Text Label 1600 6500 0 60 ~ 0 +A DIR +Text Label 1600 6700 0 60 ~ 0 +IN1 +Text Label 1600 6900 0 60 ~ 0 +IN2 +Text Label 1600 7100 0 60 ~ 0 +IN3 +Text Label 1600 7300 0 60 ~ 0 +IN4 +Text Label 1600 5200 0 60 ~ 0 +IN5 +Text Label 1600 5400 0 60 ~ 0 +EN +Text Label 1600 5600 0 60 ~ 0 +1st out +Wire Wire Line + 1600 5300 3000 5300 +Wire Wire Line + 1600 5700 3000 5700 +Wire Wire Line + 1600 6100 3000 6100 +Wire Wire Line + 1600 6500 3000 6500 +Text Label 3000 5300 0 60 ~ 0 +PB0 +Text Label 3000 5700 0 60 ~ 0 +PB1 +Text Label 3000 6100 0 60 ~ 0 +PB2 +Text Label 3000 6500 0 60 ~ 0 +PB3 +Wire Wire Line + 1600 5100 2600 5100 +Wire Wire Line + 1600 5500 2600 5500 +Wire Wire Line + 1600 5900 2600 5900 +Wire Wire Line + 1600 6300 2600 6300 +NoConn ~ 1600 5000 +Text Label 2600 5100 0 60 ~ 0 +PC1 +Text Label 2600 5500 0 60 ~ 0 +PD4 +Text Label 2600 5900 0 60 ~ 0 +PD2 +NoConn ~ 2600 6300 +Wire Wire Line + 1600 4900 2300 4900 +Wire Wire Line + 1600 5200 2300 5200 +Wire Wire Line + 1600 5400 2300 5400 +Wire Wire Line + 1600 5600 2300 5600 +Wire Wire Line + 1600 7300 2300 7300 +Wire Wire Line + 1600 7100 2300 7100 +Wire Wire Line + 1600 6900 2300 6900 +Wire Wire Line + 1600 6700 2300 6700 +NoConn ~ 2300 4900 +NoConn ~ 2300 5200 +NoConn ~ 2300 5400 +NoConn ~ 2300 5600 +NoConn ~ 2300 6700 +NoConn ~ 2300 6900 +NoConn ~ 2300 7100 +NoConn ~ 2300 7300 +$Comp +L CONN_5 P4 +U 1 1 52FB4AA7 +P 4800 5300 +F 0 "P4" V 4750 5300 50 0000 C CNN +F 1 "CONN_5" V 4850 5300 50 0000 C CNN +F 2 "" H 4800 5300 60 0000 C CNN +F 3 "" H 4800 5300 60 0000 C CNN + 1 4800 5300 + -1 0 0 1 +$EndComp +Text Notes 700 4600 0 118 ~ 0 +To TB6560_T4_V4 +Text Notes 4150 4900 0 118 ~ 0 +USB <-> TTL +Text Label 5200 5100 0 61 ~ 0 +GND +Text Label 5200 5200 0 61 ~ 0 +RXD +Text Label 5200 5300 0 61 ~ 0 +TXD +Text Label 5200 5400 0 61 ~ 0 +5.0V +Text Label 5200 5500 0 61 ~ 0 +3.3V +$Comp +L GND #PWR015 +U 1 1 52FB4CEF +P 6200 5200 +F 0 "#PWR015" H 6200 5200 30 0001 C CNN +F 1 "GND" H 6200 5130 30 0001 C CNN +F 2 "" H 6200 5200 60 0000 C CNN +F 3 "" H 6200 5200 60 0000 C CNN + 1 6200 5200 + 1 0 0 -1 +$EndComp +Wire Wire Line + 5200 5100 6200 5100 +Wire Wire Line + 6200 5100 6200 5200 +Wire Wire Line + 5200 5200 5800 5200 +Wire Wire Line + 5800 5200 5800 4800 +Wire Wire Line + 5200 5300 6400 5300 +Wire Wire Line + 6400 5300 6400 4800 +$Comp +L +3.3V #PWR016 +U 1 1 52FB4EDC +P 6600 5400 +F 0 "#PWR016" H 6600 5360 30 0001 C CNN +F 1 "+3.3V" H 6600 5510 30 0000 C CNN +F 2 "" H 6600 5400 60 0000 C CNN +F 3 "" H 6600 5400 60 0000 C CNN + 1 6600 5400 + 1 0 0 -1 +$EndComp +Wire Wire Line + 5200 5500 6600 5500 +Wire Wire Line + 6600 5500 6600 5400 +NoConn ~ 5200 5400 +Text Label 5800 4800 0 61 ~ 0 +PD5 +Text Label 6400 4800 0 61 ~ 0 +PD6 +$EndSCHEMATC diff --git a/stepper_independent/schematic/stm8s105k4t6c.bck b/stepper_independent/schematic/stm8s105k4t6c.bck new file mode 100644 index 0000000..5efbdbd --- /dev/null +++ b/stepper_independent/schematic/stm8s105k4t6c.bck @@ -0,0 +1,9 @@ +EESchema-DOCLIB Version 2.0 Date: Вт 11 фев 2014 17:09:58 +# +$CMP STM8S003K3T +D STM8S003K3T, LQFP32 (7x7, 0.8mm pitch), 16MHz, 8K Flash, 1K RAM, 128 EEPROM +K STM8 Microcontroller Value Line +F http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00024550.pdf +$ENDCMP +# +#End Doc Library diff --git a/stepper_independent/schematic/stm8s105k4t6c.dcm b/stepper_independent/schematic/stm8s105k4t6c.dcm new file mode 100644 index 0000000..71362a5 --- /dev/null +++ b/stepper_independent/schematic/stm8s105k4t6c.dcm @@ -0,0 +1,13 @@ +EESchema-DOCLIB Version 2.0 Date: Вт 11 фев 2014 17:26:38 +# +$CMP STM8S003K3T +D STM8S003K3T, LQFP32 (7x7, 0.8mm pitch), 16MHz, 8K Flash, 1K RAM, 128 EEPROM +K STM8 Microcontroller Value Line +F http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00024550.pdf +$ENDCMP +# +$CMP STM8S105K4T6C +K stm8 +$ENDCMP +# +#End Doc Library diff --git a/stepper_independent/schematic/stm8s105k4t6c.lib b/stepper_independent/schematic/stm8s105k4t6c.lib new file mode 100644 index 0000000..4b3ba70 --- /dev/null +++ b/stepper_independent/schematic/stm8s105k4t6c.lib @@ -0,0 +1,99 @@ +EESchema-LIBRARY Version 2.3 Date: Вт 11 фев 2014 17:26:38 +#encoding utf-8 +# +# STM8S003K3T +# +DEF STM8S003K3T IC 0 40 Y Y 1 F N +F0 "IC" -800 1150 60 H V C CNN +F1 "STM8S003K3T" 550 -1100 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + LQFP32* +$ENDFPLIST +DRAW +S -850 1100 850 -1050 0 1 10 f +X NRST 1 -1000 1000 149 R 40 40 1 1 I +X OSCI/PA1 2 1000 1000 149 L 40 40 1 1 B +X OSCOUT/PA2 3 1000 900 149 L 40 40 1 1 B +X VSS 4 0 -1200 149 U 40 40 1 1 W +X Vcap 5 -1000 -950 149 R 40 40 1 1 I +X VDD 6 0 1250 149 D 40 40 1 1 W +X [SPI_NSS]TIM2_CH3/PA3 7 1000 800 149 L 40 40 1 1 B +X PF4 8 -1000 -350 149 R 40 40 1 1 B +X PB7 9 1000 -50 149 L 40 40 1 1 B +X PB6 10 1000 50 149 L 40 40 1 1 B +X TIM1_CH3/PC3 20 1000 -400 149 L 40 40 1 1 B +X PD5/UART1_TX 30 -1000 150 149 R 40 40 1 1 B +X I2C_SDA/PB5 11 1000 150 149 L 40 40 1 1 B +X CLK_CCO/TIM1_CH4/PC4 21 1000 -500 149 L 40 40 1 1 B +X PD6/UART1_RX 31 -1000 50 149 R 40 40 1 1 B +X I2C_SCL/PB4 12 1000 250 149 L 40 40 1 1 B +X SPI_SCK/PC5 22 1000 -600 149 L 40 40 1 1 B +X PD7/TLI[TIM1_CH4] 32 -1000 -50 148 R 40 40 1 1 B +X TIM1_ETR/AIN3/PB3 13 1000 350 149 L 40 40 1 1 B +X PI_MOSI/PC6 23 1000 -700 149 L 40 40 1 1 B +X TIM1_CH3N/AIN2/PB2 14 1000 450 149 L 40 40 1 1 B +X PI_MISO/PC7 24 1000 -800 149 L 40 40 1 1 B +X TIM1_CH2N/AIN1/PB1 15 1000 550 149 L 40 40 1 1 B +X PD0/TIM1_BKIN[CLK_CCO] 25 -1000 650 148 R 40 40 1 1 B +X TIM1_CH1N/AIN0/PB0 16 1000 650 149 L 40 40 1 1 B +X PD1/SWIM 26 -1000 550 149 R 40 40 1 1 B +X PE5/SPI_NSS 17 -1000 -200 148 R 40 40 1 1 B +X PD2[TIM2_CH3] 27 -1000 450 149 R 40 40 1 1 B +X UART1_CK/TIM1_CH1/PC1 18 1000 -200 149 L 40 40 1 1 B +X PD3/ADC_ETR/TIM2_CH2 28 -1000 350 149 R 40 40 1 1 B +X TIM1_CH2/PC2 19 1000 -300 149 L 40 40 1 1 B +X PD4/BEEP/TIM2_CH1 29 -1000 250 149 R 40 40 1 1 B +ENDDRAW +ENDDEF +# +# STM8S105K4T6C +# +DEF STM8S105K4T6C U 0 40 Y Y 1 F N +F0 "U" 0 1050 60 H V C CNN +F1 "STM8S105K4T6C" 50 -850 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS stm8s105* +$FPLIST + lqfp32* +$ENDFPLIST +DRAW +S -1100 950 1100 -750 0 1 0 N +X NRST 1 -1400 850 300 R 50 50 1 1 I +X OSCIN/PA1 2 -1400 750 300 R 50 50 1 1 T +X OSCOUT/PA2 3 -1400 650 300 R 50 50 1 1 T +X VSS 4 -1400 550 300 R 50 50 1 1 W +X VCAP 5 -1400 450 300 R 50 50 1 1 w +X VDD(3.3-5v) 6 -1400 350 300 R 50 50 1 1 W +X VDDio 7 -1400 250 300 R 50 50 1 1 W +X PF4/AIN12 8 -1400 150 300 R 50 50 1 1 T +X VDDA 9 -1400 50 300 R 50 50 1 1 W +X VSSA 10 -1400 -50 300 R 50 50 1 1 W +X PC3(HS)/TIM1_CH3 20 1400 -350 300 L 50 50 1 1 T +X PD5/UART2_TX 30 1400 650 300 L 50 50 1 1 T +X PB5/AIN5[I2X_SDA] 11 -1400 -150 300 R 50 50 1 1 T +X PC4(HS)/TIM1_CH4 21 1400 -250 300 L 50 50 1 1 T +X PD6/UART2_RX 31 1400 750 300 L 50 50 1 1 T +X PB4/AIN4[I2C_SCL] 12 -1400 -250 300 R 50 50 1 1 T +X PC5(HS)/SPI_SCK 22 1400 -150 300 L 50 50 1 1 T +X PD7/TLI[TIM1_CH4] 32 1400 850 300 L 50 50 1 1 T +X PB3/AIN3[TIM1_ETR] 13 -1400 -350 300 R 50 50 1 1 T +X PC6(HS)/SPI_MOSI 23 1400 -50 300 L 50 50 1 1 T +X PB2/AIN2[TIM1_CH3N] 14 -1400 -450 300 R 50 50 1 1 T +X PC7(HS)/SPI_MISO 24 1400 50 300 L 50 50 1 1 T +X PB1/AIN1_[TIM1_CH2N] 15 -1400 -550 300 R 50 50 1 1 T +X PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO] 25 1400 150 300 L 50 50 1 1 T +X PB0/AIN0_[TIM1_CH1N] 16 -1400 -650 300 R 50 50 1 1 T +X PD1(HS)/SWIM 26 1400 250 300 L 50 50 1 1 T +X PE5/SPI_NSS 17 1400 -650 300 L 50 50 1 1 T +X PD2(HS)/TIM3_CH1[TIM2_CH3] 27 1400 350 300 L 50 50 1 1 T +X PC1(HS)/TIM1_CH1 18 1400 -550 300 L 50 50 1 1 T +X PD3(HS)/TIM2_CH2[ADC_ETR] 28 1400 450 300 L 50 50 1 1 T +X PC2(HS)/TIM1_CH2 19 1400 -450 300 L 50 50 1 1 T +X PD4(HS)/TIM2_CH1[BEEP] 29 1400 550 300 L 50 50 1 1 T +ENDDRAW +ENDDEF +# +#End Library diff --git a/stepper_independent/stepper.c b/stepper_independent/stepper.c new file mode 100644 index 0000000..1f64bed --- /dev/null +++ b/stepper_independent/stepper.c @@ -0,0 +1,187 @@ +/* + * stepper.c + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "ports_definition.h" +#include "stepper.h" + +volatile int Nsteps[3]={0,0,0}; // Number of steps +U8 Motor_number = 5; // Number of motor to move, 5 -- not moving +U16 Stepper_speed[3] = {1000,1000,1000}; // length of one MICROstep in us +//U8* Timers[3] = {&TIM1_CR1, &TIM2_CR1, &TIM3_CR1}; +U8* Timers[3] = {0x5250, 0x5300, 0x5320}; + +#define pause_motor(N) *Timers[N] &= ~TIM_CR1_CEN +#define resume_motor(N) *Timers[N] |= TIM_CR1_CEN +#define check_motor(N) *Timers[N] & TIM_CR1_CEN +#define PPOUT(P, PIN) PORT(P, DDR) |= PIN; PORT(P, CR1) |= PIN +#define TMR(a, b) CONCAT(a , b) +#define TIMER_CONF(reg, val) TMR(TIM1, reg) = val; TMR(TIM2, reg) = val; TMR(TIM3, reg) = val; + +/** + * Setup pins of stepper motor (all - PP out) + */ +void setup_stepper_pins(){ + // CLK + PPOUT(STP0_CLK_PORT, STP0_CLK_PIN); + PPOUT(STP1_CLK_PORT, STP1_CLK_PIN); + PPOUT(STP2_CLK_PORT, STP2_CLK_PIN); + // DIR + PPOUT(STP0_DIR_PORT, STP0_DIR_PIN); + PPOUT(STP1_DIR_PORT, STP1_DIR_PIN); + PPOUT(STP2_DIR_PORT, STP2_DIR_PIN); + /**** TIMERS (all - 1MHz, default speed - 1000 Hz) ****/ + // Motor x - timer x+1 + TIM1_PSCRH = 0; // this timer have 16 bit prescaler + TIM1_PSCRL = 15; // LSB should be written last as it updates prescaler + TIM2_PSCR = 4; + TIM3_PSCR = 4; + // auto-reload each 1ms: TIM_ARR = 1000 = 0x03E8 + TIMER_CONF(ARRH, 0x03); + TIMER_CONF(ARRL, 0xE8); + // 50% duty cycle: TIM_CCR = 500 = 0x01F4 + TIMER_CONF(CCR1H, 0x01); + TIMER_CONF(CCR1L, 0xF4); + // channel 1 generates PWM pulses + TIMER_CONF(CCMR1, 0x60); // OC1M = 110b - PWM mode 1 ( 1 -> 0) + TIMER_CONF(CCER1, 1); // Channel 1 is on. Active is high + // interrupts: update + TIMER_CONF(IER, TIM_IER_UIE); + // auto-reload + interrupt on overflow + TIMER_CONF(CR1, TIM_CR1_APRE | TIM_CR1_URS); + // enable PWM output for timer1 + TIM1_BKR |= 0x80; // MOE +} + +/** + * Set speed of stepper motor + * @param Sps - period (in us) of one MICROstep + */ +void set_stepper_speed(U8 N, U16 SpS){ + U8 AH, AL, CH, CL; + if(N > 2) return; + Stepper_speed[N] = SpS; + AH = SpS >> 8; + AL = SpS & 0xff; + SpS >>= 1; // divide to 2 - 50% duty cycle + CH = SpS >> 8; + CL = SpS & 0xff; + switch(N){ + case 0: + TIM1_ARRH = AH; + TIM1_ARRL = AL; + TIM1_CCR1H = CH; + TIM1_CCR1L = CL; + break; + case 1: + TIM2_ARRH = AH; + TIM2_ARRL = AL; + TIM2_CCR1H = CH; + TIM2_CCR1L = CL; + break; + case 2: + TIM3_ARRH = AH; + TIM3_ARRL = AL; + TIM3_CCR1H = CH; + TIM3_CCR1L = CL; + break; + } +} + +/* +void add_steps(U8 N, int Steps){ + long NS; + U8 sign = 0; + if(N > 3) return; + // pause + pause_motor(N); + NS = Nsteps[N]; + if(PORT(STP_DIR_PORT, ODR) & STP_DIR_PIN == 0) + NS *= -1L; // direction to opposite side + NS += (long)Steps; + if(NS == 0){ // there's nothing to move + stop_motor(N); + return; + } + // now change direction + if(Nsteps < 0){ + uart_write("reverce\n"); + //??PORT(STP_DIR_PORT, ODR) ^= STP_DIR_PIN; // go to the opposite side + Nsteps *= -1L; + } + // resume + *resume_motor(N); +} +* */ + +void move_motor(U8 N, int Steps){ + if(N > 2) return; + pause_motor(N); + if(Steps < 0){// dir to left + switch(N){ + case 0: + PORT(STP0_DIR_PORT, ODR) &= ~STP0_DIR_PIN; + break; + case 1: + PORT(STP1_DIR_PORT, ODR) &= ~STP1_DIR_PIN; + break; + case 2: + PORT(STP2_DIR_PORT, ODR) &= ~STP2_DIR_PIN; + break; + } + Steps *= -1; + } + Nsteps[N] = Steps; + resume_motor(N); +} + +void stop_motor(U8 N){ + if(N > 2) return; + pause_motor(N); + switch(N){ // turn off DIR + case 0: + PORT(STP0_DIR_PORT, ODR) |= STP0_DIR_PIN; + break; + case 1: + PORT(STP1_DIR_PORT, ODR) |= STP1_DIR_PIN; + break; + case 2: + PORT(STP2_DIR_PORT, ODR) |= STP2_DIR_PIN; + break; + } + Nsteps[N] = 0; + uart_write("stop"); + printUint(&N, 1); +} + +void pause_resume(U8 N){ + if(N > 2) return; + if(Nsteps[N] == 0) return; // motor is stopped + if(check_motor(N)){ // motor is running - pause + pause_motor(N); + uart_write("pause"); + }else{ // resume + resume_motor(N); + uart_write("resume"); + } + printUint(&N, 1); +} + + diff --git a/stepper_independent/stepper.h b/stepper_independent/stepper.h new file mode 100644 index 0000000..e81644f --- /dev/null +++ b/stepper_independent/stepper.h @@ -0,0 +1,38 @@ +/* + * stepper.h + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __STEPPER_H__ +#define __STEPPER_H__ + +#include "ports_definition.h" +#include "main.h" + +extern volatile int Nsteps[]; +extern U16 Stepper_speed[]; + +void setup_stepper_pins(); +void set_stepper_speed(U8 N, U16 SpS); +void move_motor(U8 N, int Steps); +void stop_motor(U8 N); +void pause_resume(U8 N); + +#endif // __STEPPER_H__ diff --git a/stepper_independent/testproj.bin b/stepper_independent/testproj.bin new file mode 100644 index 0000000000000000000000000000000000000000..43e8fa73043c831607f8b75f1f254f89ca9fa1a4 GIT binary patch literal 3280 zcmZ`+U2Gf25#IaZ&mDCnMTtl2Z}&t=JUFs`64xo;^!HR5$jaA^<00G(pc}X8!#Fgx}4{rNdpiqOpv@l!}st~cW zdz6y23B{S4oB4KT_GWH}T0nD)3kabFwD>8|eW2d~tpjZUJpg(L^m`Y>aDRaNKLY&+ zXnO$_dVqR?M!&!m#^C-Xpd`>QfIbBJ^A~pN$EEe_V-E7`zI+m)3yCcUb?DNgAAj^G zqTT%2``OO;T~NjFtQ;7?I*yjl@JRv7Q6+<2|>8EArxAE4aGRXEUu7$2bA zc)jujG-1XEDL2L|7eV7;ypM8Yg5mv)>ul9ICUcB;Gfk>efK`ZbjdEkMx;6*AHg5#1 z;40rEtS?+~P?&hLRtTqbUwP^aUSv>HZMYsF9eY2)L1CM}O(m`rTho~hTrj~t9x}RANFv|e5 z41y&Sm^Vbrx5~%AZ#ziMTE6l)5pLwS1;Sx&r+R0nhW)n@8axIdnu!lGX{8JFb}jCt zJb(aR(^MvZ&SaU%+f>H>6!AMq0*9)cxn)Z2n|2N6gTTE{<5@D_avSO}{yr zLvy#rodBWPpcuLXFu()=zk4OK*e1~9M(FwrI;WGTZ(U~P-612KkMQE*e6cB_26_jpvS)L#r$!s~l-7!15+SK=N z+|h~Tid+L62ff`5UEN6+>)qNgCRMXN8;Zdj*={ylF*B%js>I&O#vp>$jLD{8s+;_d zNdu~8b44t)SUbkd^F7D{>Oz{%pARRnUhSKMBWzIGhl1 zQ1@EOYW={kEM=5s={8xWbKYo&2TQ~UsFUznA`^co7-|Y}(Af&~HOlZ~bblYg>VZTM z%Ly6#6W$63IbQ+Ya4#4ifpCOAl}Dg&!g2||ZYmo;NtR?0t7!(h!X-qdiPp5;l8aW8=`WaGC8&F_H$}X-OZC>FjP3JIsp9S&3+{D9-YEQ~ z09~;>QQCMX4BOSaFn7CNA5h_f#K92uz`-{16opkdI2B4i2jEVIPtvZ4W{Hn@oYcKp zCw-;@^CbQ4%3HusvNQZd@rSOV7?irD_-DdDhFym z*_eBeHvPYRBuuyNHA8goo(D*?v&EKXdnE!VaD>Znea(Pt@i7pC^tRHX`e;!hIl1}) zgq3T{6R<~CQvIhEZz@o>e*HYFtgv1zfpAuT7I+FOUOEdx8ie8pAdFMZFbHqxQQ(vG zRt9030{*sMy6BXCO(a!{MR3G@uItww$g>k&euy*>pjvSObcddx?n4~XTyxi+8C~xC zA2Y4Tb=7UZ>khOd6wIwp6brY}TLVETp(PYI=0DBQrOvy=tqaIsT}!89AZu}SItE5~ z_q6^Rltfw^sMc>pSzM8xeE+wa>K7-d-s0Iy!Gvevr2s*BZ`hX{7rOVpn)XY>K$tfdwE_qb$9~zKG&pfYP&E>C5U6#|=hNiDc z)47?U@8xE+vFWS1++}(4nndrWXL47k<#8~>^pI26BsM^X+yNpF4-OubCZ~Rw)2_|D z;RcaeJm!N*FEJ0u5JP;3vjS(6FODS!RRss^@$)f-1hCYiSpG2zVf0r6G ze-meMCa>LxMiajb>uXV^{A0GNOqVUiB;xzhN=q~aSyY6?eJrUyI#eTB;vqssGkGft z8JL_J!%><*j6^NL3}LZo`QRw@N6t$jB3cpC3%_&(h11(D?;2;y@RLUZw|)TophrEb zFD775ONS*!+ASf{*4M9k@{ifA*+dmF`WvYUhT6V04i2rDy=19nE4oA@%Dlqs!uq=( zdC+3e(vUZH2%!dW*p0hM5AGp- zxX*Q%-zIh)06GA80PM&6Nk8rRm zK@L;9UB=N(!9Il#*VQN}=njtK*yscqpeBap0XtB~QE2#C9H4x80w$Wg z$(zz9XZow^>6oIP$!|%qV?|493z^3XZHjqBJ@!vtJyPFMU&Jruw~no}9fcurWa&GZ Z6Z7!D1AIKfXY|iVrBPa=3hoI){{`uNbUgq7 literal 0 HcmV?d00001 diff --git a/stepper_independent_bin/Makefile b/stepper_independent_bin/Makefile new file mode 100644 index 0000000..b766c39 --- /dev/null +++ b/stepper_independent_bin/Makefile @@ -0,0 +1,34 @@ +NAME=testproj +SDCC=sdcc + +CCFLAGS=-DSTM8S105 -I../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx +LDFLAGS= -mstm8 --out-fmt-ihx -lstm8 +FLASHFLAGS=-cstlinkv2 -pstm8s105 + +SRC=$(wildcard *.c) +# ATTENTION: FIRST in list should be file with main() +OBJ=$(SRC:%.c=%.rel) +TRASH=$(OBJ) $(SRC:%.c=%.rst) $(SRC:%.c=%.asm) $(SRC:%.c=%.lst) +TRASH+=$(SRC:%.c=%.sym) $(NAME).ihx $(NAME).lk $(NAME).map +INDEPENDENT_HEADERS=../stm8l.h ports_definition.h Makefile + +all: $(NAME).ihx + +$(SRC) : %.c : %.h $(INDEPENDENT_HEADERS) + @touch $@ + +%.h: ; + +clean: + rm -f $(TRASH) + +load: $(NAME).ihx + stm8flash $(FLASHFLAGS) -w $(NAME).ihx + +%.rel: %.c + $(SDCC) $(CCFLAGS) -c $< + +$(NAME).ihx: $(OBJ) + $(SDCC) $(LDFLAGS) $(OBJ) -o $(NAME).ihx + +.PHONY: all diff --git a/stepper_independent_bin/README b/stepper_independent_bin/README new file mode 100644 index 0000000..82c5c4d --- /dev/null +++ b/stepper_independent_bin/README @@ -0,0 +1,26 @@ +This is a simple example of INDEPENDENT management of 3 stepper motors. + +You can connect up to 256 devices to common UART line +To work with them use simple protocol: + - each byte have 8 bits of data and nineth control bit + - inactive modules don't read bytes with nineth bit == 0, + only active module reads them + - all modules send data with nineth bit == 0 + - to activate module simple send its number with nineth bit == 1 + - you can change module number (value will be stored in flash memory) by command 'N' + and get its current number with command 'n' + +All motors have independent lines DIR and CLK and common line EN. +Motor selection performed by setting to 1 corresponding EN pin. +Communication with MCU realized through simple USB<->TTL converter. +Just connect lines Rx/Tx of converter to Tx/Rx of evaluation boart, +connect together lines GND and +3.3V. +Communication speed: 57600, proto: 8N1 +Comminication with MCU don't need special soft: you can even run screen session +or some terminal client like _com_. Another wariant is a simple client - client-term. +MCU itself can print to terminal a short help about its protocol, just sent letter 'h' +to it. + +You can connect up to 4 (5 for motor 0) end-point switches for each motor. +There's an ability to move till certain EP switches value, also you can move +motors infinitely (for now it realized only for all motors simultaneously). diff --git a/stepper_independent_bin/client-term/Makefile b/stepper_independent_bin/client-term/Makefile new file mode 100644 index 0000000..19bac1f --- /dev/null +++ b/stepper_independent_bin/client-term/Makefile @@ -0,0 +1,22 @@ +PROGRAM = client +LDFLAGS = +SRCS = client.c +CC = gcc +DEFINES = -D_XOPEN_SOURCE=501 +CXX = gcc +CFLAGS = -Wall -Werror $(DEFINES) +OBJS = $(SRCS:.c=.o) +all : $(PROGRAM) clean +$(PROGRAM) : $(OBJS) + $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(PROGRAM) + +# some addition dependencies +# %.o: %.c +# $(CC) $(LDFLAGS) $(CFLAGS) $< -o $@ +#$(SRCS) : %.c : %.h $(INDEPENDENT_HEADERS) +# @touch $@ + +clean: + /bin/rm -f *.o *~ +depend: + $(CXX) -MM $(CXX.SRCS) diff --git a/stepper_independent_bin/client-term/client.c b/stepper_independent_bin/client-term/client.c new file mode 100644 index 0000000..20d32a6 --- /dev/null +++ b/stepper_independent_bin/client-term/client.c @@ -0,0 +1,259 @@ +/* + * client.c - simple terminal client + * + * Copyright 2013 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include // tcsetattr +#include // tcsetattr, close, read, write +#include // ioctl +#include // printf, getchar, fopen, perror +#include // exit +#include // read +#include // read +#include // signal +#include // time +#include // memcpy +#include // int types +#include // gettimeofday + +#define CMSPAR 010000000000 + +double t0; // start time + +FILE *fout = NULL; // file for messages duplicating +char *comdev = "/dev/ttyUSB0"; +int BAUD_RATE = B57600; +struct termio oldtty, tty; // TTY flags +struct termios oldt, newt; // terminal flags +int comfd; // TTY fd + +/** + * function for different purposes that need to know time intervals + * @return double value: time in seconds + */ +double dtime(){ + double t; + struct timeval tv; + gettimeofday(&tv, NULL); + t = tv.tv_sec + ((double)tv.tv_usec)/1e6; + return t; +} + +/** + * Exit & return terminal to old state + * @param ex_stat - status (return code) + */ +void quit(int ex_stat){ + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // return terminal to previous state + ioctl(comfd, TCSANOW, &oldtty ); // return TTY to previous state + close(comfd); + if(fout) fclose(fout); + printf("Exit! (%d)\n", ex_stat); + exit(ex_stat); +} + +unsigned char crc(unsigned char data){ + unsigned char crc = data & 1; + unsigned int i; + for(i = 1; i<8; i++) crc ^= (data >> i) & 1; + return crc; +} + +/** + * Open & setup TTY, terminal + */ +void tty_init(){ + // terminal without echo + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + if(tcsetattr(STDIN_FILENO, TCSANOW, &newt) < 0) quit(-2); + printf("\nOpen port...\n"); + if ((comfd = open(comdev,O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0){ + fprintf(stderr,"Can't use port %s\n",comdev); + quit(1); + } + printf(" OK\nGet current settings...\n"); + if(ioctl(comfd,TCGETA,&oldtty) < 0) exit(-1); // Get settings + tty = oldtty; + tty.c_lflag = 0; // ~(ICANON | ECHO | ECHOE | ISIG) + tty.c_oflag = 0; + tty.c_iflag = 0; + tty.c_cflag = BAUD_RATE|CS8|CREAD|CLOCAL|PARENB; // we will emulate 9bit by PAR + tty.c_cc[VMIN] = 0; // non-canonical mode + tty.c_cc[VTIME] = 5; + if(ioctl(comfd,TCSETA,&tty) < 0) exit(-1); // set new mode + printf(" OK\n"); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); +} + +/** + * Read character from console without echo + * @return char readed + */ +int read_console(){ + int rb; + struct timeval tv; + int retval; + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(STDIN_FILENO, &rfds); + tv.tv_sec = 0; tv.tv_usec = 10000; + retval = select(1, &rfds, NULL, NULL, &tv); + if(!retval) rb = 0; + else { + if(FD_ISSET(STDIN_FILENO, &rfds)) rb = getchar(); + else rb = 0; + } + return rb; +} + +/** + * getchar() without echo + * wait until at least one character pressed + * @return character readed + */ +int mygetchar(){ // аналог getchar() без необходимости жать Enter + int ret; + do ret = read_console(); + while(ret == 0); + return ret; +} + +/** + * Read data from TTY + * @param buff (o) - buffer for data read + * @param length - buffer len + * @return amount of readed bytes + */ +size_t read_tty(uint8_t *buff, size_t length){ + ssize_t L = 0; + fd_set rfds; + struct timeval tv; + int retval; + FD_ZERO(&rfds); + FD_SET(comfd, &rfds); + tv.tv_sec = 0; tv.tv_usec = 10000; // wait for 10ms + retval = select(comfd + 1, &rfds, NULL, NULL, &tv); + if (!retval) return 0; + if(FD_ISSET(comfd, &rfds)){ + if((L = read(comfd, buff, length)) < 1) return 0; + } + return (size_t)L; +} + +void help(){ + printf("Use this commands:\n" + "H\tShow this help\n" + "D\tChange device number\n" + "q\tQuit\n" + ); +} + +#define dup_pr(...) do{printf(__VA_ARGS__); if(fout) fprintf(fout, __VA_ARGS__);}while(0) + +/** + * Set/reset nineth bit and send command + * @param + * @return + */ +void send_with_9(unsigned char cmd, int nineth){ + if(crc(cmd) ^ nineth) // (ODD CRC) XOR (set nineth) -> odd parity + tty.c_cflag |= PARODD; // odd parity + else + tty.c_cflag &= ~PARODD; // even parity + if(ioctl(comfd, TCSETA, &tty) < 0){ + perror("Ioctl"); + quit(2); + } + if(write(comfd, &cmd, 1) < 1){ + perror("Can't write to port"); + quit(2); + } +} + +void con_sig(int rb){ + if(rb < 1) return; + if(rb == 'q') quit(0); // q == exit + else if(rb == 'H'){ // this program help + help(); + return; + }else if(rb == 'D'){ // change device + int N; + printf("device number: "); + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // return terminal to previous state + scanf("%d", &N); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); // and again - no echo + if(N < 0 || N > 255){ + printf("\nWRONG DEVNUM!\n"); + return; + } + send_with_9((unsigned char)N, 1); // send marked byte with new device number + return; + } + send_with_9((unsigned char)rb, 0); // just send command with zero nineth bit +} + +/** + * Get integer value from buffer + * @param buff (i) - buffer with int + * @param len - length of data in buffer (could be 2 or 4) + * @return + */ +uint32_t get_int(uint8_t *buff, size_t len){ + if(len != 2 && len != 4){ + fprintf(stdout, "Bad data length!\n"); + return 0xffffffff; + } + uint32_t data = 0; + uint8_t *i8 = (uint8_t*) &data; + if(len == 2) memcpy(i8, buff, 2); + else memcpy(i8, buff, 4); + return data; +} + +int main(int argc, char *argv[]){ + int rb; + uint8_t buff[128]; + size_t L; + if(argc == 2){ + fout = fopen(argv[1], "a"); + if(!fout){ + perror("Can't open output file"); + exit(-1); + } + setbuf(fout, NULL); + } + tty_init(); + signal(SIGTERM, quit); // kill (-15) + signal(SIGINT, quit); // ctrl+C + signal(SIGQUIT, SIG_IGN); // ctrl+\ . + signal(SIGTSTP, SIG_IGN); // ctrl+Z + setbuf(stdout, NULL); + t0 = dtime(); + while(1){ + rb = read_console(); + if(rb > 0) con_sig(rb); + L = read_tty(buff, 127); + if(L){ + buff[L] = 0; + printf("%s", buff); + if(fout) fprintf(fout, "%zd\t%s\n", time(NULL), buff); + } + } +} diff --git a/stepper_independent_bin/interrupts.c b/stepper_independent_bin/interrupts.c new file mode 100644 index 0000000..808f506 --- /dev/null +++ b/stepper_independent_bin/interrupts.c @@ -0,0 +1,207 @@ +/* + * interrupts.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "ports_definition.h" +#include "main.h" +#include "stepper.h" + +#define TREG(N, R) TIM##N##_##R + +#define STPR_INTR(X) \ + if(TREG(X, SR1) & TIM_SR1_UIF){ \ + TREG(X, SR1) &= ~TIM_SR1_UIF; \ + if(Nsteps[X-1]){ \ + if(++usteps[X-1] == USteps){ \ + usteps[X-1] = 0; \ + if(!StepperInfty) \ + if(--Nsteps[X-1] == 0){ \ + stop_motor(X-1); \ + } \ + } \ + } \ + } + + +// Top Level Interrupt +INTERRUPT_HANDLER(TLI_IRQHandler, 0){} + +// Auto Wake Up Interrupt +INTERRUPT_HANDLER(AWU_IRQHandler, 1){} + +// Clock Controller Interrupt +INTERRUPT_HANDLER(CLK_IRQHandler, 2){} + +// External Interrupt PORTA +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3){ + check_EP(); +} + +// External Interrupt PORTB +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4){ + check_EP(); +} + +// External Interrupt PORTC +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5){ + check_EP(); +} + +// External Interrupt PORTD +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6){ + check_EP(); +} + +// External Interrupt PORTE +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7){ + check_EP(); +} + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8){} +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8){} + +// CAN TX Interrupt routine. +INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9){} +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_HANDLER(SPI_IRQHandler, 10){} + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11){ + STPR_INTR(1); +} + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12){} + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13){} + +// Timer5 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14){} + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13){ // generate pulses for stepper CLK + STPR_INTR(2); +} + +// Timer2 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14){ +} +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15){ + STPR_INTR(3); +} + +// Timer3 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16){} +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17){} + +// UART1 RX Interrupt +INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18){} +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_HANDLER(I2C_IRQHandler, 19){} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){} + +// UART2 RX interrupt +INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21){ + U8 rb; + if(UART2_SR & UART_SR_RXNE){ // data received + rb = UART2_DR; // read received byte & clear RXNE flag + //while(!(UART2_SR & UART_SR_TXE)); + // get marked byte? + if(UART2_CR1 & UART_CR1_R8){ // Master wanna change device? + if(rb != UART_devNUM){ // another device number + UART_is_our = 0; + UART2_CR2 &= ~UART_CR2_TEN; // disable transmitter + }else{ // our device + UART_is_our = 1; + UART2_CR2 |= UART_CR2_TEN; // enable transmitter + UART_send_byte('*'); // send '*' - we got the command + } + return; + } + if(!UART_is_our) return; // this isn't our business - !marked & !our + UART_send_byte(rb); // echo received symbol + UART_rx[UART_rx_cur_i++] = rb; // put received byte into cycled buffer + if(UART_rx_cur_i == UART_rx_start_i){ // Oops: buffer overflow! Just forget old data + UART_rx_start_i++; + check_UART_pointer(UART_rx_start_i); + } + check_UART_pointer(UART_rx_cur_i); + } +} +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20){} + +// UART3 RX interrupt +INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21){} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_HANDLER(ADC2_IRQHandler, 22){} +#else +// ADC1 interrupt +INTERRUPT_HANDLER(ADC1_IRQHandler, 22){ +} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23){} +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23){ + if(TIM4_SR & TIM_SR1_UIF){ // update interrupt + Global_time++; // increase timer + } + TIM4_SR = 0; // clear all interrupt flags +} +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24){} diff --git a/stepper_independent_bin/interrupts.h b/stepper_independent_bin/interrupts.h new file mode 100644 index 0000000..6edf384 --- /dev/null +++ b/stepper_independent_bin/interrupts.h @@ -0,0 +1,144 @@ +/* + * interrupts.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __INTERRUPTS_H__ +#define __INTERRUPTS_H__ + +#include "stm8l.h" + +// Top Level Interrupt +INTERRUPT_DEFINITION(TLI_IRQHandler, 0); + +// Auto Wake Up Interrupt +INTERRUPT_DEFINITION(AWU_IRQHandler, 1); + +// Clock Controller Interrupt +INTERRUPT_DEFINITION(CLK_IRQHandler, 2); + +// External Interrupt PORTA +INTERRUPT_DEFINITION(EXTI_PORTA_IRQHandler, 3); + +// External Interrupt PORTB +INTERRUPT_DEFINITION(EXTI_PORTB_IRQHandler, 4); + +// External Interrupt PORTC +INTERRUPT_DEFINITION(EXTI_PORTC_IRQHandler, 5); + +// External Interrupt PORTD +INTERRUPT_DEFINITION(EXTI_PORTD_IRQHandler, 6); + +// External Interrupt PORTE +INTERRUPT_DEFINITION(EXTI_PORTE_IRQHandler, 7); + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_DEFINITION(EXTI_PORTF_IRQHandler, 8); +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_DEFINITION(CAN_RX_IRQHandler, 8); + +// CAN TX Interrupt routine. +INTERRUPT_DEFINITION(CAN_TX_IRQHandler, 9); +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_DEFINITION(SPI_IRQHandler, 10); + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_DEFINITION(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_DEFINITION(TIM1_CAP_COM_IRQHandler, 12); + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_DEFINITION(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); + +// Timer5 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM5_CAP_COM_IRQHandler, 14); + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM2_UPD_OVF_BRK_IRQHandler, 13); + +// Timer2 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM2_CAP_COM_IRQHandler, 14); +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM3_UPD_OVF_BRK_IRQHandler, 15); + +// Timer3 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM3_CAP_COM_IRQHandler, 16); +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_DEFINITION(UART1_TX_IRQHandler, 17); + +// UART1 RX Interrupt +INTERRUPT_DEFINITION(UART1_RX_IRQHandler, 18); +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_DEFINITION(I2C_IRQHandler, 19); + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_DEFINITION(UART2_TX_IRQHandler, 20); + +// UART2 RX interrupt +INTERRUPT_DEFINITION(UART2_RX_IRQHandler, 21); +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_DEFINITION(UART3_TX_IRQHandler, 20); + +// UART3 RX interrupt +INTERRUPT_DEFINITION(UART3_RX_IRQHandler, 21); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_DEFINITION(ADC2_IRQHandler, 22); +#else // STM8S105, STM8S103 or STM8S903 or STM8AF626x +// ADC1 interrupt +INTERRUPT_DEFINITION(ADC1_IRQHandler, 22); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_DEFINITION(TIM6_UPD_OVF_TRG_IRQHandler, 23); +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_DEFINITION(TIM4_UPD_OVF_IRQHandler, 23); +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_DEFINITION(EEPROM_EEC_IRQHandler, 24); + +#endif // __INTERRUPTS_H__ diff --git a/stepper_independent_bin/main.c b/stepper_independent_bin/main.c new file mode 100644 index 0000000..becd600 --- /dev/null +++ b/stepper_independent_bin/main.c @@ -0,0 +1,392 @@ +/* + * blinky.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "ports_definition.h" +#include "interrupts.h" +#include "main.h" +#include "stepper.h" + +/* + * 0 0000 + * 1 0001 + * 2 0010 + * 3 0011 + * 4 0100 + * 5 0101 + * 6 0110 + * 7 0111 + * 8 1000 + * 9 1001 + * a 1010 + * b 1011 + * c 1100 + * d 1101 + * e 1110 + * f 1111 + */ + +unsigned long Global_time = 0L; // global time in ms +U16 paused_val = 500; // interval between LED flashing + +U8 UART_rx[UART_BUF_LEN]; // cycle buffer for received data +U8 UART_rx_start_i = 0; // started index of received data (from which reading starts) +U8 UART_rx_cur_i = 0; // index of current first byte in rx array (to which data will be written) +U8 UART_is_our = 0; // ==1 if we get UART +// ATTENTION! to change global variable in PROGRAM memory, it should be CONST!!! +const U8 UART_devNUM = THIS_DEVICE_NUM; // device number, master sais it + +/** + * Send one byte through UART + * @param byte - data to send + */ +void UART_send_byte(U8 byte){ + if(!UART_is_our) return; // don't use UART when we have no right! + //UART2_CR2 |= UART_CR2_TEN; // enable transmitter + UART2_DR = byte; + while(!(UART2_SR & UART_SR_TC)); + //UART2_CR2 &= ~UART_CR2_TEN; // disable transmitter +} + +void uart_write(char *str){ + if(!UART_is_our) return; // don't use UART when we have no right! + //UART2_CR2 |= UART_CR2_TEN; // enable transmitter + while(*str){ + UART2_DR = *str++; + while(!(UART2_SR & UART_SR_TC)); + } + //UART2_CR2 &= ~UART_CR2_TEN; // disable transmitter +} + + +/** + * Read one byte from Rx buffer + * @param byte - where to store readed data + * @return 1 in case of non-empty buffer + */ +U8 UART_read_byte(U8 *byte){ + if(UART_rx_start_i == UART_rx_cur_i) // buffer is empty + return 0; + *byte = UART_rx[UART_rx_start_i++]; + check_UART_pointer(UART_rx_start_i); + return 1; +} + +void printUint(U8 *val, U8 len){ + unsigned long Number = 0; + U8 i = len; + char ch; + U8 decimal_buff[12]; // max len of U32 == 10 + \n + \0 + if(len > 4 || len == 3 || len == 0) return; + for(i = 0; i < 12; i++) + decimal_buff[i] = 0; + decimal_buff[10] = '\n'; + ch = 9; + switch(len){ + case 1: + Number = *((U8*)val); + break; + case 2: + Number = *((U16*)val); + break; + case 4: + Number = *((unsigned long*)val); + break; + } + do{ + i = Number % 10L; + decimal_buff[ch--] = i + '0'; + Number /= 10L; + }while(Number && ch > -1); + uart_write((char*)&decimal_buff[ch+1]); +} +/* +U8 U8toHEX(U8 val){ + val &= 0x0f; + if(val < 10) val += '0'; + else val += 'a' - 10; + return val; +} + +void printUintHEX(U8 *val, U8 len){ + U8 i, V; + uart_write("0x"); + for(i = 0; i < len; i++){ + V = *val++; + UART_send_byte(U8toHEX(V>>4)); // MSB + UART_send_byte(U8toHEX(V)); // LSB + } + UART_send_byte('\n'); +}*/ + +U8 readInt(int *val){ + unsigned long T = Global_time; + unsigned long R = 0; + int readed; + U8 sign = 0, rb, ret = 0, bad = 0; + do{ + if(!UART_read_byte(&rb)) continue; + if(rb == '-' && R == 0){ // negative number + sign = 1; + continue; + } + if(rb < '0' || rb > '9') break; // number ends with any non-digit symbol that will be omitted + ret = 1; // there's at least one digit + R = R * 10L + rb - '0'; + if(R > 0x7fff){ // bad value + R = 0; + bad = 0; + } + }while(Global_time - T < 10000); // wait no longer than 10s + if(bad || !ret) return 0; + readed = (int) R; + if(sign) readed *= -1; + *val = readed; + return 1; +} + +void error_msg(char *msg){ + uart_write("\nERROR: "); + uart_write(msg); + UART_send_byte('\n'); +} + +/** + * read motor number + * @param N - readed Number + * @return 0 in case of error + */ +U8 get_motor_number(U8 *N){ + int Ival; + if(readInt(&Ival) && Ival > -1 && Ival < 3){ + *N = (U8) Ival; + UART_send_byte('*'); // OK + return 1; + }else{ + error_msg("bad motor"); + return 0; + } +} + +void show_uid(){ + uart_write("\nMCU ID:\n"); + printUintHEX(U_ID00, 12); +} + +/** + * Change variable stored in program memory + * !!! You can change only const values (non-constants are initializes on program start) + * @param addr - variable address + * @param new value + * @return 0 in case of error + */ +U8 change_progmem_value(U8 *addr, U8 val){ + // unlock memory + FLASH_PUKR = EEPROM_KEY2; + FLASH_PUKR = EEPROM_KEY1; + // check bit PUL=1 in FLASH_IAPSR + if(!FLASH_IAPSR & 0x02) + return 0; + *addr = val; + // clear PUL to lock write + FLASH_IAPSR &= ~0x02; + return 1; +} + +/* +U8 change_eeprom_value(U8 *addr, U8 val){ + // unlock memory + FLASH_DUKR = EEPROM_KEY1; + FLASH_DUKR = EEPROM_KEY2; + // check bit DUL=1 in FLASH_IAPSR + if(!FLASH_IAPSR & 0x08) + return 0; + *addr = val; + // clear DUL to lock write + FLASH_IAPSR &= ~0x08; + return 1; +} +*/ + +int main() { + unsigned long T = 0L; + int Ival; + U8 rb, Num; + + CFG_GCR |= 1; // disable SWIM + + // Configure clocking + CLK_CKDIVR = 0; // F_HSI = 16MHz, f_CPU = 16MHz + + // Timer 4 (8 bit) used as system tick timer + // prescaler == 128 (2^7), Tfreq = 125kHz + // period = 1ms, so ARR = 125 + TIM4_PSCR = 7; + TIM4_ARR = 125; + // interrupts: update + TIM4_IER = TIM_IER_UIE; + // auto-reload + interrupt on overflow + enable + TIM4_CR1 = TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN; + + // Configure pins + // PC2 - PP output (on-board LED) + PORT(LED_PORT, DDR) |= LED_PIN; + PORT(LED_PORT, CR1) |= LED_PIN; + // PD5 - UART2_TX -- pseudo open-drain output; don't forget an pullup resistor! + PORT(UART_PORT, DDR) |= UART_TX_PIN; + PORT(UART_PORT, ODR) |= UART_TX_PIN; // torn off N push-down + //PORT(UART_PORT, CR1) |= UART_TX_PIN; + + // Configure UART + // 9 bit, no parity, 1 stop (UART_CR3 = 0 - reset value) + // 57600 on 16MHz: BRR1=0x11, BRR2=0x06 + UART2_BRR1 = 0x11; UART2_BRR2 = 0x06; + UART2_CR1 = UART_CR1_M; // M = 1 -- 9bits + UART2_CR2 = UART_CR2_REN | UART_CR2_RIEN; // Allow RX, generate ints on rx + + setup_stepper_pins(); + + + // enable all interrupts + enableInterrupts(); + // Loop + do{ + if((Global_time - T > paused_val) || (T > Global_time)){ + T = Global_time; + PORT(LED_PORT, ODR) ^= LED_PIN; // blink on-board LED + } + if(UART_read_byte(&rb)){ // buffer isn't empty + switch(rb){ + case 'h': // help + case 'H': + uart_write("\nPROTO:\n" + "+/-\tLED period\n" + "Ex/ex\tset/get end-switches stored\n" + "p\tget HW end-switches\n" + "Mx\tstop on end-switch\n" + "Sx/sx\tset/get Mspeed\n" + "mx\tget steps\n" + "Px\tpause/resume\n" + "Xx\tstop\n" + "0..2N\tmove xth motor for N steps\n" + "=\tinfinity moving (after 0..2)" + "U/u\tset/get U-stepping\n" + "I\tget serial ID\n" + "N\tchange HW number\n" + "n\tshow HW number\n" + ); + break; + case 'I': // get serial id + show_uid(); + break; + case '+': + paused_val += 100; + if(paused_val > 10000) + paused_val = 500; // but not more than 10s + break; + case '-': + paused_val -= 100; + if(paused_val < 100) // but not less than 0.1s + paused_val = 500; + break; + case 'E': // set end-switches value + if(get_motor_number(&Num)){ + if(readInt(&Ival) && (Ival == (Ival & 0x1f))){ + if(Num) + EPs[Num] = Ival & 0x0f; // 4 bits in motors 1&2 + else + EPs[0] = Ival; // all 5 bits in motor 0 + }else + error_msg("bad EP"); + } + break; + case 'e': // get stored end-switches value + if(get_motor_number(&Num)){ + printUint(&EPs[Num], 1); + } + break; + case 'p': // get hardware end-switches value + if(get_motor_number(&Num)){ + Num = get_ep_value(Num); + printUint(&Num, 1); + } + break; + case 'S': // set stepper speed + if(get_motor_number(&Num)){ + if(readInt(&Ival) && Ival > MIN_STEP_LENGTH) + set_stepper_speed(Num, Ival); + else + error_msg("bad speed"); + } + break; + case 's': // get stepper speed + if(get_motor_number(&Num)) + printUint((U8*)&Stepper_speed[Num], 2); + break; + case 'M': // move till EP, you can call it before starting motor + if(get_motor_number(&Num)) + Stop_on_EP[Num] = 1; + break; + case 'm': // how much steps there is to the end of moving + if(get_motor_number(&Num)) + printUint((U8*)&Nsteps[Num], 2); + break; + case 'X': // stop + if(get_motor_number(&Num)) + stop_motor(Num); + break; + case 'P': // pause/resume + if(get_motor_number(&Num)) + pause_resume(Num); + break; + case 'N': + if(readInt(&Ival) && Ival > 0 && Ival < 256) + if(!change_progmem_value(&UART_devNUM, (unsigned int) Ival)) + error_msg("can't change val"); + break; + case 'n': // show HW num + printUint(&UART_devNUM, 1); + break; + case 'u': // show UStepping + printUint(&USteps, 1); + break; + case 'U': // set UStepping + if(readInt(&Ival) && Ival > 0 && Ival < 256) + USteps = Ival; + break; + case '=': // infinity moving: just don't decrement steps + StepperInfty = 1; + break; + default: + if(rb >= '0' && rb <= '2'){ // run motor + Num = rb - '0'; + if(readInt(&Ival) && Ival) + move_motor(Num, Ival); + else{ + error_msg("bad Nsteps"); + } + } + } + } + }while(1); +} + + diff --git a/stepper_independent_bin/main.h b/stepper_independent_bin/main.h new file mode 100644 index 0000000..7df79ed --- /dev/null +++ b/stepper_independent_bin/main.h @@ -0,0 +1,44 @@ +/* + * blinky.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __MAIN_H__ +#define __MAIN_H__ + +extern unsigned long Global_time; // global time in ms + +#define UART_BUF_LEN 8 // max 7 bytes transmited in on operation +#define MIN_STEP_LENGTH 9 // max speed, microseconds for one microstep +#define THIS_DEVICE_NUM 1 // hardware number (0..255) can be changed by writting into EEPROM + +extern U8 UART_rx[]; +extern U8 UART_rx_start_i; +extern U8 UART_rx_cur_i; +extern U8 UART_is_our; // ==1 if we get UART +extern const U8 UART_devNUM; + +void UART_send_byte(U8 byte); +void uart_write(char *str); +void printUint(U8 *val, U8 len); +void error_msg(char *msg); + +#define check_UART_pointer(x) if(x == UART_BUF_LEN) x = 0; + +#endif // __MAIN_H__ diff --git a/stepper_independent_bin/ports_definition.h b/stepper_independent_bin/ports_definition.h new file mode 100644 index 0000000..a680931 --- /dev/null +++ b/stepper_independent_bin/ports_definition.h @@ -0,0 +1,90 @@ +/* + * ports_definition.h - definition of ports pins & so on + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __PORTS_DEFINITION_H__ +#define __PORTS_DEFINITION_H__ + +#include "stm8l.h" + +// macro for using in port constructions like PORT(LED_PORT, ODR) = xx +#define CONCAT(a,b) a##_##b +#define PORT(a,b) CONCAT(a,b) + +// on-board LED +#define LED_PORT PC +#define LED_PIN GPIO_PIN2 + +// UART2_TX +#define UART_PORT PD +#define UART_TX_PIN GPIO_PIN5 + +/***** Stepper motor *****/ +// Clocking +#define STP0_CLK_PORT PC +#define STP0_CLK_PIN GPIO_PIN1 +#define STP1_CLK_PORT PD +#define STP1_CLK_PIN GPIO_PIN4 +#define STP2_CLK_PORT PD +#define STP2_CLK_PIN GPIO_PIN2 +// Direction +#define STP0_DIR_PORT PD +#define STP0_DIR_PIN GPIO_PIN0 +#define STP1_DIR_PORT PD +#define STP1_DIR_PIN GPIO_PIN7 +#define STP2_DIR_PORT PF +#define STP2_DIR_PIN GPIO_PIN4 +// Enable +#define STP0_EN_PORT PE +#define STP0_EN_PIN GPIO_PIN5 +#define STP1_EN_PORT PD +#define STP1_EN_PIN GPIO_PIN3 +#define STP2_EN_PORT PD +#define STP2_EN_PIN GPIO_PIN1 + +/** sensors for each motor **/ +// SETUP (interrupts: only falling edge; inputs: all with weak pull-up) +#define SETUP_EP(x) SET_EP ## x ## UP() + +// motor 0: PC3..PC7, 5EPs +#define SET_EP0UP() do{PORT(PC, CR2) |= 0xfc; PORT(PC, CR1) |= 0xfc; EXTI_CR1 |= 0x20;}while(0) +// motor 1: PB0..PB3, 4EPs +#define SET_EP1UP() do{PORT(PB, CR2) |= 0x0f; PORT(PB, CR1) |= 0x0f; EXTI_CR1 |= 0x08;}while(0) +// motor 2: PB4, PB5, PA1, PA2, 4EPs +#define SET_EP2UP() do{PORT(PB, CR2) |= 0x30; PORT(PA, CR2) |= 0x06; \ + PORT(PB, CR1) |= 0x30; PORT(PA, CR1) |= 0x06; EXTI_CR1 |= 0x0a; }while(0) + +/* +// motor 0: PC3..PC7, 5EPs +#define SET_EP0UP() do{PORT(PC, CR1) |= 0xfc; }while(0) +// motor 1: PB0..PB3, 4EPs +#define SET_EP1UP() do{PORT(PB, CR1) |= 0x0f; }while(0) +// motor 2: PB4, PB5, PA1, PA2, 4EPs +#define SET_EP2UP() do{PORT(PB, CR1) |= 0x30; PORT(PA, CR1) |= 0x06; }while(0) +*/ +// GET VALUE +#define READ_EP(x) GET_EP ## x ## _() +#define GET_EP0_() (( PORT(PC, IDR) >> 3 )) +#define GET_EP1_() (( PORT(PB, IDR) & 0x0f )) +#define GET_EP2_() (( ((PORT(PB,IDR) >> 4) & 0x03) | ((PORT(PA,IDR) << 1) & 0x0c) )) + + +#endif // __PORTS_DEFINITION_H__ diff --git a/stepper_independent_bin/schematic/kicad.kicad_pcb b/stepper_independent_bin/schematic/kicad.kicad_pcb new file mode 100644 index 0000000..97857c9 --- /dev/null +++ b/stepper_independent_bin/schematic/kicad.kicad_pcb @@ -0,0 +1,961 @@ +(kicad_pcb (version 3) (host pcbnew "(2013-feb-26)-stable") + + (general + (links 70) + (no_connects 70) + (area 0 0 0 0) + (thickness 1.6) + (drawings 0) + (tracks 0) + (zones 0) + (modules 15) + (nets 32) + ) + + (page A3) + (layers + (15 F.Cu signal) + (0 B.Cu signal) + (16 B.Adhes user) + (17 F.Adhes user) + (18 B.Paste user) + (19 F.Paste user) + (20 B.SilkS user) + (21 F.SilkS user) + (22 B.Mask user) + (23 F.Mask user) + (24 Dwgs.User user) + (25 Cmts.User user) + (26 Eco1.User user) + (27 Eco2.User user) + (28 Edge.Cuts user) + ) + + (setup + (last_trace_width 0.254) + (trace_clearance 0.254) + (zone_clearance 0.508) + (zone_45_only no) + (trace_min 0.254) + (segment_width 0.2) + (edge_width 0.15) + (via_size 0.889) + (via_drill 0.635) + (via_min_size 0.889) + (via_min_drill 0.508) + (uvia_size 0.508) + (uvia_drill 0.127) + (uvias_allowed no) + (uvia_min_size 0.508) + (uvia_min_drill 0.127) + (pcb_text_width 0.3) + (pcb_text_size 1 1) + (mod_edge_width 0.15) + (mod_text_size 1 1) + (mod_text_width 0.15) + (pad_size 1 1) + (pad_drill 0.6) + (pad_to_mask_clearance 0) + (aux_axis_origin 0 0) + (visible_elements FFFFFFBF) + (pcbplotparams + (layerselection 3178497) + (usegerberextensions true) + (excludeedgelayer true) + (linewidth 152400) + (plotframeref false) + (viasonmask false) + (mode 1) + (useauxorigin false) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15) + (hpglpenoverlay 2) + (psnegative false) + (psa4output false) + (plotreference true) + (plotvalue true) + (plotothertext true) + (plotinvisibletext false) + (padsonsilk false) + (subtractmaskfromsilk false) + (outputformat 1) + (mirror false) + (drillshape 1) + (scaleselection 1) + (outputdirectory "")) + ) + + (net 0 "") + (net 1 +3.3V) + (net 2 "/A DIR") + (net 3 /NRST) + (net 4 /OSC1IN) + (net 5 /OSC2IN) + (net 6 /PB0) + (net 7 /PB1) + (net 8 /PB2) + (net 9 /PB4) + (net 10 /PB5) + (net 11 /PC1) + (net 12 /PC2) + (net 13 /PC3) + (net 14 /PC4) + (net 15 /PC5) + (net 16 /PC6) + (net 17 /PC7) + (net 18 /PD0) + (net 19 /PD2) + (net 20 /PD3) + (net 21 /PD4) + (net 22 /PD5) + (net 23 /PD6) + (net 24 /PD7) + (net 25 /PE5) + (net 26 /PF4) + (net 27 /SWIM/PD1) + (net 28 GND) + (net 29 N-0000021) + (net 30 N-0000026) + (net 31 N-0000042) + + (net_class Default "This is the default net class." + (clearance 0.254) + (trace_width 0.254) + (via_dia 0.889) + (via_drill 0.635) + (uvia_dia 0.508) + (uvia_drill 0.127) + (add_net "") + (add_net +3.3V) + (add_net "/A DIR") + (add_net /NRST) + (add_net /OSC1IN) + (add_net /OSC2IN) + (add_net /PB0) + (add_net /PB1) + (add_net /PB2) + (add_net /PB4) + (add_net /PB5) + (add_net /PC1) + (add_net /PC2) + (add_net /PC3) + (add_net /PC4) + (add_net /PC5) + (add_net /PC6) + (add_net /PC7) + (add_net /PD0) + (add_net /PD2) + (add_net /PD3) + (add_net /PD4) + (add_net /PD5) + (add_net /PD6) + (add_net /PD7) + (add_net /PE5) + (add_net /PF4) + (add_net /SWIM/PD1) + (add_net GND) + (add_net N-0000021) + (add_net N-0000026) + (add_net N-0000042) + ) + + (module TQFP32 (layer F.Cu) (tedit 43A670DA) (tstamp 52FB46F3) + (at 239.268 53.34) + (path /52FB03A2) + (fp_text reference U1 (at 0 -1.27) (layer F.SilkS) + (effects (font (size 1.27 1.016) (thickness 0.2032))) + ) + (fp_text value STM8S105K4T6C (at 0 1.905) (layer F.SilkS) + (effects (font (size 1.27 1.016) (thickness 0.2032))) + ) + (fp_line (start 5.0292 2.7686) (end 3.8862 2.7686) (layer F.SilkS) (width 0.1524)) + (fp_line (start 5.0292 -2.7686) (end 3.9116 -2.7686) (layer F.SilkS) (width 0.1524)) + (fp_line (start 5.0292 2.7686) (end 5.0292 -2.7686) (layer F.SilkS) (width 0.1524)) + (fp_line (start 2.794 3.9624) (end 2.794 5.0546) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.8194 3.9878) (end -2.8194 5.0546) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.8448 5.0546) (end 2.794 5.08) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.794 -5.0292) (end 2.7178 -5.0546) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.8862 -3.2766) (end -3.8862 3.9116) (layer F.SilkS) (width 0.1524)) + (fp_line (start 2.7432 -5.0292) (end 2.7432 -3.9878) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.2512 -3.8862) (end 3.81 -3.8862) (layer F.SilkS) (width 0.1524)) + (fp_line (start 3.8608 3.937) (end 3.8608 -3.7846) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.8862 3.937) (end 3.7338 3.937) (layer F.SilkS) (width 0.1524)) + (fp_line (start -5.0292 -2.8448) (end -5.0292 2.794) (layer F.SilkS) (width 0.1524)) + (fp_line (start -5.0292 2.794) (end -3.8862 2.794) (layer F.SilkS) (width 0.1524)) + (fp_line (start -3.87604 -3.302) (end -3.29184 -3.8862) (layer F.SilkS) (width 0.1524)) + (fp_line (start -5.02412 -2.8448) (end -3.87604 -2.8448) (layer F.SilkS) (width 0.1524)) + (fp_line (start -2.794 -3.8862) (end -2.794 -5.03428) (layer F.SilkS) (width 0.1524)) + (fp_circle (center -2.83972 -2.86004) (end -2.43332 -2.60604) (layer F.SilkS) (width 0.1524)) + (pad 8 smd rect (at -4.81584 2.77622) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 26 /PF4) + ) + (pad 7 smd rect (at -4.81584 1.97612) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 6 smd rect (at -4.81584 1.17602) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 5 smd rect (at -4.81584 0.37592) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 30 N-0000026) + ) + (pad 4 smd rect (at -4.81584 -0.42418) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 3 smd rect (at -4.81584 -1.22428) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 5 /OSC2IN) + ) + (pad 2 smd rect (at -4.81584 -2.02438) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 4 /OSC1IN) + ) + (pad 1 smd rect (at -4.81584 -2.82448) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (pad 24 smd rect (at 4.7498 -2.8194) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 17 /PC7) + ) + (pad 17 smd rect (at 4.7498 2.794) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 25 /PE5) + ) + (pad 18 smd rect (at 4.7498 1.9812) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 11 /PC1) + ) + (pad 19 smd rect (at 4.7498 1.1684) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 12 /PC2) + ) + (pad 20 smd rect (at 4.7498 0.381) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 13 /PC3) + ) + (pad 21 smd rect (at 4.7498 -0.4318) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 14 /PC4) + ) + (pad 22 smd rect (at 4.7498 -1.2192) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 15 /PC5) + ) + (pad 23 smd rect (at 4.7498 -2.032) (size 1.99898 0.44958) + (layers F.Cu F.Paste F.Mask) + (net 16 /PC6) + ) + (pad 32 smd rect (at -2.82448 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 24 /PD7) + ) + (pad 31 smd rect (at -2.02692 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 23 /PD6) + ) + (pad 30 smd rect (at -1.22428 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 22 /PD5) + ) + (pad 29 smd rect (at -0.42672 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 21 /PD4) + ) + (pad 28 smd rect (at 0.37592 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 20 /PD3) + ) + (pad 27 smd rect (at 1.17348 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 19 /PD2) + ) + (pad 26 smd rect (at 1.97612 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 27 /SWIM/PD1) + ) + (pad 25 smd rect (at 2.77368 -4.826) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 18 /PD0) + ) + (pad 9 smd rect (at -2.8194 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 10 smd rect (at -2.032 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 11 smd rect (at -1.2192 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 10 /PB5) + ) + (pad 12 smd rect (at -0.4318 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 9 /PB4) + ) + (pad 13 smd rect (at 0.3556 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 2 "/A DIR") + ) + (pad 14 smd rect (at 1.1684 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 8 /PB2) + ) + (pad 15 smd rect (at 1.9812 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 7 /PB1) + ) + (pad 16 smd rect (at 2.794 4.7752) (size 0.44958 1.99898) + (layers F.Cu F.Paste F.Mask) + (net 6 /PB0) + ) + (model smd/tqfp32.wrl + (at (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM2010 (layer F.Cu) (tedit 4EFC4DD5) (tstamp 52FB4700) + (at 207.518 73.66) + (tags "CMS SM") + (path /52FB0F3B) + (attr smd) + (fp_text reference SW1 (at -0.50038 0 90) (layer F.SilkS) + (effects (font (size 0.70104 0.70104) (thickness 0.127))) + ) + (fp_text value SW_PUSH (at 0.8001 0 90) (layer F.SilkS) + (effects (font (size 0.70104 0.70104) (thickness 0.127))) + ) + (fp_line (start 3.50012 -1.6002) (end 3.50012 1.6002) (layer F.SilkS) (width 0.11938)) + (fp_line (start -3.50012 -1.6002) (end -3.50012 1.6002) (layer F.SilkS) (width 0.11938)) + (fp_text user + (at -4.30022 1.80086) (layer F.SilkS) + (effects (font (size 1.524 1.524) (thickness 0.29972))) + ) + (fp_line (start 1.19634 1.60528) (end 3.48234 1.60528) (layer F.SilkS) (width 0.11938)) + (fp_line (start 3.48234 -1.60528) (end 1.19634 -1.60528) (layer F.SilkS) (width 0.11938)) + (fp_line (start -1.19888 -1.60528) (end -3.48488 -1.60528) (layer F.SilkS) (width 0.11938)) + (fp_line (start -3.48488 1.60528) (end -1.19888 1.60528) (layer F.SilkS) (width 0.11938)) + (pad 1 smd rect (at -2.4003 0) (size 1.80086 2.70002) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 2 smd rect (at 2.4003 0) (size 1.80086 2.70002) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (model smd\chip_smd_pol_wide.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.35 0.35 0.35)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB470C) + (at 214.884 73.406) + (path /52FB0413) + (attr smd) + (fp_text reference C1 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 1u (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 30 N-0000026) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4718) + (at 220.98 73.406) + (path /52FB0426) + (attr smd) + (fp_text reference C2 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 104 (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4724) + (at 227.076 73.406) + (path /52FB0DD3) + (attr smd) + (fp_text reference D1 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value LED (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 31 N-0000042) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4730) + (at 233.172 73.406) + (path /52FB0DE2) + (attr smd) + (fp_text reference R1 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 1k (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 31 N-0000042) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 12 /PC2) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB473C) + (at 182.626 76.962) + (path /52FB0ECD) + (attr smd) + (fp_text reference D2 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value LED (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 29 N-0000021) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4748) + (at 188.722 76.962) + (path /52FB0ED3) + (attr smd) + (fp_text reference R2 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 1k (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 29 N-0000021) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4754) + (at 194.818 76.962) + (path /52FB0EFD) + (attr smd) + (fp_text reference R3 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 10k (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 1 +3.3V) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SM1206 (layer F.Cu) (tedit 42806E24) (tstamp 52FB4760) + (at 200.914 76.962) + (path /52FB0F99) + (attr smd) + (fp_text reference C3 (at 0 0) (layer F.SilkS) + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_text value 104 (at 0 0) (layer F.SilkS) hide + (effects (font (size 0.762 0.762) (thickness 0.127))) + ) + (fp_line (start -2.54 -1.143) (end -2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -2.54 1.143) (end -0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 0.889 -1.143) (end 2.54 -1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 -1.143) (end 2.54 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start 2.54 1.143) (end 0.889 1.143) (layer F.SilkS) (width 0.127)) + (fp_line (start -0.889 -1.143) (end -2.54 -1.143) (layer F.SilkS) (width 0.127)) + (pad 1 smd rect (at -1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 3 /NRST) + ) + (pad 2 smd rect (at 1.651 0) (size 1.524 2.032) + (layers F.Cu F.Paste F.Mask) + (net 28 GND) + ) + (model smd/chip_cms.wrl + (at (xyz 0 0 0)) + (scale (xyz 0.17 0.16 0.16)) + (rotate (xyz 0 0 0)) + ) + ) + + (module SIL-5 (layer F.Cu) (tedit 200000) (tstamp 52FB476E) + (at 187.452 73.66) + (descr "Connecteur 5 pins") + (tags "CONN DEV") + (path /52FB4AA7) + (fp_text reference P4 (at -0.635 -2.54) (layer F.SilkS) + (effects (font (size 1.72974 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_5 (at 0 -2.54) (layer F.SilkS) hide + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -7.62 1.27) (end -7.62 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -7.62 -1.27) (end 5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 -1.27) (end 5.08 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 1.27) (end -7.62 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 1 +3.3V) + ) + (pad 2 thru_hole circle (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 3 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 23 /PD6) + ) + (pad 4 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 22 /PD5) + ) + (pad 5 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + ) + + (module SIL-4 (layer F.Cu) (tedit 200000) (tstamp 52FB477D) + (at 198.12 73.66) + (descr "Connecteur 4 pibs") + (tags "CONN DEV") + (path /52FB0A49) + (fp_text reference P2 (at 0 -2.54) (layer F.SilkS) + (effects (font (size 1.73482 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_4 (at 0 -2.54) (layer F.SilkS) hide + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -5.08 -1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 -1.27) (end -5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -5.08 -1.27) (end 5.08 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 -1.27) (end 5.08 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 5.08 1.27) (end -5.08 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -2.54 1.27) (end -2.54 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 1 +3.3V) + ) + (pad 2 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 27 /SWIM/PD1) + ) + (pad 3 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 3 /NRST) + ) + (pad 4 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + ) + + (module SIL-14 (layer F.Cu) (tedit 200000) (tstamp 52FB4793) + (at 197.612 70.358) + (descr "Connecteur 14 pins") + (tags "CONN DEV") + (path /52FB0A6A) + (fp_text reference P1 (at -10.16 -2.54) (layer F.SilkS) + (effects (font (size 1.72974 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_14 (at 7.62 -2.54) (layer F.SilkS) + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -17.78 -1.27) (end 17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 -1.27) (end 17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 1.27) (end -17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -17.78 1.27) (end -17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 1 +3.3V) + ) + (pad 2 thru_hole circle (at -13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 3 thru_hole circle (at -11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 3 /NRST) + ) + (pad 4 thru_hole circle (at -8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 4 /OSC1IN) + ) + (pad 5 thru_hole circle (at -6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 5 /OSC2IN) + ) + (pad 6 thru_hole circle (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 26 /PF4) + ) + (pad 7 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 10 /PB5) + ) + (pad 8 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 9 /PB4) + ) + (pad 9 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 2 "/A DIR") + ) + (pad 10 thru_hole circle (at 6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 8 /PB2) + ) + (pad 11 thru_hole circle (at 8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 7 /PB1) + ) + (pad 12 thru_hole circle (at 11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 6 /PB0) + ) + (pad 13 thru_hole circle (at 13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 25 /PE5) + ) + (pad 14 thru_hole circle (at 16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 11 /PC1) + ) + ) + + (module SIL-14 (layer F.Cu) (tedit 200000) (tstamp 52FB47A9) + (at 233.68 70.358) + (descr "Connecteur 14 pins") + (tags "CONN DEV") + (path /52FB0A79) + (fp_text reference P3 (at -10.16 -2.54) (layer F.SilkS) + (effects (font (size 1.72974 1.08712) (thickness 0.3048))) + ) + (fp_text value CONN_14 (at 7.62 -2.54) (layer F.SilkS) + (effects (font (size 1.524 1.016) (thickness 0.3048))) + ) + (fp_line (start -17.78 -1.27) (end 17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 -1.27) (end 17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start 17.78 1.27) (end -17.78 1.27) (layer F.SilkS) (width 0.3048)) + (fp_line (start -17.78 1.27) (end -17.78 -1.27) (layer F.SilkS) (width 0.3048)) + (pad 1 thru_hole rect (at -16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 24 /PD7) + ) + (pad 2 thru_hole circle (at -13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 23 /PD6) + ) + (pad 3 thru_hole circle (at -11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 22 /PD5) + ) + (pad 4 thru_hole circle (at -8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 21 /PD4) + ) + (pad 5 thru_hole circle (at -6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 20 /PD3) + ) + (pad 6 thru_hole circle (at -3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 19 /PD2) + ) + (pad 7 thru_hole circle (at -1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 27 /SWIM/PD1) + ) + (pad 8 thru_hole circle (at 1.27 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 18 /PD0) + ) + (pad 9 thru_hole circle (at 3.81 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 17 /PC7) + ) + (pad 10 thru_hole circle (at 6.35 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 16 /PC6) + ) + (pad 11 thru_hole circle (at 8.89 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 15 /PC5) + ) + (pad 12 thru_hole circle (at 11.43 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 14 /PC4) + ) + (pad 13 thru_hole circle (at 13.97 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 13 /PC3) + ) + (pad 14 thru_hole circle (at 16.51 0) (size 1.397 1.397) (drill 0.8128) + (layers *.Cu *.Mask F.SilkS) + (net 12 /PC2) + ) + ) + + (module DB25FC (layer F.Cu) (tedit 200000) (tstamp 52FB47DC) + (at 206.502 66.04) + (descr "Connecteur DB25 femelle couche") + (tags "CONN DB25") + (path /52FB403E) + (fp_text reference J1 (at 0 -15.24) (layer F.SilkS) + (effects (font (size 1.524 1.524) (thickness 0.3048))) + ) + (fp_text value DB25 (at 0 -6.35) (layer F.SilkS) + (effects (font (size 1.524 1.524) (thickness 0.3048))) + ) + (fp_line (start 26.67 -11.43) (end 26.67 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start 19.05 -6.35) (end 19.05 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start 20.955 -11.43) (end 20.955 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.955 -11.43) (end -20.955 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start -19.05 -6.35) (end -19.05 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 2.54) (end -26.67 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start 26.67 -6.35) (end 19.05 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 -6.35) (end -19.05 -6.35) (layer F.SilkS) (width 0.3048)) + (fp_line (start 20.32 -8.255) (end 20.32 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -8.255) (end -20.32 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start 20.32 -18.415) (end 20.32 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -18.415) (end -20.32 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start 26.67 -11.43) (end 26.67 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start 26.67 -12.7) (end -26.67 -12.7) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 -12.7) (end -26.67 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 -11.43) (end 26.67 -11.43) (layer F.SilkS) (width 0.3048)) + (fp_line (start 19.05 2.54) (end 26.67 2.54) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -8.255) (end 20.32 -8.255) (layer F.SilkS) (width 0.3048)) + (fp_line (start -20.32 -18.415) (end 20.32 -18.415) (layer F.SilkS) (width 0.3048)) + (fp_line (start -26.67 2.54) (end -19.05 2.54) (layer F.SilkS) (width 0.3048)) + (pad "" thru_hole circle (at 23.495 -1.27) (size 3.81 3.81) (drill 3.048) + (layers *.Cu *.Mask F.SilkS) + ) + (pad "" thru_hole circle (at -23.495 -1.27) (size 3.81 3.81) (drill 3.048) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 1 thru_hole rect (at -16.51 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 2 thru_hole circle (at -13.716 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 11 /PC1) + ) + (pad 3 thru_hole circle (at -11.049 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 6 /PB0) + ) + (pad 4 thru_hole circle (at -8.255 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 21 /PD4) + ) + (pad 5 thru_hole circle (at -5.461 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 7 /PB1) + ) + (pad 6 thru_hole circle (at -2.667 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 19 /PD2) + ) + (pad 7 thru_hole circle (at 0 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 8 /PB2) + ) + (pad 8 thru_hole circle (at 2.794 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 9 thru_hole circle (at 5.588 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 2 "/A DIR") + ) + (pad 10 thru_hole circle (at 8.382 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 11 thru_hole circle (at 11.049 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 12 thru_hole circle (at 13.843 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 13 thru_hole circle (at 16.637 1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 14 thru_hole circle (at -14.9352 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 15 thru_hole circle (at -12.3952 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 16 thru_hole circle (at -9.6012 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 17 thru_hole circle (at -6.858 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + ) + (pad 18 thru_hole circle (at -4.1148 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 19 thru_hole circle (at -1.3208 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 20 thru_hole circle (at 1.4224 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 21 thru_hole circle (at 4.1656 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 22 thru_hole circle (at 7.0104 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 23 thru_hole circle (at 9.7028 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 24 thru_hole circle (at 12.446 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (pad 25 thru_hole circle (at 15.24 -1.27) (size 1.524 1.524) (drill 1.016) + (layers *.Cu *.Mask F.SilkS) + (net 28 GND) + ) + (model conn_DBxx/db25_female_pin90deg.wrl + (at (xyz 0 0 0)) + (scale (xyz 1 1 1)) + (rotate (xyz 0 0 0)) + ) + ) + +) diff --git a/stepper_independent_bin/schematic/kicad.pro b/stepper_independent_bin/schematic/kicad.pro new file mode 100644 index 0000000..6affc30 --- /dev/null +++ b/stepper_independent_bin/schematic/kicad.pro @@ -0,0 +1,82 @@ +update=Вт 11 фев 2014 17:26:13 +version=1 +last_client=eeschema +[cvpcb] +version=1 +NetIExt=net +[cvpcb/libraries] +EquName1=devcms +[pcbnew] +version=1 +LastNetListRead= +PadDrlX=320 +PadDimH=550 +PadDimV=550 +BoardThickness=620 +TxtPcbV=600 +TxtPcbH=600 +TxtModV=500 +TxtModH=500 +TxtModW=100 +VEgarde=100 +DrawLar=120 +EdgeLar=80 +TxtLar=120 +MSegLar=120 +[pcbnew/libraries] +LibDir= +LibName1=sockets +LibName2=connect +LibName3=discret +LibName4=pin_array +LibName5=divers +LibName6=libcms +LibName7=display +LibName8=led +LibName9=dip_sockets +LibName10=pga_sockets +LibName11=valves +[general] +version=1 +[eeschema] +version=1 +LibDir= +NetFmtName= +RptD_X=0 +RptD_Y=100 +RptLab=1 +LabSize=60 +[eeschema/libraries] +LibName1=power +LibName2=device +LibName3=transistors +LibName4=conn +LibName5=linear +LibName6=regul +LibName7=74xx +LibName8=cmos4000 +LibName9=adc-dac +LibName10=memory +LibName11=xilinx +LibName12=special +LibName13=microcontrollers +LibName14=dsp +LibName15=microchip +LibName16=analog_switches +LibName17=motorola +LibName18=texas +LibName19=intel +LibName20=audio +LibName21=interface +LibName22=digital-audio +LibName23=philips +LibName24=display +LibName25=cypress +LibName26=siliconi +LibName27=opto +LibName28=atmel +LibName29=contrib +LibName30=valves +LibName31=stm8 +LibName32=st-microelectronics +LibName33=stm8s105k4t6c diff --git a/stepper_independent_bin/schematic/stepper-cache.dcm b/stepper_independent_bin/schematic/stepper-cache.dcm new file mode 100644 index 0000000..91e08e9 --- /dev/null +++ b/stepper_independent_bin/schematic/stepper-cache.dcm @@ -0,0 +1,8 @@ +EESchema-DOCLIB Version 2.0 Date: Ср 26 фев 2014 17:45:20 +# +$CMP CONN_5_ +D Symbole general de connecteur +K CONN +$ENDCMP +# +#End Doc Library diff --git a/stepper_independent_bin/schematic/stepper-cache.lib b/stepper_independent_bin/schematic/stepper-cache.lib new file mode 100644 index 0000000..3d2f48b --- /dev/null +++ b/stepper_independent_bin/schematic/stepper-cache.lib @@ -0,0 +1,253 @@ +EESchema-LIBRARY Version 2.3 Date: Пн 03 мар 2014 17:27:22 +#encoding utf-8 +# +# +3.3V +# +DEF +3.3V #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -40 30 H I C CNN +F1 "+3.3V" 0 110 30 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS +3,3V +DRAW +X +3.3V 1 0 0 0 U 30 30 0 0 W N +C 0 60 20 0 1 0 N +P 3 0 1 0 0 0 0 40 0 40 N +ENDDRAW +ENDDEF +# +# C +# +DEF C C 0 10 N Y 1 F N +F0 "C" 0 100 40 H V L CNN +F1 "C" 6 -85 40 H V L CNN +F2 "~" 38 -150 30 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + SM* + C? + C1-1 +$ENDFPLIST +DRAW +P 2 0 1 20 -80 -30 80 -30 N +P 2 0 1 20 -80 30 80 30 N +X ~ 1 0 200 170 D 40 40 1 1 P +X ~ 2 0 -200 170 U 40 40 1 1 P +ENDDRAW +ENDDEF +# +# CONN_14 +# +DEF CONN_14 P 0 40 Y N 1 F N +F0 "P" -30 0 60 V V C CNN +F1 "CONN_14" 80 0 60 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 700 150 -700 0 1 0 N +X P1 1 -350 650 250 R 50 50 1 1 P I +X P2 2 -350 550 250 R 50 50 1 1 P I +X P3 3 -350 450 250 R 50 50 1 1 P I +X P4 4 -350 350 250 R 50 50 1 1 P I +X P5 5 -350 250 250 R 50 50 1 1 P I +X P6 6 -350 150 250 R 50 50 1 1 P I +X P7 7 -350 50 250 R 50 50 1 1 P I +X P8 8 -350 -50 250 R 50 50 1 1 P I +X P9 9 -350 -150 250 R 50 50 1 1 P I +X P10 10 -350 -250 250 R 50 50 1 1 P I +X P11 11 -350 -350 250 R 50 50 1 1 P I +X P12 12 -350 -450 250 R 50 50 1 1 P I +X P13 13 -350 -550 250 R 50 50 1 1 P I +X P14 14 -350 -650 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_3 +# +DEF CONN_3 K 0 40 Y N 1 F N +F0 "K" -50 0 50 V V C CNN +F1 "CONN_3" 50 0 40 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 150 100 -150 0 1 0 N +X P1 1 -350 100 250 R 60 60 1 1 P I +X PM 2 -350 0 250 R 60 60 1 1 P I +X P3 3 -350 -100 250 R 60 60 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_4 +# +DEF CONN_4 P 0 40 Y N 1 F N +F0 "P" -50 0 50 V V C CNN +F1 "CONN_4" 50 0 50 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 200 100 -200 0 1 0 N +X P1 1 -350 150 250 R 50 50 1 1 P I +X P2 2 -350 50 250 R 50 50 1 1 P I +X P3 3 -350 -50 250 R 50 50 1 1 P I +X P4 4 -350 -150 250 R 50 50 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_5 +# +DEF CONN_5 P 0 40 Y Y 1 F N +F0 "P" -50 0 50 V V C CNN +F1 "CONN_5" 50 0 50 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 250 100 -250 0 1 0 f +X ~ 1 -400 200 300 R 60 60 1 1 P I +X ~ 2 -400 100 300 R 60 60 1 1 P I +X ~ 3 -400 0 300 R 60 60 1 1 P I +X ~ 4 -400 -100 300 R 60 60 1 1 P I +X ~ 5 -400 -200 300 R 60 60 1 1 P I +ENDDRAW +ENDDEF +# +# CONN_5_ +# +DEF CONN_5_ P 0 40 Y Y 1 F N +F0 "P" 50 -300 50 H V C CNN +F1 "CONN_5_" 150 0 50 V V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -100 250 200 -250 0 1 0 f +X ~ 1 -400 200 300 R 60 60 1 1 w I +X ~ 2 -400 100 300 R 60 60 1 1 w I +X ~ 3 -400 0 300 R 60 60 1 1 O I +X ~ 4 -400 -100 300 R 60 60 1 1 I I +X ~ 5 -400 -200 300 R 60 60 1 1 w I +ENDDRAW +ENDDEF +# +# GND +# +DEF ~GND #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 0 30 H I C CNN +F1 "GND" 0 -70 30 H I C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N +X GND 1 0 0 0 U 30 30 1 1 W N +ENDDRAW +ENDDEF +# +# LED +# +DEF LED D 0 40 Y N 1 F N +F0 "D" 0 100 50 H V C CNN +F1 "LED" 0 -100 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + LED-3MM + LED-5MM + LED-10MM + LED-0603 + LED-0805 + LED-1206 + LEDV +$ENDFPLIST +DRAW +P 2 0 1 0 50 50 50 -50 N +P 3 0 1 0 -50 50 50 0 -50 -50 F +P 3 0 1 0 65 -40 110 -80 105 -55 N +P 3 0 1 0 80 -25 125 -65 120 -40 N +X A 1 -200 0 150 R 40 40 1 1 P +X K 2 200 0 150 L 40 40 1 1 P +ENDDRAW +ENDDEF +# +# R +# +DEF R R 0 0 N Y 1 F N +F0 "R" 80 0 40 V V C CNN +F1 "R" 7 1 40 V V C CNN +F2 "~" -70 0 30 V V C CNN +F3 "~" 0 0 30 H V C CNN +$FPLIST + R? + SM0603 + SM0805 + R?-* + SM1206 +$ENDFPLIST +DRAW +S -40 150 40 -150 0 1 12 N +X ~ 1 0 250 100 D 60 60 1 1 P +X ~ 2 0 -250 100 U 60 60 1 1 P +ENDDRAW +ENDDEF +# +# STM8S105K4T6C +# +DEF STM8S105K4T6C U 0 40 Y Y 1 F N +F0 "U" 0 1050 60 H V C CNN +F1 "STM8S105K4T6C" 50 -850 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS stm8s105* +$FPLIST + lqfp32* +$ENDFPLIST +DRAW +S -1100 950 1100 -750 0 1 0 N +X NRST 1 -1400 850 300 R 50 50 1 1 I +X OSCIN/PA1 2 -1400 750 300 R 50 50 1 1 T +X OSCOUT/PA2 3 -1400 650 300 R 50 50 1 1 T +X VSS 4 -1400 550 300 R 50 50 1 1 W +X VCAP 5 -1400 450 300 R 50 50 1 1 w +X VDD(3.3-5v) 6 -1400 350 300 R 50 50 1 1 W +X VDDio 7 -1400 250 300 R 50 50 1 1 W +X PF4/AIN12 8 -1400 150 300 R 50 50 1 1 T +X VDDA 9 -1400 50 300 R 50 50 1 1 W +X VSSA 10 -1400 -50 300 R 50 50 1 1 W +X PC3(HS)/TIM1_CH3 20 1400 -350 300 L 50 50 1 1 T +X PD5/UART2_TX 30 1400 650 300 L 50 50 1 1 T +X PB5/AIN5[I2X_SDA] 11 -1400 -150 300 R 50 50 1 1 T +X PC4(HS)/TIM1_CH4 21 1400 -250 300 L 50 50 1 1 T +X PD6/UART2_RX 31 1400 750 300 L 50 50 1 1 T +X PB4/AIN4[I2C_SCL] 12 -1400 -250 300 R 50 50 1 1 T +X PC5(HS)/SPI_SCK 22 1400 -150 300 L 50 50 1 1 T +X PD7/TLI[TIM1_CH4] 32 1400 850 300 L 50 50 1 1 T +X PB3/AIN3[TIM1_ETR] 13 -1400 -350 300 R 50 50 1 1 T +X PC6(HS)/SPI_MOSI 23 1400 -50 300 L 50 50 1 1 T +X PB2/AIN2[TIM1_CH3N] 14 -1400 -450 300 R 50 50 1 1 T +X PC7(HS)/SPI_MISO 24 1400 50 300 L 50 50 1 1 T +X PB1/AIN1_[TIM1_CH2N] 15 -1400 -550 300 R 50 50 1 1 T +X PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO] 25 1400 150 300 L 50 50 1 1 T +X PB0/AIN0_[TIM1_CH1N] 16 -1400 -650 300 R 50 50 1 1 T +X PD1(HS)/SWIM 26 1400 250 300 L 50 50 1 1 T +X PE5/SPI_NSS 17 1400 -650 300 L 50 50 1 1 T +X PD2(HS)/TIM3_CH1[TIM2_CH3] 27 1400 350 300 L 50 50 1 1 T +X PC1(HS)/TIM1_CH1 18 1400 -550 300 L 50 50 1 1 T +X PD3(HS)/TIM2_CH2[ADC_ETR] 28 1400 450 300 L 50 50 1 1 T +X PC2(HS)/TIM1_CH2 19 1400 -450 300 L 50 50 1 1 T +X PD4(HS)/TIM2_CH1[BEEP] 29 1400 550 300 L 50 50 1 1 T +ENDDRAW +ENDDEF +# +# SW_PUSH +# +DEF SW_PUSH SW 0 40 N N 1 F N +F0 "SW" 150 110 50 H V C CNN +F1 "SW_PUSH" 0 -80 50 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +DRAW +S -170 50 170 60 0 1 0 N +P 4 0 1 0 -40 60 -30 90 30 90 40 60 N +X 1 1 -300 0 200 R 60 60 0 1 P I +X 2 2 300 0 200 L 60 60 0 1 P I +ENDDRAW +ENDDEF +# +#End Library diff --git a/stepper_independent_bin/schematic/stepper.cmp b/stepper_independent_bin/schematic/stepper.cmp new file mode 100644 index 0000000..90be011 --- /dev/null +++ b/stepper_independent_bin/schematic/stepper.cmp @@ -0,0 +1,108 @@ +Cmp-Mod V01 Created by CvPcb (2013-feb-26)-stable date = Ср 12 фев 2014 14:01:35 + +BeginCmp +TimeStamp = /52FB0413; +Reference = C1; +ValeurCmp = 1u; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0426; +Reference = C2; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F99; +Reference = C3; +ValeurCmp = 104; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0DD3; +Reference = D1; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ECD; +Reference = D2; +ValeurCmp = LED; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB403E; +Reference = J1; +ValeurCmp = DB25; +IdModule = DB25FC; +EndCmp + +BeginCmp +TimeStamp = /52FB0A6A; +Reference = P1; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB0A49; +Reference = P2; +ValeurCmp = CONN_4; +IdModule = SIL-4; +EndCmp + +BeginCmp +TimeStamp = /52FB0A79; +Reference = P3; +ValeurCmp = CONN_14; +IdModule = SIL-14; +EndCmp + +BeginCmp +TimeStamp = /52FB4AA7; +Reference = P4; +ValeurCmp = CONN_5; +IdModule = SIL-5; +EndCmp + +BeginCmp +TimeStamp = /52FB0DE2; +Reference = R1; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0ED3; +Reference = R2; +ValeurCmp = 1k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0EFD; +Reference = R3; +ValeurCmp = 10k; +IdModule = SM1206; +EndCmp + +BeginCmp +TimeStamp = /52FB0F3B; +Reference = SW1; +ValeurCmp = SW_PUSH; +IdModule = SM2010; +EndCmp + +BeginCmp +TimeStamp = /52FB03A2; +Reference = U1; +ValeurCmp = STM8S105K4T6C; +IdModule = TQFP32; +EndCmp + +EndListe diff --git a/stepper_independent_bin/schematic/stepper.net b/stepper_independent_bin/schematic/stepper.net new file mode 100644 index 0000000..818b2b3 --- /dev/null +++ b/stepper_independent_bin/schematic/stepper.net @@ -0,0 +1,415 @@ +(export (version D) + (design + (source /home/eddy/Docs/SAO/ELECTRONICS/STM8/stepper_independent/schematic/stepper.sch) + (date "Ср 12 фев 2014 14:00:57") + (tool "eeschema (2013-feb-26)-stable")) + (components + (comp (ref U1) + (value STM8S105K4T6C) + (libsource (lib stm8s105k4t6c) (part STM8S105K4T6C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB03A2)) + (comp (ref C1) + (value 1u) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0413)) + (comp (ref C2) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0426)) + (comp (ref P2) + (value CONN_4) + (libsource (lib conn) (part CONN_4)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A49)) + (comp (ref P1) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A6A)) + (comp (ref P3) + (value CONN_14) + (libsource (lib conn) (part CONN_14)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0A79)) + (comp (ref D1) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DD3)) + (comp (ref R1) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0DE2)) + (comp (ref D2) + (value LED) + (libsource (lib device) (part LED)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ECD)) + (comp (ref R2) + (value 1k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0ED3)) + (comp (ref R3) + (value 10k) + (libsource (lib device) (part R)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0EFD)) + (comp (ref SW1) + (value SW_PUSH) + (libsource (lib device) (part SW_PUSH)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F3B)) + (comp (ref C3) + (value 104) + (libsource (lib device) (part C)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB0F99)) + (comp (ref J1) + (value DB25) + (libsource (lib conn) (part DB25)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB403E)) + (comp (ref P4) + (value CONN_5) + (libsource (lib conn) (part CONN_5)) + (sheetpath (names /) (tstamps /)) + (tstamp 52FB4AA7))) + (libparts + (libpart (lib device) (part C) + (description "Condensateur non polarise") + (footprints + (fp SM*) + (fp C?) + (fp C1-1)) + (fields + (field (name Reference) C) + (field (name Value) C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part LED) + (footprints + (fp LED-3MM) + (fp LED-5MM) + (fp LED-10MM) + (fp LED-0603) + (fp LED-0805) + (fp LED-1206) + (fp LEDV)) + (fields + (field (name Reference) D) + (field (name Value) LED) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name A) (type passive)) + (pin (num 2) (name K) (type passive)))) + (libpart (lib device) (part R) + (description Resistance) + (footprints + (fp R?) + (fp SM0603) + (fp SM0805) + (fp R?-*) + (fp SM1206)) + (fields + (field (name Reference) R) + (field (name Value) R) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive)))) + (libpart (lib device) (part SW_PUSH) + (description "Push Button") + (fields + (field (name Reference) SW) + (field (name Value) SW_PUSH) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name 1) (type passive)) + (pin (num 2) (name 2) (type passive)))) + (libpart (lib conn) (part CONN_14) + (description "Symbole general de connexion") + (fields + (field (name Reference) P) + (field (name Value) CONN_14)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)) + (pin (num 5) (name P5) (type passive)) + (pin (num 6) (name P6) (type passive)) + (pin (num 7) (name P7) (type passive)) + (pin (num 8) (name P8) (type passive)) + (pin (num 9) (name P9) (type passive)) + (pin (num 10) (name P10) (type passive)) + (pin (num 11) (name P11) (type passive)) + (pin (num 12) (name P12) (type passive)) + (pin (num 13) (name P13) (type passive)) + (pin (num 14) (name P14) (type passive)))) + (libpart (lib conn) (part CONN_4) + (description "Symbole general de connecteur") + (fields + (field (name Reference) P) + (field (name Value) CONN_4)) + (pins + (pin (num 1) (name P1) (type passive)) + (pin (num 2) (name P2) (type passive)) + (pin (num 3) (name P3) (type passive)) + (pin (num 4) (name P4) (type passive)))) + (libpart (lib conn) (part DB25) + (footprints + (fp DB25*)) + (fields + (field (name Reference) J) + (field (name Value) DB25)) + (pins + (pin (num 1) (name 1) (type passive)) + (pin (num 2) (name 2) (type passive)) + (pin (num 3) (name 3) (type passive)) + (pin (num 4) (name 4) (type passive)) + (pin (num 5) (name 5) (type passive)) + (pin (num 6) (name 6) (type passive)) + (pin (num 7) (name 7) (type passive)) + (pin (num 8) (name 8) (type passive)) + (pin (num 9) (name 9) (type passive)) + (pin (num 10) (name 10) (type passive)) + (pin (num 11) (name 11) (type passive)) + (pin (num 12) (name 12) (type passive)) + (pin (num 13) (name 13) (type passive)) + (pin (num 14) (name P14) (type passive)) + (pin (num 15) (name P15) (type passive)) + (pin (num 16) (name P16) (type passive)) + (pin (num 17) (name P17) (type passive)) + (pin (num 18) (name P18) (type passive)) + (pin (num 19) (name P19) (type passive)) + (pin (num 20) (name P20) (type passive)) + (pin (num 21) (name P21) (type passive)) + (pin (num 22) (name P22) (type passive)) + (pin (num 23) (name P23) (type passive)) + (pin (num 24) (name P24) (type passive)) + (pin (num 25) (name P25) (type passive)))) + (libpart (lib stm8s105k4t6c) (part STM8S105K4T6C) + (footprints + (fp lqfp32*)) + (fields + (field (name Reference) U) + (field (name Value) STM8S105K4T6C) + (field (name Footprint) ~) + (field (name Datasheet) ~)) + (pins + (pin (num 1) (name NRST) (type input)) + (pin (num 2) (name OSCIN/PA1) (type 3state)) + (pin (num 3) (name OSCOUT/PA2) (type 3state)) + (pin (num 4) (name VSS) (type power_in)) + (pin (num 5) (name VCAP) (type power_out)) + (pin (num 6) (name "VDD(3.3-5v)") (type power_in)) + (pin (num 7) (name VDDio) (type power_in)) + (pin (num 8) (name PF4/AIN12) (type 3state)) + (pin (num 9) (name VDDA) (type power_in)) + (pin (num 10) (name VSSA) (type power_in)) + (pin (num 11) (name PB5/AIN5[I2X_SDA]) (type 3state)) + (pin (num 12) (name PB4/AIN4[I2C_SCL]) (type 3state)) + (pin (num 13) (name PB3/AIN3[TIM1_ETR]) (type 3state)) + (pin (num 14) (name PB2/AIN2[TIM1_CH3N]) (type 3state)) + (pin (num 15) (name PB1/AIN1_[TIM1_CH2N]) (type 3state)) + (pin (num 16) (name PB0/AIN0_[TIM1_CH1N]) (type 3state)) + (pin (num 17) (name PE5/SPI_NSS) (type 3state)) + (pin (num 18) (name "PC1(HS)/TIM1_CH1") (type 3state)) + (pin (num 19) (name "PC2(HS)/TIM1_CH2") (type 3state)) + (pin (num 20) (name "PC3(HS)/TIM1_CH3") (type 3state)) + (pin (num 21) (name "PC4(HS)/TIM1_CH4") (type 3state)) + (pin (num 22) (name "PC5(HS)/SPI_SCK") (type 3state)) + (pin (num 23) (name "PC6(HS)/SPI_MOSI") (type 3state)) + (pin (num 24) (name "PC7(HS)/SPI_MISO") (type 3state)) + (pin (num 25) (name "PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO]") (type 3state)) + (pin (num 26) (name "PD1(HS)/SWIM") (type 3state)) + (pin (num 27) (name "PD2(HS)/TIM3_CH1[TIM2_CH3]") (type 3state)) + (pin (num 28) (name "PD3(HS)/TIM2_CH2[ADC_ETR]") (type 3state)) + (pin (num 29) (name "PD4(HS)/TIM2_CH1[BEEP]") (type 3state)) + (pin (num 30) (name PD5/UART2_TX) (type 3state)) + (pin (num 31) (name PD6/UART2_RX) (type 3state)) + (pin (num 32) (name PD7/TLI[TIM1_CH4]) (type 3state)))) + (libpart (lib conn) (part CONN_5) + (description "Symbole general de connecteur") + (fields + (field (name Reference) P) + (field (name Value) CONN_5)) + (pins + (pin (num 1) (name ~) (type power_out)) + (pin (num 2) (name ~) (type passive)) + (pin (num 3) (name ~) (type passive)) + (pin (num 4) (name ~) (type passive)) + (pin (num 5) (name ~) (type power_out))))) + (libraries + (library (logical device) + (uri /usr/share/kicad/library/device.lib)) + (library (logical conn) + (uri /usr/share/kicad/library/conn.lib)) + (library (logical stm8s105k4t6c) + (uri stm8s105k4t6c.lib))) + (nets + (net (code 1) (name "") + (node (ref J1) (pin 14))) + (net (code 2) (name /PC1) + (node (ref P1) (pin 14)) + (node (ref J1) (pin 2)) + (node (ref U1) (pin 18))) + (net (code 3) (name GND) + (node (ref C2) (pin 1)) + (node (ref P1) (pin 2)) + (node (ref P4) (pin 5)) + (node (ref SW1) (pin 1)) + (node (ref U1) (pin 10)) + (node (ref R2) (pin 2)) + (node (ref J1) (pin 24)) + (node (ref J1) (pin 25)) + (node (ref J1) (pin 18)) + (node (ref J1) (pin 19)) + (node (ref C1) (pin 1)) + (node (ref P2) (pin 4)) + (node (ref J1) (pin 20)) + (node (ref U1) (pin 4)) + (node (ref J1) (pin 21)) + (node (ref J1) (pin 22)) + (node (ref J1) (pin 23)) + (node (ref C3) (pin 2))) + (net (code 4) (name /NRST) + (node (ref SW1) (pin 2)) + (node (ref P2) (pin 3)) + (node (ref U1) (pin 1)) + (node (ref R3) (pin 2)) + (node (ref C3) (pin 1)) + (node (ref P1) (pin 3))) + (net (code 5) (name +3.3V) + (node (ref D1) (pin 1)) + (node (ref P1) (pin 1)) + (node (ref D2) (pin 1)) + (node (ref P2) (pin 1)) + (node (ref C2) (pin 2)) + (node (ref U1) (pin 9)) + (node (ref R3) (pin 1)) + (node (ref U1) (pin 7)) + (node (ref P4) (pin 1)) + (node (ref U1) (pin 6))) + (net (code 6) (name /PC2) + (node (ref P3) (pin 14)) + (node (ref R1) (pin 2)) + (node (ref U1) (pin 19))) + (net (code 7) (name "/1st out") + (node (ref J1) (pin 17))) + (net (code 8) (name /5.0V) + (node (ref P4) (pin 2))) + (net (code 9) (name /IN4) + (node (ref J1) (pin 13))) + (net (code 10) (name /IN3) + (node (ref J1) (pin 12))) + (net (code 11) (name /IN2) + (node (ref J1) (pin 11))) + (net (code 12) (name /IN1) + (node (ref J1) (pin 10))) + (net (code 13) (name /EN) + (node (ref J1) (pin 16))) + (net (code 14) (name /IN5) + (node (ref J1) (pin 15))) + (net (code 15) (name "/2nd out") + (node (ref J1) (pin 1))) + (net (code 16) (name /PD5) + (node (ref P3) (pin 3)) + (node (ref U1) (pin 30)) + (node (ref P4) (pin 4))) + (net (code 17) (name /PD6) + (node (ref P4) (pin 3)) + (node (ref P3) (pin 2)) + (node (ref U1) (pin 31))) + (net (code 18) (name "/A CLK") + (node (ref J1) (pin 8))) + (net (code 19) (name /PD2) + (node (ref J1) (pin 6)) + (node (ref P3) (pin 6)) + (node (ref U1) (pin 27))) + (net (code 20) (name /PD4) + (node (ref U1) (pin 29)) + (node (ref J1) (pin 4)) + (node (ref P3) (pin 4))) + (net (code 21) (name "") + (node (ref R2) (pin 1)) + (node (ref D2) (pin 2))) + (net (code 22) (name "/A DIR") + (node (ref J1) (pin 9)) + (node (ref U1) (pin 13)) + (node (ref P1) (pin 9))) + (net (code 23) (name /PB2) + (node (ref U1) (pin 14)) + (node (ref P1) (pin 10)) + (node (ref J1) (pin 7))) + (net (code 24) (name /PB1) + (node (ref P1) (pin 11)) + (node (ref U1) (pin 15)) + (node (ref J1) (pin 5))) + (net (code 25) (name /PB0) + (node (ref U1) (pin 16)) + (node (ref P1) (pin 12)) + (node (ref J1) (pin 3))) + (net (code 26) (name "") + (node (ref C1) (pin 2)) + (node (ref U1) (pin 5))) + (net (code 27) (name /PC3) + (node (ref U1) (pin 20)) + (node (ref P3) (pin 13))) + (net (code 28) (name /PC6) + (node (ref U1) (pin 23)) + (node (ref P3) (pin 10))) + (net (code 29) (name /PD7) + (node (ref P3) (pin 1)) + (node (ref U1) (pin 32))) + (net (code 30) (name /PC5) + (node (ref P3) (pin 11)) + (node (ref U1) (pin 22))) + (net (code 31) (name /PB4) + (node (ref P1) (pin 8)) + (node (ref U1) (pin 12))) + (net (code 32) (name /PC4) + (node (ref P3) (pin 12)) + (node (ref U1) (pin 21))) + (net (code 33) (name /PB5) + (node (ref U1) (pin 11)) + (node (ref P1) (pin 7))) + (net (code 34) (name /PF4) + (node (ref U1) (pin 8)) + (node (ref P1) (pin 6))) + (net (code 35) (name /OSC2IN) + (node (ref U1) (pin 3)) + (node (ref P1) (pin 5))) + (net (code 36) (name /OSC1IN) + (node (ref P1) (pin 4)) + (node (ref U1) (pin 2))) + (net (code 37) (name /PD3) + (node (ref P3) (pin 5)) + (node (ref U1) (pin 28))) + (net (code 38) (name /PE5) + (node (ref U1) (pin 17)) + (node (ref P1) (pin 13))) + (net (code 39) (name /SWIM/PD1) + (node (ref P3) (pin 7)) + (node (ref P2) (pin 2)) + (node (ref U1) (pin 26))) + (net (code 40) (name /PD0) + (node (ref P3) (pin 8)) + (node (ref U1) (pin 25))) + (net (code 41) (name /PC7) + (node (ref U1) (pin 24)) + (node (ref P3) (pin 9))) + (net (code 42) (name "") + (node (ref R1) (pin 1)) + (node (ref D1) (pin 2))))) \ No newline at end of file diff --git a/stepper_independent_bin/schematic/stepper.pro b/stepper_independent_bin/schematic/stepper.pro new file mode 100644 index 0000000..6601fe6 --- /dev/null +++ b/stepper_independent_bin/schematic/stepper.pro @@ -0,0 +1,45 @@ +update=Ср 26 фев 2014 17:43:07 +last_client=eeschema +[eeschema] +version=1 +LibDir= +NetFmtName= +RptD_X=0 +RptD_Y=100 +RptLab=1 +LabSize=118 +[eeschema/libraries] +LibName1=power +LibName2=device +LibName3=transistors +LibName4=conn +LibName5=linear +LibName6=regul +LibName7=74xx +LibName8=cmos4000 +LibName9=adc-dac +LibName10=memory +LibName11=xilinx +LibName12=special +LibName13=microcontrollers +LibName14=dsp +LibName15=microchip +LibName16=analog_switches +LibName17=motorola +LibName18=texas +LibName19=intel +LibName20=audio +LibName21=interface +LibName22=digital-audio +LibName23=philips +LibName24=display +LibName25=cypress +LibName26=siliconi +LibName27=opto +LibName28=atmel +LibName29=contrib +LibName30=valves +LibName31=stm8 +LibName32=st-microelectronics +LibName33=stm8s105k4t6c +LibName34=stepper-cache diff --git a/stepper_independent_bin/schematic/stepper.sch b/stepper_independent_bin/schematic/stepper.sch new file mode 100644 index 0000000..7136e4f --- /dev/null +++ b/stepper_independent_bin/schematic/stepper.sch @@ -0,0 +1,779 @@ +EESchema Schematic File Version 2 date Пн 03 мар 2014 17:27:22 +LIBS:power +LIBS:device +LIBS:transistors +LIBS:conn +LIBS:linear +LIBS:regul +LIBS:74xx +LIBS:cmos4000 +LIBS:adc-dac +LIBS:memory +LIBS:xilinx +LIBS:special +LIBS:microcontrollers +LIBS:dsp +LIBS:microchip +LIBS:analog_switches +LIBS:motorola +LIBS:texas +LIBS:intel +LIBS:audio +LIBS:interface +LIBS:digital-audio +LIBS:philips +LIBS:display +LIBS:cypress +LIBS:siliconi +LIBS:opto +LIBS:atmel +LIBS:contrib +LIBS:valves +LIBS:stm8 +LIBS:st-microelectronics +LIBS:stm8s105k4t6c +LIBS:stepper-cache +LIBS:stepper-cache +EELAYER 27 0 +EELAYER END +$Descr A4 11693 8268 +encoding utf-8 +Sheet 1 1 +Title "" +Date "3 mar 2014" +Rev "" +Comp "" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L STM8S105K4T6C U1 +U 1 1 52FB03A2 +P 4400 3100 +F 0 "U1" H 4400 4150 60 0000 C CNN +F 1 "STM8S105K4T6C" H 4450 2250 60 0000 C CNN +F 2 "~" H 4400 3100 60 0000 C CNN +F 3 "~" H 4400 3100 60 0000 C CNN + 1 4400 3100 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR01 +U 1 1 52FB03EF +P 2750 3200 +F 0 "#PWR01" H 2750 3200 30 0001 C CNN +F 1 "GND" H 2750 3130 30 0001 C CNN +F 2 "" H 2750 3200 60 0000 C CNN +F 3 "" H 2750 3200 60 0000 C CNN + 1 2750 3200 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 3200 2750 3150 +Wire Wire Line + 2750 3150 3000 3150 +$Comp +L GND #PWR02 +U 1 1 52FB0400 +P 2750 2600 +F 0 "#PWR02" H 2750 2600 30 0001 C CNN +F 1 "GND" H 2750 2530 30 0001 C CNN +F 2 "" H 2750 2600 60 0000 C CNN +F 3 "" H 2750 2600 60 0000 C CNN + 1 2750 2600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2750 2600 2750 2550 +Wire Wire Line + 2750 2550 3000 2550 +$Comp +L C C1 +U 1 1 52FB0413 +P 2250 2700 +F 0 "C1" H 2300 2800 50 0000 L CNN +F 1 "1u" H 2300 2600 50 0000 L CNN +F 2 "" H 2250 2700 60 0000 C CNN +F 3 "" H 2250 2700 60 0000 C CNN + 1 2250 2700 + 0 -1 -1 0 +$EndComp +$Comp +L C C2 +U 1 1 52FB0426 +P 2250 2950 +F 0 "C2" H 2300 3050 50 0000 L CNN +F 1 "104" H 2300 2850 50 0000 L CNN +F 2 "" H 2250 2950 60 0000 C CNN +F 3 "" H 2250 2950 60 0000 C CNN + 1 2250 2950 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 2450 2700 2850 2700 +Wire Wire Line + 2850 2700 2850 2650 +Wire Wire Line + 2850 2650 3000 2650 +Wire Wire Line + 3000 2750 3000 2850 +Wire Wire Line + 2450 2950 2450 2850 +Wire Wire Line + 2450 2850 3000 2850 +Wire Wire Line + 2050 2700 2050 3100 +$Comp +L GND #PWR03 +U 1 1 52FB0453 +P 2050 3100 +F 0 "#PWR03" H 2050 3100 30 0001 C CNN +F 1 "GND" H 2050 3030 30 0001 C CNN +F 2 "" H 2050 3100 60 0000 C CNN +F 3 "" H 2050 3100 60 0000 C CNN + 1 2050 3100 + 1 0 0 -1 +$EndComp +Connection ~ 2050 2800 +Connection ~ 2050 2950 +Text Label 3000 2250 2 60 ~ 0 +NRST +Text Label 3000 2350 2 60 ~ 0 +OSC1IN/PA1 +Text Label 3000 2450 2 60 ~ 0 +OSC2IN/PA2 +Text Label 3000 2950 2 60 ~ 0 +PF4 +Text Label 3000 3250 2 60 ~ 0 +PB5 +Text Label 3000 3350 2 60 ~ 0 +PB4 +Text Label 3000 3450 2 60 ~ 0 +PB3 +Text Label 3000 3550 2 60 ~ 0 +PB2 +Text Label 3000 3650 2 60 ~ 0 +PB1 +Text Label 3000 3750 2 60 ~ 0 +PB0 +Text Label 5800 3750 0 60 ~ 0 +PE5 +Text Label 5800 3650 0 60 ~ 0 +PC1 +Text Label 5800 3550 0 60 ~ 0 +PC2 +Text Label 5800 3450 0 60 ~ 0 +PC3 +Text Label 5800 3350 0 60 ~ 0 +PC4 +Text Label 5800 3250 0 60 ~ 0 +PC5 +Text Label 5800 3150 0 60 ~ 0 +PC6 +Text Label 5800 3050 0 60 ~ 0 +PC7 +Text Label 5800 2950 0 60 ~ 0 +PD0 +Text Label 5800 2850 0 60 ~ 0 +SWIM/PD1 +Text Label 5800 2750 0 60 ~ 0 +PD2 +Text Label 5800 2650 0 60 ~ 0 +PD3 +Text Label 5800 2550 0 60 ~ 0 +PD4 +Text Label 5800 2450 0 60 ~ 0 +PD5 +Text Label 5800 2350 0 60 ~ 0 +PD6 +Text Label 5800 2250 0 60 ~ 0 +PD7 +$Comp +L CONN_4 P2 +U 1 1 52FB0A49 +P 4350 1000 +F 0 "P2" V 4300 1000 50 0000 C CNN +F 1 "CONN_4" V 4400 1000 50 0000 C CNN +F 2 "" H 4350 1000 60 0000 C CNN +F 3 "" H 4350 1000 60 0000 C CNN + 1 4350 1000 + 1 0 0 -1 +$EndComp +$Comp +L CONN_14 P1 +U 1 1 52FB0A6A +P 1250 1500 +F 0 "P1" V 1220 1500 60 0000 C CNN +F 1 "CONN_14" V 1330 1500 60 0000 C CNN +F 2 "" H 1250 1500 60 0000 C CNN +F 3 "" H 1250 1500 60 0000 C CNN + 1 1250 1500 + -1 0 0 -1 +$EndComp +$Comp +L CONN_14 P3 +U 1 1 52FB0A79 +P 7100 1500 +F 0 "P3" V 7070 1500 60 0000 C CNN +F 1 "CONN_14" V 7180 1500 60 0000 C CNN +F 2 "" H 7100 1500 60 0000 C CNN +F 3 "" H 7100 1500 60 0000 C CNN + 1 7100 1500 + 1 0 0 -1 +$EndComp +Text Label 1600 1150 0 60 ~ 0 +OSC1IN/PA1 +Text Label 1600 1250 0 60 ~ 0 +OSC2IN/PA2 +Text Label 1600 1350 0 60 ~ 0 +PF4 +Text Label 1600 1450 0 60 ~ 0 +PB5 +Text Label 1600 1550 0 60 ~ 0 +PB4 +Text Label 1600 1650 0 60 ~ 0 +PB3 +Text Label 1600 1750 0 60 ~ 0 +PB2 +Text Label 1600 1850 0 60 ~ 0 +PB1 +Text Label 1600 1950 0 60 ~ 0 +PB0 +Text Label 1600 2050 0 60 ~ 0 +PE5 +Text Label 1600 2150 0 60 ~ 0 +PC1 +Text Label 1600 1050 0 60 ~ 0 +NRST +Text Label 4000 950 2 60 ~ 0 +SWIM/PD1 +Text Label 4000 1050 2 60 ~ 0 +NRST +Text Label 6750 850 2 60 ~ 0 +PD7 +Text Label 6750 950 2 60 ~ 0 +PD6 +Text Label 6750 1050 2 60 ~ 0 +PD5 +Text Label 6750 1150 2 60 ~ 0 +PD4 +Text Label 6750 1250 2 60 ~ 0 +PD3 +Text Label 6750 1350 2 60 ~ 0 +PD2 +Text Label 6750 1450 2 60 ~ 0 +SWIM/PD1 +Text Label 6750 1550 2 60 ~ 0 +PD0 +Text Label 6750 1650 2 60 ~ 0 +PC7 +Text Label 6750 1750 2 60 ~ 0 +PC6 +Text Label 6750 1850 2 60 ~ 0 +PC5 +Text Label 6750 1950 2 60 ~ 0 +PC4 +Text Label 6750 2050 2 60 ~ 0 +PC3 +Text Label 6750 2150 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR04 +U 1 1 52FB0DC4 +P 950 2800 +F 0 "#PWR04" H 950 2760 30 0001 C CNN +F 1 "+3.3V" H 950 2910 30 0000 C CNN +F 2 "" H 950 2800 60 0000 C CNN +F 3 "" H 950 2800 60 0000 C CNN + 1 950 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D1 +U 1 1 52FB0DD3 +P 950 3100 +F 0 "D1" H 950 3200 50 0000 C CNN +F 1 "LED" H 950 3000 50 0000 C CNN +F 2 "" H 950 3100 60 0000 C CNN +F 3 "" H 950 3100 60 0000 C CNN + 1 950 3100 + 0 1 1 0 +$EndComp +$Comp +L R R1 +U 1 1 52FB0DE2 +P 950 3600 +F 0 "R1" V 1030 3600 50 0000 C CNN +F 1 "1k" V 950 3600 50 0000 C CNN +F 2 "" H 950 3600 60 0000 C CNN +F 3 "" H 950 3600 60 0000 C CNN + 1 950 3600 + 1 0 0 -1 +$EndComp +Wire Wire Line + 950 2800 950 2900 +Wire Wire Line + 950 3300 950 3350 +Wire Wire Line + 950 3850 950 3950 +$Comp +L +3.3V #PWR05 +U 1 1 52FB0EC7 +P 1300 2800 +F 0 "#PWR05" H 1300 2760 30 0001 C CNN +F 1 "+3.3V" H 1300 2910 30 0000 C CNN +F 2 "" H 1300 2800 60 0000 C CNN +F 3 "" H 1300 2800 60 0000 C CNN + 1 1300 2800 + 1 0 0 -1 +$EndComp +$Comp +L LED D2 +U 1 1 52FB0ECD +P 1300 3100 +F 0 "D2" H 1300 3200 50 0000 C CNN +F 1 "LED" H 1300 3000 50 0000 C CNN +F 2 "" H 1300 3100 60 0000 C CNN +F 3 "" H 1300 3100 60 0000 C CNN + 1 1300 3100 + 0 1 1 0 +$EndComp +$Comp +L R R2 +U 1 1 52FB0ED3 +P 1300 3600 +F 0 "R2" V 1380 3600 50 0000 C CNN +F 1 "1k" V 1300 3600 50 0000 C CNN +F 2 "" H 1300 3600 60 0000 C CNN +F 3 "" H 1300 3600 60 0000 C CNN + 1 1300 3600 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR06 +U 1 1 52FB0ED9 +P 1300 3950 +F 0 "#PWR06" H 1300 3950 30 0001 C CNN +F 1 "GND" H 1300 3880 30 0001 C CNN +F 2 "" H 1300 3950 60 0000 C CNN +F 3 "" H 1300 3950 60 0000 C CNN + 1 1300 3950 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1300 2800 1300 2900 +Wire Wire Line + 1300 3300 1300 3350 +Wire Wire Line + 1300 3850 1300 3950 +Text Label 950 3950 2 60 ~ 0 +PC2 +$Comp +L +3.3V #PWR07 +U 1 1 52FB0EF1 +P 6500 2550 +F 0 "#PWR07" H 6500 2510 30 0001 C CNN +F 1 "+3.3V" H 6500 2660 30 0000 C CNN +F 2 "" H 6500 2550 60 0000 C CNN +F 3 "" H 6500 2550 60 0000 C CNN + 1 6500 2550 + 1 0 0 -1 +$EndComp +$Comp +L R R3 +U 1 1 52FB0EFD +P 6500 2900 +F 0 "R3" V 6580 2900 50 0000 C CNN +F 1 "10k" V 6500 2900 50 0000 C CNN +F 2 "" H 6500 2900 60 0000 C CNN +F 3 "" H 6500 2900 60 0000 C CNN + 1 6500 2900 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR08 +U 1 1 52FB0F03 +P 6500 4050 +F 0 "#PWR08" H 6500 4050 30 0001 C CNN +F 1 "GND" H 6500 3980 30 0001 C CNN +F 2 "" H 6500 4050 60 0000 C CNN +F 3 "" H 6500 4050 60 0000 C CNN + 1 6500 4050 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6500 2550 6500 2650 +Wire Wire Line + 6500 3850 6500 4050 +$Comp +L SW_PUSH SW1 +U 1 1 52FB0F3B +P 6500 3550 +F 0 "SW1" H 6650 3660 50 0000 C CNN +F 1 "SW_PUSH" H 6500 3470 50 0000 C CNN +F 2 "" H 6500 3550 60 0000 C CNN +F 3 "" H 6500 3550 60 0000 C CNN + 1 6500 3550 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 6500 3250 6500 3150 +$Comp +L C C3 +U 1 1 52FB0F99 +P 6900 3550 +F 0 "C3" H 6950 3650 50 0000 L CNN +F 1 "104" H 6950 3450 50 0000 L CNN +F 2 "" H 6900 3550 60 0000 C CNN +F 3 "" H 6900 3550 60 0000 C CNN + 1 6900 3550 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6900 3200 6900 3350 +Wire Wire Line + 6900 3750 6900 3900 +Wire Wire Line + 6900 3900 6500 3900 +Connection ~ 6500 3900 +Wire Wire Line + 6500 3200 6900 3200 +Connection ~ 6500 3200 +Text Label 6500 3200 2 60 ~ 0 +NRST +$Comp +L +3.3V #PWR09 +U 1 1 52FB2273 +P 2150 850 +F 0 "#PWR09" H 2150 810 30 0001 C CNN +F 1 "+3.3V" H 2150 960 30 0000 C CNN +F 2 "" H 2150 850 60 0000 C CNN +F 3 "" H 2150 850 60 0000 C CNN + 1 2150 850 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 850 2150 850 +$Comp +L GND #PWR010 +U 1 1 52FB2296 +P 2150 1000 +F 0 "#PWR010" H 2150 1000 30 0001 C CNN +F 1 "GND" H 2150 930 30 0001 C CNN +F 2 "" H 2150 1000 60 0000 C CNN +F 3 "" H 2150 1000 60 0000 C CNN + 1 2150 1000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1600 950 2150 950 +Wire Wire Line + 2150 950 2150 1000 +Wire Wire Line + 2600 3050 3000 3050 +Wire Wire Line + 2750 3050 2750 2850 +Connection ~ 2750 2850 +$Comp +L +3.3V #PWR011 +U 1 1 52FB26FA +P 2600 3000 +F 0 "#PWR011" H 2600 2960 30 0001 C CNN +F 1 "+3.3V" H 2600 3110 30 0000 C CNN +F 2 "" H 2600 3000 60 0000 C CNN +F 3 "" H 2600 3000 60 0000 C CNN + 1 2600 3000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 2600 3000 2600 3050 +Connection ~ 2750 3050 +$Comp +L +3.3V #PWR012 +U 1 1 52FB286D +P 4000 750 +F 0 "#PWR012" H 4000 710 30 0001 C CNN +F 1 "+3.3V" H 4000 860 30 0000 C CNN +F 2 "" H 4000 750 60 0000 C CNN +F 3 "" H 4000 750 60 0000 C CNN + 1 4000 750 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR013 +U 1 1 52FB287C +P 4000 1300 +F 0 "#PWR013" H 4000 1300 30 0001 C CNN +F 1 "GND" H 4000 1230 30 0001 C CNN +F 2 "" H 4000 1300 60 0000 C CNN +F 3 "" H 4000 1300 60 0000 C CNN + 1 4000 1300 + 1 0 0 -1 +$EndComp +Wire Wire Line + 4000 1300 4000 1150 +Wire Wire Line + 4000 850 4000 750 +Wire Notes Line + 600 500 600 4200 +Wire Notes Line + 600 4200 7500 4200 +Wire Notes Line + 7500 4200 7500 500 +Wire Notes Line + 7500 500 600 500 +Text Notes 4800 750 0 118 ~ 0 +STM8 board +Text Notes 7950 950 0 118 ~ 0 +USB <-> TTL +Text Label 9000 1150 0 61 ~ 0 +GND +Text Label 9000 1250 0 61 ~ 0 +RXD +Text Label 9000 1350 0 61 ~ 0 +TXD +Text Label 9000 1450 0 61 ~ 0 +5.0V +Text Label 9000 1550 0 61 ~ 0 +3.3V +$Comp +L GND #PWR014 +U 1 1 52FB4CEF +P 10000 1250 +F 0 "#PWR014" H 10000 1250 30 0001 C CNN +F 1 "GND" H 10000 1180 30 0001 C CNN +F 2 "" H 10000 1250 60 0000 C CNN +F 3 "" H 10000 1250 60 0000 C CNN + 1 10000 1250 + 1 0 0 -1 +$EndComp +Wire Wire Line + 9000 1150 10000 1150 +Wire Wire Line + 10000 1150 10000 1250 +Wire Wire Line + 9000 1250 9600 1250 +Wire Wire Line + 9600 1250 9600 850 +Wire Wire Line + 9000 1350 10200 1350 +Wire Wire Line + 10200 1350 10200 850 +$Comp +L +3.3V #PWR015 +U 1 1 52FB4EDC +P 10400 1450 +F 0 "#PWR015" H 10400 1410 30 0001 C CNN +F 1 "+3.3V" H 10400 1560 30 0000 C CNN +F 2 "" H 10400 1450 60 0000 C CNN +F 3 "" H 10400 1450 60 0000 C CNN + 1 10400 1450 + 1 0 0 -1 +$EndComp +Wire Wire Line + 9000 1550 10400 1550 +Wire Wire Line + 10400 1550 10400 1450 +NoConn ~ 9000 1450 +Text Label 9600 850 0 61 ~ 0 +PD5 +Text Label 10200 850 0 61 ~ 0 +PD6 +$Comp +L CONN_3 K1 +U 1 1 530DEDA9 +P 950 5150 +F 0 "K1" V 900 5150 50 0000 C CNN +F 1 "CONN_3" V 1000 5150 40 0000 C CNN +F 2 "" H 950 5150 60 0000 C CNN +F 3 "" H 950 5150 60 0000 C CNN + 1 950 5150 + -1 0 0 1 +$EndComp +Wire Wire Line + 1300 5050 1600 5050 +Wire Wire Line + 1300 5150 1600 5150 +Wire Wire Line + 1300 5250 1600 5250 +Text Label 1600 5050 0 60 ~ 0 +PD0 +Text Label 1600 5150 0 60 ~ 0 +PE5 +Text Label 1600 5250 0 60 ~ 0 +PC1 +$Comp +L CONN_3 K2 +U 1 1 530DEE90 +P 950 5750 +F 0 "K2" V 900 5750 50 0000 C CNN +F 1 "CONN_3" V 1000 5750 40 0000 C CNN +F 2 "" H 950 5750 60 0000 C CNN +F 3 "" H 950 5750 60 0000 C CNN + 1 950 5750 + -1 0 0 1 +$EndComp +Wire Wire Line + 1300 5650 1600 5650 +Wire Wire Line + 1300 5750 1600 5750 +Wire Wire Line + 1300 5850 1600 5850 +Text Label 1600 5650 0 60 ~ 0 +PD7 +Text Label 1600 5750 0 60 ~ 0 +PD3 +Text Label 1600 5850 0 60 ~ 0 +PD4 +$Comp +L CONN_3 K3 +U 1 1 530DEE9C +P 950 6350 +F 0 "K3" V 900 6350 50 0000 C CNN +F 1 "CONN_3" V 1000 6350 40 0000 C CNN +F 2 "" H 950 6350 60 0000 C CNN +F 3 "" H 950 6350 60 0000 C CNN + 1 950 6350 + -1 0 0 1 +$EndComp +Wire Wire Line + 1300 6250 1600 6250 +Wire Wire Line + 1300 6350 1600 6350 +Wire Wire Line + 1300 6450 1600 6450 +Text Label 1600 6250 0 60 ~ 0 +PF4 +Text Label 1600 6350 0 60 ~ 0 +SWIM/PD1 +Text Label 1600 6450 0 60 ~ 0 +PD2 +Text Notes 850 4900 0 98 ~ 0 +Motor 0 +Text Notes 850 5500 0 98 ~ 0 +Motor 1 +Text Notes 850 6100 0 98 ~ 0 +Motor 2 +Text Notes 700 4650 0 118 ~ 0 +MOTOR management +Text Notes 3700 4650 0 118 ~ 0 +End-switches (EPs) +$Comp +L CONN_5 P4 +U 1 1 530DF06A +P 3750 5200 +F 0 "P4" H 3800 5500 50 0000 C CNN +F 1 "CONN_5" V 3900 5200 50 0000 C CNN +F 2 "" H 3750 5200 60 0000 C CNN +F 3 "" H 3750 5200 60 0000 C CNN + 1 3750 5200 + -1 0 0 1 +$EndComp +$Comp +L CONN_5_ P7 +U 1 1 530DF308 +P 8600 1350 +F 0 "P7" H 8650 1050 50 0000 C CNN +F 1 "CONN_5_" V 8750 1350 50 0000 C CNN +F 2 "" H 8600 1350 60 0000 C CNN +F 3 "" H 8600 1350 60 0000 C CNN + 1 8600 1350 + -1 0 0 1 +$EndComp +Wire Wire Line + 4150 5000 4700 5000 +Wire Wire Line + 4150 5200 4700 5200 +Wire Wire Line + 4150 5400 4700 5400 +Wire Wire Line + 4150 5100 4450 5100 +Wire Wire Line + 4150 5300 4450 5300 +Text Notes 3500 4850 0 98 ~ 0 +Motor 0 +Text Label 4700 5000 0 59 ~ 0 +PC7 +Text Label 4450 5100 0 59 ~ 0 +PC6 +Text Label 4700 5200 0 59 ~ 0 +PC5 +Text Label 4450 5300 0 59 ~ 0 +PC4 +Text Label 4700 5400 0 59 ~ 0 +PC3 +$Comp +L CONN_5 P5 +U 1 1 530DF803 +P 3750 6100 +F 0 "P5" H 3800 6400 50 0000 C CNN +F 1 "CONN_5" V 3900 6100 50 0000 C CNN +F 2 "" H 3750 6100 60 0000 C CNN +F 3 "" H 3750 6100 60 0000 C CNN + 1 3750 6100 + -1 0 0 1 +$EndComp +Wire Wire Line + 4150 6100 4700 6100 +Wire Wire Line + 4150 6300 4700 6300 +Wire Wire Line + 4150 6000 4450 6000 +Wire Wire Line + 4150 6200 4450 6200 +Text Notes 3500 5750 0 98 ~ 0 +Motor 1 +Text Label 4450 6000 0 59 ~ 0 +PB3 +Text Label 4700 6100 0 59 ~ 0 +PB2 +Text Label 4450 6200 0 59 ~ 0 +PB1 +Text Label 4700 6300 0 59 ~ 0 +PB0 +NoConn ~ 4150 5900 +$Comp +L CONN_5 P6 +U 1 1 530DF8E3 +P 3750 7000 +F 0 "P6" H 3800 7300 50 0000 C CNN +F 1 "CONN_5" V 3900 7000 50 0000 C CNN +F 2 "" H 3750 7000 60 0000 C CNN +F 3 "" H 3750 7000 60 0000 C CNN + 1 3750 7000 + -1 0 0 1 +$EndComp +Wire Wire Line + 4150 7000 4700 7000 +Wire Wire Line + 4150 7200 4700 7200 +Wire Wire Line + 4150 6900 4450 6900 +Wire Wire Line + 4150 7100 4450 7100 +Text Notes 3500 6650 0 98 ~ 0 +Motor 2 +Text Label 4450 6900 0 59 ~ 0 +OSC2IN/PA2 +Text Label 4700 7000 0 59 ~ 0 +OSC1IN/PA1 +Text Label 4450 7100 0 59 ~ 0 +PB5 +Text Label 4700 7200 0 59 ~ 0 +PB4 +NoConn ~ 4150 6800 +Text Notes 1300 5050 0 59 ~ 0 +DIR\nEN\nCLK +Text Notes 1300 5650 0 59 ~ 0 +DIR\nEN\nCLK +Text Notes 1300 6250 0 59 ~ 0 +DIR\nEN\nCLK +Text Notes 4150 5000 0 63 ~ 0 +4\n3\n2\n1\n0 +Text Notes 4150 5900 0 63 ~ 0 +4\n3\n2\n1\n0 +Text Notes 4150 6800 0 63 ~ 0 +4\n3\n2\n1\n0 +$EndSCHEMATC diff --git a/stepper_independent_bin/schematic/stm8s105k4t6c.bck b/stepper_independent_bin/schematic/stm8s105k4t6c.bck new file mode 100644 index 0000000..5efbdbd --- /dev/null +++ b/stepper_independent_bin/schematic/stm8s105k4t6c.bck @@ -0,0 +1,9 @@ +EESchema-DOCLIB Version 2.0 Date: Вт 11 фев 2014 17:09:58 +# +$CMP STM8S003K3T +D STM8S003K3T, LQFP32 (7x7, 0.8mm pitch), 16MHz, 8K Flash, 1K RAM, 128 EEPROM +K STM8 Microcontroller Value Line +F http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00024550.pdf +$ENDCMP +# +#End Doc Library diff --git a/stepper_independent_bin/schematic/stm8s105k4t6c.dcm b/stepper_independent_bin/schematic/stm8s105k4t6c.dcm new file mode 100644 index 0000000..71362a5 --- /dev/null +++ b/stepper_independent_bin/schematic/stm8s105k4t6c.dcm @@ -0,0 +1,13 @@ +EESchema-DOCLIB Version 2.0 Date: Вт 11 фев 2014 17:26:38 +# +$CMP STM8S003K3T +D STM8S003K3T, LQFP32 (7x7, 0.8mm pitch), 16MHz, 8K Flash, 1K RAM, 128 EEPROM +K STM8 Microcontroller Value Line +F http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00024550.pdf +$ENDCMP +# +$CMP STM8S105K4T6C +K stm8 +$ENDCMP +# +#End Doc Library diff --git a/stepper_independent_bin/schematic/stm8s105k4t6c.lib b/stepper_independent_bin/schematic/stm8s105k4t6c.lib new file mode 100644 index 0000000..4b3ba70 --- /dev/null +++ b/stepper_independent_bin/schematic/stm8s105k4t6c.lib @@ -0,0 +1,99 @@ +EESchema-LIBRARY Version 2.3 Date: Вт 11 фев 2014 17:26:38 +#encoding utf-8 +# +# STM8S003K3T +# +DEF STM8S003K3T IC 0 40 Y Y 1 F N +F0 "IC" -800 1150 60 H V C CNN +F1 "STM8S003K3T" 550 -1100 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +$FPLIST + LQFP32* +$ENDFPLIST +DRAW +S -850 1100 850 -1050 0 1 10 f +X NRST 1 -1000 1000 149 R 40 40 1 1 I +X OSCI/PA1 2 1000 1000 149 L 40 40 1 1 B +X OSCOUT/PA2 3 1000 900 149 L 40 40 1 1 B +X VSS 4 0 -1200 149 U 40 40 1 1 W +X Vcap 5 -1000 -950 149 R 40 40 1 1 I +X VDD 6 0 1250 149 D 40 40 1 1 W +X [SPI_NSS]TIM2_CH3/PA3 7 1000 800 149 L 40 40 1 1 B +X PF4 8 -1000 -350 149 R 40 40 1 1 B +X PB7 9 1000 -50 149 L 40 40 1 1 B +X PB6 10 1000 50 149 L 40 40 1 1 B +X TIM1_CH3/PC3 20 1000 -400 149 L 40 40 1 1 B +X PD5/UART1_TX 30 -1000 150 149 R 40 40 1 1 B +X I2C_SDA/PB5 11 1000 150 149 L 40 40 1 1 B +X CLK_CCO/TIM1_CH4/PC4 21 1000 -500 149 L 40 40 1 1 B +X PD6/UART1_RX 31 -1000 50 149 R 40 40 1 1 B +X I2C_SCL/PB4 12 1000 250 149 L 40 40 1 1 B +X SPI_SCK/PC5 22 1000 -600 149 L 40 40 1 1 B +X PD7/TLI[TIM1_CH4] 32 -1000 -50 148 R 40 40 1 1 B +X TIM1_ETR/AIN3/PB3 13 1000 350 149 L 40 40 1 1 B +X PI_MOSI/PC6 23 1000 -700 149 L 40 40 1 1 B +X TIM1_CH3N/AIN2/PB2 14 1000 450 149 L 40 40 1 1 B +X PI_MISO/PC7 24 1000 -800 149 L 40 40 1 1 B +X TIM1_CH2N/AIN1/PB1 15 1000 550 149 L 40 40 1 1 B +X PD0/TIM1_BKIN[CLK_CCO] 25 -1000 650 148 R 40 40 1 1 B +X TIM1_CH1N/AIN0/PB0 16 1000 650 149 L 40 40 1 1 B +X PD1/SWIM 26 -1000 550 149 R 40 40 1 1 B +X PE5/SPI_NSS 17 -1000 -200 148 R 40 40 1 1 B +X PD2[TIM2_CH3] 27 -1000 450 149 R 40 40 1 1 B +X UART1_CK/TIM1_CH1/PC1 18 1000 -200 149 L 40 40 1 1 B +X PD3/ADC_ETR/TIM2_CH2 28 -1000 350 149 R 40 40 1 1 B +X TIM1_CH2/PC2 19 1000 -300 149 L 40 40 1 1 B +X PD4/BEEP/TIM2_CH1 29 -1000 250 149 R 40 40 1 1 B +ENDDRAW +ENDDEF +# +# STM8S105K4T6C +# +DEF STM8S105K4T6C U 0 40 Y Y 1 F N +F0 "U" 0 1050 60 H V C CNN +F1 "STM8S105K4T6C" 50 -850 60 H V C CNN +F2 "~" 0 0 60 H V C CNN +F3 "~" 0 0 60 H V C CNN +ALIAS stm8s105* +$FPLIST + lqfp32* +$ENDFPLIST +DRAW +S -1100 950 1100 -750 0 1 0 N +X NRST 1 -1400 850 300 R 50 50 1 1 I +X OSCIN/PA1 2 -1400 750 300 R 50 50 1 1 T +X OSCOUT/PA2 3 -1400 650 300 R 50 50 1 1 T +X VSS 4 -1400 550 300 R 50 50 1 1 W +X VCAP 5 -1400 450 300 R 50 50 1 1 w +X VDD(3.3-5v) 6 -1400 350 300 R 50 50 1 1 W +X VDDio 7 -1400 250 300 R 50 50 1 1 W +X PF4/AIN12 8 -1400 150 300 R 50 50 1 1 T +X VDDA 9 -1400 50 300 R 50 50 1 1 W +X VSSA 10 -1400 -50 300 R 50 50 1 1 W +X PC3(HS)/TIM1_CH3 20 1400 -350 300 L 50 50 1 1 T +X PD5/UART2_TX 30 1400 650 300 L 50 50 1 1 T +X PB5/AIN5[I2X_SDA] 11 -1400 -150 300 R 50 50 1 1 T +X PC4(HS)/TIM1_CH4 21 1400 -250 300 L 50 50 1 1 T +X PD6/UART2_RX 31 1400 750 300 L 50 50 1 1 T +X PB4/AIN4[I2C_SCL] 12 -1400 -250 300 R 50 50 1 1 T +X PC5(HS)/SPI_SCK 22 1400 -150 300 L 50 50 1 1 T +X PD7/TLI[TIM1_CH4] 32 1400 850 300 L 50 50 1 1 T +X PB3/AIN3[TIM1_ETR] 13 -1400 -350 300 R 50 50 1 1 T +X PC6(HS)/SPI_MOSI 23 1400 -50 300 L 50 50 1 1 T +X PB2/AIN2[TIM1_CH3N] 14 -1400 -450 300 R 50 50 1 1 T +X PC7(HS)/SPI_MISO 24 1400 50 300 L 50 50 1 1 T +X PB1/AIN1_[TIM1_CH2N] 15 -1400 -550 300 R 50 50 1 1 T +X PD0(HS)/TIM3_CH2[TIM1_BKIN][CLK_CCO] 25 1400 150 300 L 50 50 1 1 T +X PB0/AIN0_[TIM1_CH1N] 16 -1400 -650 300 R 50 50 1 1 T +X PD1(HS)/SWIM 26 1400 250 300 L 50 50 1 1 T +X PE5/SPI_NSS 17 1400 -650 300 L 50 50 1 1 T +X PD2(HS)/TIM3_CH1[TIM2_CH3] 27 1400 350 300 L 50 50 1 1 T +X PC1(HS)/TIM1_CH1 18 1400 -550 300 L 50 50 1 1 T +X PD3(HS)/TIM2_CH2[ADC_ETR] 28 1400 450 300 L 50 50 1 1 T +X PC2(HS)/TIM1_CH2 19 1400 -450 300 L 50 50 1 1 T +X PD4(HS)/TIM2_CH1[BEEP] 29 1400 550 300 L 50 50 1 1 T +ENDDRAW +ENDDEF +# +#End Library diff --git a/stepper_independent_bin/stepper.c b/stepper_independent_bin/stepper.c new file mode 100644 index 0000000..d9ce212 --- /dev/null +++ b/stepper_independent_bin/stepper.c @@ -0,0 +1,242 @@ +/* + * stepper.c + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "ports_definition.h" +#include "stepper.h" + +volatile int Nsteps[3]={0,0,0}; // Number of steps +volatile int usteps[3] = {0,0,0};// microstepping counters +U8 Motor_number = 5; // Number of motor to move, 5 -- not moving +U16 Stepper_speed[3] = {1000,1000,1000}; // length of one MICROstep in us +U8* Timers[3] = {0x5250, 0x5300, 0x5320}; // {&TIM1_CR1, &TIM2_CR1, &TIM3_CR1} +U8 EPs[3] = {0,0,0}; // value of conditional stop-on-EP terminals status +U8 Stop_on_EP[3] = {0,0,0}; // boolean: whether motor should freely move or stop on EPs +U8 USteps = 16; // amount of microsteps on each step +U8 StepperInfty = 0; // infinity moving + +#define pause_motor(N) *Timers[N] &= ~TIM_CR1_CEN +#define resume_motor(N) *Timers[N] |= TIM_CR1_CEN +#define check_motor(N) *Timers[N] & TIM_CR1_CEN +#define PPOUT(P, PIN) do{PORT(P, DDR) |= PIN; PORT(P, CR1) |= PIN;}while(0) +#define _MTR(X, N) PPOUT(STP ## N ## _ ## X ## _PORT, STP ## N ## _ ## X ## _PIN) +#define SETUP_MOTOR_PORT(X) do{_MTR(X,0); _MTR(X,1); _MTR(X,2);}while(0) +#define TMR(a, b) CONCAT(a , b) +#define TIMER_CONF(reg, val) do{TMR(TIM1, reg) = val; TMR(TIM2, reg) = val; TMR(TIM3, reg) = val;}while(0) + +/** + * Setup pins of stepper motor (all - PP out) & timers + */ +void setup_stepper_pins(){ + // CLK + SETUP_MOTOR_PORT(CLK); + // DIR + SETUP_MOTOR_PORT(DIR); + // EN + SETUP_MOTOR_PORT(EN); + // End point switches: + SETUP_EP(0); + SETUP_EP(1); + SETUP_EP(2); + /**** TIMERS (all - 1MHz, default speed - 1000 Hz) ****/ + // Motor x - timer x+1 + TIM1_PSCRH = 0; // this timer have 16 bit prescaler + TIM1_PSCRL = 15; // LSB should be written last as it updates prescaler + TIM2_PSCR = 4; + TIM3_PSCR = 4; + // auto-reload each 1ms: TIM_ARR = 1000 = 0x03E8 + TIMER_CONF(ARRH, 0x03); + TIMER_CONF(ARRL, 0xE8); + // 50% duty cycle: TIM_CCR = 500 = 0x01F4 + TIMER_CONF(CCR1H, 0x01); + TIMER_CONF(CCR1L, 0xF4); + // channel 1 generates PWM pulses + TIMER_CONF(CCMR1, 0x60); // OC1M = 110b - PWM mode 1 ( 1 -> 0) + TIMER_CONF(CCER1, 1); // Channel 1 is on. Active is high + // interrupts: update + TIMER_CONF(IER, TIM_IER_UIE); + // auto-reload + interrupt on overflow + TIMER_CONF(CR1, TIM_CR1_APRE | TIM_CR1_URS); + // enable PWM output for timer1 + TIM1_BKR |= 0x80; // MOE + // Turn off EN + PORT(STP0_EN_PORT, ODR) |= STP0_EN_PIN; + PORT(STP1_EN_PORT, ODR) |= STP1_EN_PIN; + PORT(STP2_EN_PORT, ODR) |= STP2_EN_PIN; +} + +/** + * Set speed of stepper motor + * @param N - number of motor + * @param Sps - period (in us) of one MICROstep + */ +void set_stepper_speed(U8 N, U16 SpS){ + U8 AH, AL, CH, CL; + if(N > 2) return; + Stepper_speed[N] = SpS; + AH = SpS >> 8; + AL = SpS & 0xff; + SpS >>= 1; // divide to 2 - 50% duty cycle + CH = SpS >> 8; + CL = SpS & 0xff; + switch(N){ + case 0: + TIM1_ARRH = AH; + TIM1_ARRL = AL; + TIM1_CCR1H = CH; + TIM1_CCR1L = CL; + break; + case 1: + TIM2_ARRH = AH; + TIM2_ARRL = AL; + TIM2_CCR1H = CH; + TIM2_CCR1L = CL; + break; + case 2: + TIM3_ARRH = AH; + TIM3_ARRL = AL; + TIM3_CCR1H = CH; + TIM3_CCR1L = CL; + break; + } +} + +/** + * Move motor N for 'Steps' amount of steps + * @param N - number of motor + * @param Steps - number of steps to move (negative value means to move CCV) + */ +void move_motor(U8 N, int Steps){ + if(N > 2) return; + pause_motor(N); + if(Steps < 0){// dir to left + switch(N){ + case 0: + PORT(STP0_DIR_PORT, ODR) |= STP0_DIR_PIN; + break; + case 1: + PORT(STP1_DIR_PORT, ODR) |= STP1_DIR_PIN; + break; + case 2: + PORT(STP2_DIR_PORT, ODR) |= STP2_DIR_PIN; + break; + } + Steps *= -1; + } + // turn on EN + switch(N){ + case 0: + PORT(STP0_EN_PORT, ODR) &= ~STP0_EN_PIN; + break; + case 1: + PORT(STP1_EN_PORT, ODR) &= ~STP1_EN_PIN; + break; + case 2: + PORT(STP2_EN_PORT, ODR) &= ~STP2_EN_PIN; + break; + } + Nsteps[N] = Steps; + resume_motor(N); + uart_write("move"); + printUint(&N, 1); +} + +/** + * Stop motor N + * @param N - number of motor + */ +void stop_motor(U8 N){ + if(N > 2) return; + pause_motor(N); + switch(N){ // turn off DIR & EN + case 0: + PORT(STP0_DIR_PORT, ODR) &= ~STP0_DIR_PIN; + PORT(STP0_EN_PORT, ODR) |= STP0_EN_PIN; + break; + case 1: + PORT(STP1_DIR_PORT, ODR) &= ~STP1_DIR_PIN; + PORT(STP1_EN_PORT, ODR) |= STP1_EN_PIN; + break; + case 2: + PORT(STP2_DIR_PORT, ODR) &= ~STP2_DIR_PIN; + PORT(STP2_EN_PORT, ODR) |= STP2_EN_PIN; + break; + } + StepperInfty = 0; // clear infinity flag + Nsteps[N] = 0; + usteps[N] = 0; + uart_write("stop"); + printUint(&N, 1); +} + +/** + * Pause or resume motor N + * @param N - number of motor + */ +void pause_resume(U8 N){ + if(N > 2) return; + if(Nsteps[N] == 0) return; // motor is stopped + if(check_motor(N)){ // motor is running - pause + pause_motor(N); + uart_write("pause"); + }else{ // resume + resume_motor(N); + uart_write("resume"); + } + printUint(&N, 1); +} + +/** + * Get current value of EP switches + * @param N - number of motor + * @return value of EPs + */ +U8 get_ep_value(U8 N){ + U8 val = 0; + switch(N){ + case 0: + val = READ_EP(0); + break; + case 1: + val = READ_EP(1); + break; + case 2: + val = READ_EP(2); + break; + } + return val; +} + +/** + * Checks for "stop-on-EP" condition + * @param + * @return + */ +void check_EP(){ + U8 i; + for(i = 0; i < 3; i++){ + if(Stop_on_EP[i] == 0) continue; + if(EPs[i] == get_ep_value(i)){ + stop_motor(i); + uart_write("endpoint\n"); + // Stop_on_EP[i] = 0; // reset off-condition + } + } +} diff --git a/stepper_independent_bin/stepper.h b/stepper_independent_bin/stepper.h new file mode 100644 index 0000000..f6d12e2 --- /dev/null +++ b/stepper_independent_bin/stepper.h @@ -0,0 +1,47 @@ +/* + * stepper.h + * + * Copyright 2014 Edward V. Emelianov + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#pragma once +#ifndef __STEPPER_H__ +#define __STEPPER_H__ + +#include "ports_definition.h" +#include "main.h" + +extern volatile int Nsteps[]; +extern volatile int usteps[]; +extern U16 Stepper_speed[]; +extern U8 EPs[]; +extern U8 Stop_on_EP[]; +extern U8 USteps; +extern U8 StepperInfty; + +void setup_stepper_pins(); +void set_stepper_speed(U8 N, U16 SpS); +void move_motor(U8 N, int Steps); +void stop_motor(U8 N); +void pause_resume(U8 N); + +U8 get_ep_value(U8 N); + +void check_EP(); + +#endif // __STEPPER_H__ diff --git a/stepper_independent_bin/testproj.bin b/stepper_independent_bin/testproj.bin new file mode 100644 index 0000000000000000000000000000000000000000..240041bd794fabcfd8bddb498edf65a751227c4d GIT binary patch literal 4840 zcmZ`-YitzP6}~gG&)LV=YwvFSU}jA0UBLL6k_ZqA54(XH*zFn;!a8ycECEgY(Ap$K zqsTVc$(p3rq{z6+4;zECO-wbF`lD(qMQWPjs3|6DRHap0sXr=N`4c6IlG!3!yWhRL zUQ7wVJ@d^u=bn4cxo7S@%LOuW@d6>_0vZ1hrwnW{Z z{rLUA5ZCcY?$*eN8TVQXJZR30`xx>8m0AlWpg;kJ0(qXT$O9_yxFQdzz=PGoTp-G; zVpghvsu`*V3Rw#(C{UQ8Fc8*t73TsK?7_c+Js`^STMPdI1%l5&)aR?r%2gn@wIG24 zxfpWgrLb3!Hs_@_Yr$d0ZFxQLsGh)hLVkwGW+a{;HWNKrDQ9+iv(WC`LTTbe7FwM? zM(Zg}oXma>j-S!3lqOPH4jhTm21*mBv)_PI!e}FAM(>vROwM z<`}JEoOpH&vk0RqrHNi^VFVPOm$OWi14%5O@SGy#PRflYJi335e^j`2vBe}I#nr9* zr;nxYxAzob0+zNaIduP&b@#qnv6-E7grGN>rhgQ$q}+`hc;E6|CwiFgdQc zzI$r9HUCeft}u0;ri@LMtoi>^Y!bI36g&|^uGM=^Eg-=0YZFVa|0Ky@sV2@24)}|t zkhF~^9J-rDGWITw1oPcA5`jem5e>nO5M-(rZB%ztx93;bdc|#2w=nK-p1ZcCYB>#S z{!7qx+neqto2jSv!brl3y^{Fi=yfEdC0`3bQ_D-hG+x8d^D(TGUFbr zt*vcJmCd-rnwO^3AO(l#rFlWaMsn8vd2b~*HIw8}x90e-6^BVSD!fVR6qkgUxM@_b zVv}vwq3G89D{pBYoy#nZJCd9x>Yh?D5}@xFSH@&V-Z|Me?B#TBPN;hy)z;hpQi==? z^$(DNo^yjKl1>et>rIhV->HHAvwcG%85tQ_8b9#B7)kJE;;4mWJc%7k9HkY4T(u&7 z(&d#dV|9^i(s+q0<03LxNPPM^vN;l<>Ak#i+*o}s;^-jMuOvT0jdk*C#yat_5KqBa z>4U~f*BkQ`jdAOZZ7dqw2xGp2v9bq^m901CD;ne1jKMdXnb>W;qeg^VuRmiZ_E^}P zM4Pq0wrO$lrUqfVmC^Z9`&iVA`fJ6vlW5PWUE4U)isKx(W6RR(7su2eAOWq>Ho6;l zH3_Hii=<^5w4%p0x z00NSh`OsIx9#^`Qs#rH_wrcp`oVV^ z;L8=qY8^M4H9@uAc!u(jEOTw$GIwEiC-r9L&)UBpLKDrA>x;v5mB~B z99d5DsAs`zu7%J7*pB>9Sm3*5=LG)cgI;>;S%g~}mUL07=r*SH3S%mLr*yWWWO}AT zno3_I&9m2tRz7o$gq@mQFV`IA@M@Ve7I4G@_F8A&AwR3QuLTrbfS*Fa1-NPBdb9+y zFq?Ytl+Pcr`P{U6Ds^W@cWeGJ&Fk|-?Xownc;yWt?%_(V{p_otdsr8;J39^;dPj7Eh29aU&^w~9qx~ALDj-~)iM?68C-!9>pl#U_(DrO? zZfWG|+w|l8%BkRMuMar1QkqTsZPI9TXUfWq*+9UU32;fSt`vG@PNu|EYRhSvIBA*K z&A4d2i^atps>D{Pl4w@9;Ue(N)uUeC+zHS?!Eu0H0F$o(v{McR`zhEAaDaks0JO?} zqyrqL;46SQ1%CzTq@WVuD8S@lfMb;NTYwb6n|}g06Kw|VrTn)6`lx0rzyMYF7GRKy zjsl#cqTRP9N6g9P{NCMqLtVPm3yL&UlT)9NMgWx8MghES-;gGptBrZ_hN769s{21N zEuc$}=f9UX)GJ-ZdTPbTtZ0(tm-#Y(q}Inp!?;vutGMYIoSgJa&q%?s9994uMvaI~{> zcksv}ny&}EK+muiBMSIC#BRk~FyeivkwPQ!z--DNyD`T2Yl+6jzM;}k$kqblNK+oo znv*v(h~`34I25HU)2Jy12idwTnPk(tw|iN7sC8ZVh-`vMRLN#MaA4Czk%3kmiU6Lg z%^J31&Ch5+=A&!LzWBXDvRjM(B!i=T^LZk+Clay54wanfIi>dY5A~;scxc~I^+4MW zk%;j`>_}{fSl`s(KG@!-4y4j&`%j7O=bKXJ-Giy2rWaB}Dmto$!I#etojj8oRMBvy zQ>VlMH5C4jg_$q)yvRg{nOh`blh8owp8c@{ha!z3pX@P?Jsb8Z9@$;y(_I0t z?hJTpeN=G7c$x}S7wv2{Uj10-HQRc%y0VZv{WY64O{YzT-HLPFOdOYjX!8k?k7akr zNq@Tpx)r-3WL1sVgYZD(LSZ>b9SAEyUC<=imcft3vN2cSS+}Iv^nm8TPelO-N~P{t zpv|{kbHl6)%Fd8GY!5lZf^09V(rtlCT?kav)raiqui2~SrHnBBk?GZJ`XdV*Zs)Ku zrH7{V;1pd^~mnPs&ebmbvM% zy~Zk9L!QbZDV0l=GPz8tkSj9F0+Z5?Os=xD4YJ3Y4h4;6Vef3!2DvInnKI^ajLU;7 zgG-mZyrL*n0E0Dhjq<4cs8T1_Zq!%} zQHQCxMQ%|ZlOI#I$=mYo&Kfz{)1^E?<;JueTo#PI@)N6}AQ&`)UGgr)F55E}Oi|rn zm(oB*OqYjl!>SytCc?1nq4Y`@nnZD#*WAmT=CVTj!oE;@`i?ui6Fo_Vr0pE5@M+sa zJHO;Z+gDdY2jr*HcXrNJ>_9iPed>qF-J|$Vq~agD@HzdPh + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#pragma once +#ifndef __STM8L_H__ +#define __STM8L_H__ + +typedef unsigned char U8; +typedef unsigned int U16; +#define NULL (void*)0 + +/* functions */ +#define enableInterrupts() {__asm__("rim\n");} // enable interrupts +#define disableInterrupts() {__asm__("sim\n");} // disable interrupts +#define iret() {__asm__("iret\n");} // Interrupt routine return +#define pop_ccr() {__asm__("pop cc\n");} // Pop CCR from the stack +#define push_ccr() {__asm__("push cc\n");}// Push CCR on the stack +#define rim() {__asm__("rim\n");} // enable interrupts +#define sim() {__asm__("sim\n");} // disable interrupts +#define nop() {__asm__("nop\n");} // No Operation +#define trap() {__asm__("trap\n");} // Trap (soft IT) +#define wfi() {__asm__("wfi\n");} // Wait For Interrupt +#define halt() {__asm__("halt\n");} // Halt + +/* + * Registers map is shown in short datasheet, page 26 + */ +/* GPIO */ +#define PA_ODR *(unsigned char*)0x5000 +#define PA_IDR *(unsigned char*)0x5001 +#define PA_DDR *(unsigned char*)0x5002 +#define PA_CR1 *(unsigned char*)0x5003 +#define PA_CR2 *(unsigned char*)0x5004 + +#define PB_ODR *(unsigned char*)0x5005 +#define PB_IDR *(unsigned char*)0x5006 +#define PB_DDR *(unsigned char*)0x5007 +#define PB_CR1 *(unsigned char*)0x5008 +#define PB_CR2 *(unsigned char*)0x5009 + +#define PC_ODR *(unsigned char*)0x500A +#define PC_IDR *(unsigned char*)0x500B +#define PC_DDR *(unsigned char*)0x500C +#define PC_CR1 *(unsigned char*)0x500D +#define PC_CR2 *(unsigned char*)0x500E + +#define PD_ODR *(unsigned char*)0x500F +#define PD_IDR *(unsigned char*)0x5010 +#define PD_DDR *(unsigned char*)0x5011 +#define PD_CR1 *(unsigned char*)0x5012 +#define PD_CR2 *(unsigned char*)0x5013 + +#define PE_ODR *(unsigned char*)0x5014 +#define PE_IDR *(unsigned char*)0x5015 +#define PE_DDR *(unsigned char*)0x5016 +#define PE_CR1 *(unsigned char*)0x5017 +#define PE_CR2 *(unsigned char*)0x5018 + +#define PF_ODR *(unsigned char*)0x5019 +#define PF_IDR *(unsigned char*)0x501A +#define PF_DDR *(unsigned char*)0x501B +#define PF_CR1 *(unsigned char*)0x501C +#define PF_CR2 *(unsigned char*)0x501D + +#ifdef STM8S105 +#define PG_ODR *(unsigned char*)0x501E +#define PG_IDR *(unsigned char*)0x501F +#define PG_DDR *(unsigned char*)0x5020 +#define PG_CR1 *(unsigned char*)0x5021 +#define PG_CR2 *(unsigned char*)0x5022 + +#define PH_ODR *(unsigned char*)0x5023 +#define PH_IDR *(unsigned char*)0x5024 +#define PH_DDR *(unsigned char*)0x5025 +#define PH_CR1 *(unsigned char*)0x5026 +#define PH_CR2 *(unsigned char*)0x5027 + +#define PI_ODR *(unsigned char*)0x5028 +#define PI_IDR *(unsigned char*)0x5029 +#define PI_DDR *(unsigned char*)0x502A +#define PI_CR1 *(unsigned char*)0x502B +#define PI_CR2 *(unsigned char*)0x502C +#endif // STM8S105 + +/* GPIO bits */ +#define GPIO_PIN0 (1 << 0) +#define GPIO_PIN1 (1 << 1) +#define GPIO_PIN2 (1 << 2) +#define GPIO_PIN3 (1 << 3) +#define GPIO_PIN4 (1 << 4) +#define GPIO_PIN5 (1 << 5) +#define GPIO_PIN6 (1 << 6) +#define GPIO_PIN7 (1 << 7) + + +/* CLOCK */ +#define CLK_ICKR *(unsigned char*)0x50C0 +#define CLK_ECKR *(unsigned char*)0x50C1 +#define CLK_CMSR *(unsigned char*)0x50C3 +#define CLK_SWR *(unsigned char*)0x50C4 +#define CLK_SWCR *(unsigned char*)0x50C5 +#define CLK_CKDIVR *(unsigned char*)0x50C6 +#define CLK_SPCKENR1 *(unsigned char*)0x50C7 +#define CLK_CSSR *(unsigned char*)0x50C8 +#define CLK_CCOR *(unsigned char*)0x50C9 +#define CLK_PCKENR2 *(unsigned char*)0x50CA +#define CLK_HSITRIMR *(unsigned char*)0x50CC +#define CLK_SWIMCCR *(unsigned char*)0x50CD + + + +/* ------------------- UART ------------------- */ +#ifdef STM8S003 +#define UART1_SR *(unsigned char*)0x5230 +#define UART1_DR *(unsigned char*)0x5231 +#define UART1_BRR1 *(unsigned char*)0x5232 +#define UART1_BRR2 *(unsigned char*)0x5233 +#define UART1_CR1 *(unsigned char*)0x5234 +#define UART1_CR2 *(unsigned char*)0x5235 +#define UART1_CR3 *(unsigned char*)0x5236 +#define UART1_CR4 *(unsigned char*)0x5237 +#define UART1_CR5 *(unsigned char*)0x5238 +#define UART1_GTR *(unsigned char*)0x5239 +#define UART1_PSCR *(unsigned char*)0x523A +#endif // STM8S003 +#ifdef STM8S105 +#define UART2_SR *(unsigned char*)0x5240 +#define UART2_DR *(unsigned char*)0x5241 +#define UART2_BRR1 *(unsigned char*)0x5242 +#define UART2_BRR2 *(unsigned char*)0x5243 +#define UART2_CR1 *(unsigned char*)0x5244 +#define UART2_CR2 *(unsigned char*)0x5245 +#define UART2_CR3 *(unsigned char*)0x5246 +#define UART2_CR4 *(unsigned char*)0x5247 +#define UART2_CR5 *(unsigned char*)0x5248 +#define UART2_CR6 *(unsigned char*)0x5249 +#define UART2_GTR *(unsigned char*)0x524A +#define UART2_PSCR *(unsigned char*)0x524B +#endif // STM8S105 + +/* UART_CR1 bits */ +#define UART_CR1_R8 (1 << 7) +#define UART_CR1_T8 (1 << 6) +#define UART_CR1_UARTD (1 << 5) +#define UART_CR1_M (1 << 4) +#define UART_CR1_WAKE (1 << 3) +#define UART_CR1_PCEN (1 << 2) +#define UART_CR1_PS (1 << 1) +#define UART_CR1_PIEN (1 << 0) + +/* UART_CR2 bits */ +#define UART_CR2_TIEN (1 << 7) +#define UART_CR2_TCIEN (1 << 6) +#define UART_CR2_RIEN (1 << 5) +#define UART_CR2_ILIEN (1 << 4) +#define UART_CR2_TEN (1 << 3) +#define UART_CR2_REN (1 << 2) +#define UART_CR2_RWU (1 << 1) +#define UART_CR2_SBK (1 << 0) + +/* USART_CR3 bits */ +#define UART_CR3_LINEN (1 << 6) +#define UART_CR3_STOP2 (1 << 5) +#define UART_CR3_STOP1 (1 << 4) +#define UART_CR3_CLKEN (1 << 3) +#define UART_CR3_CPOL (1 << 2) +#define UART_CR3_CPHA (1 << 1) +#define UART_CR3_LBCL (1 << 0) + +/* UART_SR bits */ +#define UART_SR_TXE (1 << 7) +#define UART_SR_TC (1 << 6) +#define UART_SR_RXNE (1 << 5) +#define UART_SR_IDLE (1 << 4) +#define UART_SR_OR (1 << 3) +#define UART_SR_NF (1 << 2) +#define UART_SR_FE (1 << 1) +#define UART_SR_PE (1 << 0) + + +/* ------------------- TIMERS ------------------- */ +/* TIM1 */ +#define TIM1_CR1 *(unsigned char*)0x5250 +#define TIM1_CR2 *(unsigned char*)0x5251 +#define TIM1_SMCR *(unsigned char*)0x5252 +#define TIM1_ETR *(unsigned char*)0x5253 +#define TIM1_IER *(unsigned char*)0x5254 +#define TIM1_SR1 *(unsigned char*)0x5255 +#define TIM1_SR2 *(unsigned char*)0x5256 +#define TIM1_EGR *(unsigned char*)0x5257 +#define TIM1_CCMR1 *(unsigned char*)0x5258 +#define TIM1_CCMR2 *(unsigned char*)0x5259 +#define TIM1_CCMR3 *(unsigned char*)0x525A +#define TIM1_CCMR4 *(unsigned char*)0x525B +#define TIM1_CCER1 *(unsigned char*)0x525C +#define TIM1_CCER2 *(unsigned char*)0x525D +#define TIM1_CNTRH *(unsigned char*)0x525E +#define TIM1_CNTRL *(unsigned char*)0x525F +#define TIM1_PSCRH *(unsigned char*)0x5260 +#define TIM1_PSCRL *(unsigned char*)0x5261 +#define TIM1_ARRH *(unsigned char*)0x5262 +#define TIM1_ARRL *(unsigned char*)0x5263 +#define TIM1_RCR *(unsigned char*)0x5264 +#define TIM1_CCR1H *(unsigned char*)0x5265 +#define TIM1_CCR1L *(unsigned char*)0x5266 +#define TIM1_CCR2H *(unsigned char*)0x5267 +#define TIM1_CCR2L *(unsigned char*)0x5268 +#define TIM1_CCR3H *(unsigned char*)0x5269 +#define TIM1_CCR3L *(unsigned char*)0x526A +#define TIM1_CCR4H *(unsigned char*)0x526B +#define TIM1_CCR4L *(unsigned char*)0x526C +#define TIM1_BKR *(unsigned char*)0x526D +#define TIM1_DTR *(unsigned char*)0x526E +#define TIM1_OISR *(unsigned char*)0x526F + + +/* TIM_IER bits */ +#define TIM_IER_BIE (1 << 7) +#define TIM_IER_TIE (1 << 6) +#define TIM_IER_COMIE (1 << 5) +#define TIM_IER_CC4IE (1 << 4) +#define TIM_IER_CC3IE (1 << 3) +#define TIM_IER_CC2IE (1 << 2) +#define TIM_IER_CC1IE (1 << 1) +#define TIM_IER_UIE (1 << 0) + +/* TIM_CR1 bits */ +#define TIM_CR1_APRE (1 << 7) +#define TIM_CR1_CMSH (1 << 6) +#define TIM_CR1_CMSL (1 << 5) +#define TIM_CR1_DIR (1 << 4) +#define TIM_CR1_OPM (1 << 3) +#define TIM_CR1_URS (1 << 2) +#define TIM_CR1_UDIS (1 << 1) +#define TIM_CR1_CEN (1 << 0) + +/* TIM_SR1 bits */ +#define TIM_SR1_BIF (1 << 7) +#define TIM_SR1_TIF (1 << 6) +#define TIM_SR1_COMIF (1 << 5) +#define TIM_SR1_CC4IF (1 << 4) +#define TIM_SR1_CC3IF (1 << 3) +#define TIM_SR1_CC2IF (1 << 2) +#define TIM_SR1_CC1IF (1 << 1) +#define TIM_SR1_UIF (1 << 0) + +/* TIM2 */ +#define TIM2_CR1 *(unsigned char*)0x5300 +#define TIM2_IER *(unsigned char*)0x5301 +#define TIM2_SR1 *(unsigned char*)0x5302 +#define TIM2_SR2 *(unsigned char*)0x5303 +#define TIM2_EGR *(unsigned char*)0x5304 +#define TIM2_CCMR1 *(unsigned char*)0x5305 +#define TIM2_CCMR2 *(unsigned char*)0x5306 +#define TIM2_CCMR3 *(unsigned char*)0x5307 +#define TIM2_CCER1 *(unsigned char*)0x5308 +#define TIM2_CCER2 *(unsigned char*)0x5309 +#define TIM2_CNTRH *(unsigned char*)0x530A +#define TIM2_CNTRL *(unsigned char*)0x530B +#define TIM2_PSCR *(unsigned char*)0x530C +#define TIM2_ARRH *(unsigned char*)0x530D +#define TIM2_ARRL *(unsigned char*)0x530E +#define TIM2_CCR1H *(unsigned char*)0x530F +#define TIM2_CCR1L *(unsigned char*)0x5310 +#define TIM2_CCR2H *(unsigned char*)0x5311 +#define TIM2_CCR2L *(unsigned char*)0x5312 +#define TIM2_CCR3H *(unsigned char*)0x5313 +#define TIM2_CCR3L *(unsigned char*)0x5314 + +/* TIM3 */ +#define TIM3_CR1 *(unsigned char*)0x5320 +#define TIM3_IER *(unsigned char*)0x5321 +#define TIM3_SR1 *(unsigned char*)0x5322 +#define TIM3_SR2 *(unsigned char*)0x5323 +#define TIM3_EGR *(unsigned char*)0x5324 +#define TIM3_CCMR1 *(unsigned char*)0x5325 +#define TIM3_CCMR2 *(unsigned char*)0x5326 +#define TIM3_CCER1 *(unsigned char*)0x5327 +#define TIM3_CNTRH *(unsigned char*)0x5328 +#define TIM3_CNTRL *(unsigned char*)0x5329 +#define TIM3_PSCR *(unsigned char*)0x532A +#define TIM3_ARRH *(unsigned char*)0x532B +#define TIM3_ARRL *(unsigned char*)0x532C +#define TIM3_CCR1H *(unsigned char*)0x532D +#define TIM3_CCR1L *(unsigned char*)0x532E +#define TIM3_CCR2H *(unsigned char*)0x532F +#define TIM3_CCR2L *(unsigned char*)0x5330 + +/* TIM4 */ +#define TIM4_CR1 *(unsigned char*)0x5340 +#define TIM4_IER *(unsigned char*)0x5341 +#define TIM4_SR *(unsigned char*)0x5342 +#define TIM4_EGR *(unsigned char*)0x5343 +#define TIM4_CNTR *(unsigned char*)0x5344 +#define TIM4_PSCR *(unsigned char*)0x5345 +#define TIM4_ARR *(unsigned char*)0x5346 + +/* ------------------- ADC ------------------- */ +#define ADC_DB0RH *(unsigned char*)0x53E0 +#define ADC_DB0RL *(unsigned char*)0x53E1 +#define ADC_DB1RH *(unsigned char*)0x53E2 +#define ADC_DB1RL *(unsigned char*)0x53E3 +#define ADC_DB2RH *(unsigned char*)0x53E4 +#define ADC_DB2RL *(unsigned char*)0x53E5 +#define ADC_DB3RH *(unsigned char*)0x53E6 +#define ADC_DB3RL *(unsigned char*)0x53E7 +#define ADC_DB4RH *(unsigned char*)0x53E8 +#define ADC_DB4RL *(unsigned char*)0x53E9 +#define ADC_DB5RH *(unsigned char*)0x53EA +#define ADC_DB5RL *(unsigned char*)0x53EB +#define ADC_DB6RH *(unsigned char*)0x53EC +#define ADC_DB6RL *(unsigned char*)0x53ED +#define ADC_DB7RH *(unsigned char*)0x53EE +#define ADC_DB7RL *(unsigned char*)0x53EF +#define ADC_DB8RH *(unsigned char*)0x53F0 +#define ADC_DB8RL *(unsigned char*)0x53F1 +#define ADC_DB9RH *(unsigned char*)0x53F2 +#define ADC_DB9RL *(unsigned char*)0x53F3 +#define ADC_CSR *(unsigned char*)0x5400 +#define ADC_CR1 *(unsigned char*)0x5401 +#define ADC_CR2 *(unsigned char*)0x5402 +#define ADC_CR3 *(unsigned char*)0x5403 +#define ADC_DRH *(unsigned char*)0x5404 +#define ADC_DRL *(unsigned char*)0x5405 +#define ADC_TDRH *(unsigned char*)0x5406 +#define ADC_TDRL *(unsigned char*)0x5407 +#define ADC_HTRH *(unsigned char*)0x5408 +#define ADC_HTRL *(unsigned char*)0x5409 +#define ADC_LTRH *(unsigned char*)0x540A +#define ADC_LTRL *(unsigned char*)0x540B +#define ADC_AWSRH *(unsigned char*)0x540C +#define ADC_AWSRL *(unsigned char*)0x540D +#define ADC_AWCRH *(unsigned char*)0x540E +#define ADC_AWCRL *(unsigned char*)0x540F + +/* ------------------- swim control ------------------- */ +#define CFG_GCR *(unsigned char*)0x7F60 + +/* -------------------- UNIQUE ID -------------------- */ +#if defined STM8S105 || defined STM8S103 // maybe some other MCU have this too??? +#define U_ID00 (unsigned char*)0x48CD +#define U_ID01 (unsigned char*)0x48CE +#define U_ID02 (unsigned char*)0x48CF +#define U_ID03 (unsigned char*)0x48D0 +#define U_ID04 (unsigned char*)0x48D1 +#define U_ID05 (unsigned char*)0x48D2 +#define U_ID06 (unsigned char*)0x48D3 +#define U_ID07 (unsigned char*)0x48D4 +#define U_ID08 (unsigned char*)0x48D5 +#define U_ID09 (unsigned char*)0x48D6 +#define U_ID10 (unsigned char*)0x48D7 +#define U_ID11 (unsigned char*)0x48D8 +#endif // defined STM8S105 || defined STM8S103 + +/* -------------------- FLASH/EEPROM -------------------- */ +#define FLASH_CR1 *(unsigned char*)0x505A +#define FLASH_CR2 *(unsigned char*)0x505B +#define FLASH_NCR2 *(unsigned char*)0x505C +#define FLASH_FPR *(unsigned char*)0x505D +#define FLASH_NFPR *(unsigned char*)0x505E +#define FLASH_IAPSR *(unsigned char*)0x505F +#define FLASH_PUKR *(unsigned char*)0x5062 // progmem unprotection +#define FLASH_DUKR *(unsigned char*)0x5064 // EEPROM unprotection + +#define EEPROM_KEY1 0xAE // keys to manage EEPROM's write access +#define EEPROM_KEY2 0x56 + +/* ------------------- interrupts ------------------- */ +#define EXTI_CR1 *(unsigned char*)0x50A0 +#define EXTI_CR2 *(unsigned char*)0x50A1 +#define INTERRUPT_HANDLER(fn, num) void fn() __interrupt(num) +#define INTERRUPT_DEFINITION(fn, num) extern void fn() __interrupt(num) +// CCR REGISTER: bits 3&5 should be 1 if you wanna change EXTI_CRx +#define CCR *(unsigned char*)0x7F0A + +#endif // __STM8L_H__ diff --git a/zakwire.tgz b/zakwire.tgz new file mode 100644 index 0000000000000000000000000000000000000000..ae7a81fa9c0a7037e54db2ea4211fb2fef804067 GIT binary patch literal 9623 zcmV;IC1~0oiwFQ?((h6L1MEE8a^qHV^w`N-C~vvq*t zj))+N*<>o4&8GMWF9<0i8zJc@$&`JJ3{%nxiO8MK$#ghbH=YJVPxtuPn*VL-Q0^+K z{3OP}3C>va9WwtyiqGQwXEMB)$_N>l|0JIlB7}bu%mj}=^7*gjx62!*Y?wn``-s~u z6^k22r`_f@%kPPWYHgz@AB+3Sfa8kA%2xjR?na`t+uUB;<@qE@R98oazH0O&Fd)QQ zRR(Q!)R9S|ZXrZ4sVMjF+@-U z2IaWjMseef=#ip!+LGQO%PZ{|cZuYi&2p_--KnjUO0}`uB+7uOieVC?r;XGO*_R2L zH#t(w9_dTUAR6O#3O@x(KyUrcmG;J)E4r-4xMl+wfNppgBfh7G>FaEz=I7@Hta2-O(3@V2Rq+CB2d+Z+dg2;K8_wpCdgtaA%`pCr0K zg^Cs9I8~E6zM;7VWU;GC1|UY=>5GxXQP&5^Q4LeZxCLMnYz@_785Y2|$s5;D07p?c z5YB@a+_IvW^@t=iuWDU%7;)YA1ZY@B4M;=6^K>+jd!6LCXT1!c*(t}e^O(7Gnz%Q5MAzo zTh^8Rktq|!B+{U>s_CS!b(HQ2(t*Cwpd;(V?8(HG^}a#0F1@*4+auTIfvig^sgL$m zrA@Y!wmdLoBEituWAtS3^^^``RFH>Viw9ECfUsmL+8{?{hyyUjZJ1QJC!#%uMKDe@ z9f?FG6FJw3HblG_uzNyO$#hXyCW!A!*}+(Zw0qhRB9PfPJK}U2YUN0VQ9k zZdIG_gAfo6o3--pE~)G^NS@U5jb^pDx0P>@`d*{Hvs+#vWLHMEWF#;}#a%i}pvI1D zN{VXOg1-+FYX#Y!bX$fAZp+GT;7uZJFs0d(heRY*8yv9UYV=d; zk@q*e{{-J7fl5!1I35L;Vg)It9g2dV+&F2MB0qu00#Gbk6a$#TgdW;(cmy3@_v$fv z9Vuo=7>RKnJ-7Ts9*amZOD2mMs!G9?x=iU5U5aI(SQ1DO!8Z?K!-VLOi5@K>MRC$x zPnvzd9!pe@%cc4`zm6yG|mIA!;YjH~1Zb{Cq6rb?4 zjeL!S*!d!pAyADef5!`wcWHYWJ(f+rH3#mmxv z)1r$T3+9e4UYeo4+x0nf`)>Mgn)h~PpWAzT^f~6g(Kphlbw=M9s!xvxr*Z3y9^9`_ zzYi~aBG*~sj7N6&u)O%=S-@=BX6V|b4s0ynLP0RaJ~3$iJJfVY^L&q2sV~fXd?7l( zyx{e0`9Pcy>3_`E+P`iauHd8`cbRwHr8p^cVF1|>GAwwZi{40zXAfUVHa`3SDfnlz zm0H6)ryFilYvbXnvWDI;xsE<}gSNeV6&=1AnUdk^Yze+hz(<=fB@HB4Z#C48q-O&vTY>n2gKAR$XppjC;(6KM9xDGkfCzf_OYw?&P;Xwq~a`4?mNC_jw?r;mx+5#zY+{-{V+s$zcp!2Sx8zwPF`T%QzVEbKe0b=J) zsX;DpkiUywuUB_k^=eHxwOc8tm5JpDkf6x;9?y7VBO5>_?~-xs?v&WrNrtV`;s7WN z-bVEkcwHMD0BXTOwe1bqh52%Ni%zf7jc$=^L|BX6q4b!h7wq9rH=Gr-bt{Mc1*gB@ z>n}R}MNj`-Sv6!znQ9uQ#!=Qzr4k&+X39T`+v^>}?!8N8uqS4XXL6M4E<8$Xt1V42 z?mE`iq}sQ961bEjm;y8m=E7>!wnDuVNhC;~rZl9)62THnSxe{}Vjf$qfzX41Z=_^n zaeSj@)1JWhRjG|{%_Q1UjG-#w+j^G~(q+_|Yov76Tccr%QbRMXp^+NkW!t?dZ7;MX zLniz>v^+XShEbFIx-1>$Y$$<2m0YM4KMp01K?xyH$uTHi^g>bPyH3OswY5L$c4hr$ zin@{|vK056cd4cCtJ2_*?4Q63dsiB%riVzaWoLFU9tF1VnYK;M9>|pCak5C*JvDZ?U0Jl;4-y8wEa07dEcJ(~ zybiF!iYP9kw_5B8(*7ce8d_hbs~G0^P^LqyNc-(YBLD430l$Sp0W;8#y*5={hCqt0 z5CX0|l;JWkU$-8*ZqIU;NA@0!)>ojTW5Izb*7mlxK;|y3hB4L9xJ{)oT=O$zv*nq% zXuBurWZ7^$WdY_9rkZxQdvUUj^8&^WedAN5%UxYIdVwip3x@hwxj!^dEPgmtU{qnq z3iz!Q{9L&b0|N_Kl7f~5#=~6P>&P5o%LscY0Y)qb?87Z(pIp97qLeInSLguBxRkan zaHIslZ;_?dB?N``HL|q6#9R(#9E~5rmv|hRxj*8deF$h4)`5j3fekrG(h{hjt*QX# z+b-sH3o{R~&cV!wV{X8sgazMM1|!2kNKk}K7(&lN=*hnKN16_HXG)mzb#<+ebYO_S1dBwnVhgp^p{5Mz zEG!gm@@ND6aTkO2f;SYwuoRBvk=~)f1=H|{=t@Gk#a!4L&nVypmp^Dy4$AgAH8;lX zzSME40h>0?7(PeGK{kOxf^1VGyK;qvH6S$5jw~6$CfoOL$V4+Eu2IzuKr7!EV zVw^H?@M*O3_zxHexe0_X&|?h*NO~5kFB=QUQM(lbh(IW;L0>?kfqZOx74U7gBy9-; z05v7H1C4T__a(*&xY9nA(aIF1zBU4*^7D^mtwCw*^~>b=IdCD&1-YJ&is*NQV;KqL zgFc72j&lztH8_y%NJRFjEevGC2xJCE3-F_sGp+@OhoNCecX(K*06`78X4%wKor3*B zs)^HU$_Gv|t>C?8hf8VDakx}WkDVwm97FI%)Wp@RSIM;vbm$ud+E-~}bfjy8gSZU^ z;Wm*-lowr5ZF7Kuqqvr<)P|s;%Y8fgP>I0L;NoFE98^&SFG`0zJtb9`4IGg!lwe$A zBjWrmI2H-(G6;rYlV#)nP(_DwUD!t>_65Wd`B>Jq@pYNJWrrE>U>3hTW01*#6Shz# z%Nw}ZDO5+hL-G3Xv`XHzBEi^#fu~G4fW5lGpza>^6jhEU5;f{PFs@ZClcmGKJ$n)h zCTo-)gb*jVP(7omIL6{k9je|DW&wpYQ*B_Wv&pb?Kll5sU)dC8Y~i*(I&kR=L#L zY_*(XrP~ws!N9E7*WBd%G&dpj%Z=wdh8R zR%xr;h&H#Xt!m?MHeofWGH?g4;CCr{egrb#z^dHda4LoTjXfU)!KP4Dwe}&b>Vc_i zDmrMUHukBVqhDIWvUK=MdI>N|~QK7>a3y=JvVANoioXOJpPBUSK`O3ffuoJOkX zBbA;(sx*yM$ww*!@B6E(_{JZFAYR4IK+g`Ur#M54g!|wFXpI?buM5rUw%FQbaX;tw zuuK4&*lO+6x5=q^t)fLsZ){Cus|cyF8&n@;l#beeuTS3@KM){%3UVLH%my*l400O()s zj>BkTxm*Bm0sc^4-GM08RkfqlCWQ0@Szj&S*64IsRNWR@d$_6kZl%?1TyGT`exD!+ zR$+@mqS0QaMhUIfUbVt(d_>20^9!)Z>#DXdsV%H^U%5gHdEhgF9f&Qo#!rij4ozow zRh1!4!##Y57U`kl#3&!t5=STSF36?eA%B8rpjn+}&AQ!iDk zt>jtiO*`sE)uM`hV<&x6nVu}#BAKK>3mI(TFku3@h6w+qAuR~e`=?{_3_6n>G8_urE2jT&G zbL(~AU$GB*`5+?WuhwjA20ON_4#;!va;_-FZOVi|g{c-rOlAAha0uQN(&T1Utkgvh zERG{uutEr|fN$WB|aWEmUC&E7|jt@rmr%e!Lt11?!asEh}AR zU&JKn2Qqz3E&BK+=aFm|K-ed`5C%GAYq#K~bZV2@B-gGH{4Nr2i@WrTQT{mD^(4FH zog$>v`5PrC(fyt?7n;OoCcPufiZdDC+ksDgNk{*WmSc|dKOx6V1(~14bjo2mjN$S8 z1Yc$4A%3w_E>Cx;<#N3NF&Du6q-nzatgF0}kC6KRWB&|bM*Uw%CwY7SKbuYptp3lR z*Z-f!F;@RS{|w-~{(oNopW`zCCj{&Uz6J<92>mEPru9*}heYv0K!C@9M=K*y?N&}XDCO9s3(VtO*i21Kb`sn)9a_me{QAae687%^()skC;lVJcC%U z;GcWcdVd)4V97uC6f6E-GYc#F=jN{Y2Pln|{l}zw#Hzn%oRGqQ?)%mKy&hnW(tqxe ztM0*pCKTSo?d*~3?*36{mfmw`t-J^6PpB8?e*bFke$J|R)>SMClrXo{M31Ucv5}XqtrC@felyB5`Q=c#<_@4^JUw;@s1z5(g9$ zRw&NRt`m<@8LxwngD zy?GD2{%e&cp2!%q?wifd`up!#|4pURS*-tx07k@>l_$ybpDgs%=!2KPvy85`SkDa(cjO01Ltqy{1-U?70!Qy^WWk84>e3JNok-+^ z%m4QvQe9g3%`d2q`A46_qs7aA^6=hI$>oRl{^7xAzhYGHJok$`7q$*xy7SWEh0lM1fOnqz|Msr$ zDT*VH&+P27yMrsZ$gGIY3@E!G;_hNpWMiTt5dsu@sL=@A#;hB(hU`)-T+WP^l3>KQ ztx6$v4=3VzRK=^~FSwU`@gXJU%T?Xu<>jcn-H)okrMwFF{eF99cV$7~Y!{9* zJ>B2#{&x4bzui0E&v!xC1MPmo?U>O;t$eyt{4-ZuFFc((iUoPFpfacoJP%e(wLsuH z(RAh(g{64a>LX}j)!Oo>0el`fw|Z)CZ4Rsc1qVc>FSt3V`WM`6?im+&##KX#o41V2 zXI-m_xo2F>(pe|mTrk4?m)y>|`(JW3v-FBvee@<=*C4}yV=2xNFS)fPj#v2p#N7CE z{$}sO_J(hO4J!Oo;9niGUnD+}yL-3i zPd$#r-Q}6;K~K+mkGqHK;qK<{E`K&X=-JI(&dopMG-vMqL+%;3YtSYr)kki)(p$|5o$lXzYKhx3U(3(kht65u=`?d_!V-6= z5HFbdHK_0DLc9a1sk?ONV~3gZal}mf_&@kocX#a-sp!AqFw!zyEv!fso*6kAj(jC0S5ltns2%f-(CO)IKz0;KMOSow`_rH`+>5>$n4YG z$Kd|G{mzPQs&kRow!za#Sm;+Bi~RO&eW9|&^G2HEkfxH-RKn9~Gfib*$hCN6R_%ny zmY{2K_pI6uw^!iy{Hz*=+pZub*bBD@f;)VC&@Fow*VoiwLf-;y@vJ_+wWij@ux!3oV0}2V{ORztF3c=XmrqYU;f7~nzzyG@S-yQ|8lFHbIFZRy zAWDWqWf1c=w9iOA;H=^K4H?dTDEIN5u5`OaSlow?5wx&x{$9 z;KX7(Bd1}C)P+Y(!6}q{)tG`?0A$xW1!n=WhQmqSGh3uTs-CEVO$N#Rk zLUHPTtxT`b1RqYWvd6q8>MqTzJ2e>Oue1fJ^oOOMn$FVuj1+3PDs{ zb;uq?kVWiqw=BjLUUf=hfR}h#NPP~8`1qh}YT$V8UTz2`X@^oSm#+wLcUq~ItCfHp zP~Mc^oLS-LrcdV9VHI)Udw8==-lkN^RZ5LqGqWPl+j~Pwtz5gR?Uu_|=cMY~ig0qi zcDG!+hLJMl<0;kwu`CE%=JkIv{P!x?H`B6K=}oc)d5YB52}@L-VfinrBt&2>7JV@o&9> z*o^M2snBB6H9qaA6#IumI=cRy)GePL|28&X(>`~<=IHD%29LvXCYQ4=@=zCfd>-hc za_pjVSiXGhoj~sdpAf3lw;tEr{eGWTCY1%8&~LtgQ*z3DO84v#`mpCbQ%tGjP3_L% zaNw2Q)1L}|m6iA$sf3$Ir19&>gRdT_U#kz^Q`^+Y*gxOHQ`J|YdX~cfK`{4!2uSr) zIe__|{oj$-toy&nYl!~>d&1KG?^Oi${TJ)~(wASQFTYA(epxNQf1K&J;TdLgTksct z@`Z+2y)XFg%l5%n-pK6bAAKQwbmytWWL0ocj9Ic^E(`Wol?1QT# z&>S_1pN$dBG=31)(Q~T%oq;?T-b!?x=_XXTzOIk=s~;pf;^)lAB06JN(^;VL*6GCQ z4nhiMOo5qt>HSd{Q0Ke*L~jB4g;gV&&mKQ@aFBh*(A7GO66b1qY?2ue8a*s}4cr!> zT`5)2TUVQMqL84E3DW5+UyCZNoQ_hXaUD=k=7 zQS;f?IutoJp2{XK;TL$vfMfdA^o=n52mKShf#{5s1|dt04}4(SMS-2|z}0XR6Ci^R z8D_fiGaXjDLKe|WDX2QVXHHtYFycI(03k+$2YF}?o@}8~RQ#pMiA>9Q3LOrrsY}T# zYV^ZwJ6RZmR7C2aIxsMugPmI1X$j0&4oo%c?3$wO8KWr&wcjtg%We<0W zbKRY>4fSZYSRccpkuiUxYF1Ne96|;qyS@I2_&}${VE^2}nGNRq8@maSuW|4hUw0&p zuR9QqGo4}`Yuu|H9Z|J0((*>Mi5b0SRjd+Ov#O)1^vJ}O{YB|p)y8Pc8N40x6Cb5;k@+ZtLqBWaA0mEa%LE8ihLo5^iZmDOTm#y`Hz@47g^y}1pSq)?(}H<~ z&F*MzH<-8IY%Q`D>leeOwVTtE+JHn*vA{|tuOXNM&2u%Zw*Ha|z_CXuQJ57{w$u0( zO+W=q#Rh1>=GBa&YPFH@D6)mkN0@DhzPt_CCq|ylxI{*`SiDWhfEYJs-)Jg1fv$80 zPk;~^R)ad?05EhmdR-_f-V1=T>VX|ao z`Rb5Q2}_r;KE%CDDwH)nI)D~#Ns{loOqxLlSa8Xqyv#VF5WuKPXEWpZq$bS3CJ@E= z6H|Rt>{YP9gh0Px%$jp;8|MlrY&cc&$}a0mQ)w-p1DnlHB!5F?_JpFU;%U@M6 z&wtD<%1?0w^nJhoA39|H{h$25x0djKUrk`=Kl$Fbz}07MyAmcHa9f^CWwW?FDIFG- z4vR{MML!fK&~gOygAb7CP-cTZ#ST6&6zOhEQNweejY>uK}X9IK}TH~ z@({$-+Hi6_Nq&`^kan@&V=bf5CW{tnZ(o`X5_DX_7(`lOYh<{%p810{5+v4LbasOW zFQ|EN6BRt~55Q2lm{SaNMO5&LRdixQPQZYoUEFSPJ=7Y>`yMizaCNu{BMp@-)&RnV zvh<|rwRMoVsdBpspK<3)CVS@QtBsWxKh=GP4q|ZCfV~u+CZ;Zrn5ST^_EWIU{Eb{R zj?HWwGyI6W0MXC}wY6z=BQcvNJ3FWIy6DC8SRpDD_OS`ez_E51O$QqBj4lZtmNr)C zox`kmqDNWpu>Bg2W41XyM5iZNf*b=ep8+}kKDli&9S)IO5W0&-nu;CvuuYrU*RK=C zAGyuTjDS>(Vsci)>xP#O)RkGx>#wt@8^##}OuwXUr-k$WofEy`*2rr|_8kF{7THhh z3hc2+I-3qx8b27#T$e4lzcHs%OxRF9 z8hGsdW+2+dzzW$zFR}r<$Tr=r>07PoTPZzlKN{`MoD6`u@kvrH3I@;f|eeRFd`0;nZ9^O z7qh%5)_-I6OtfGQ$86h?m|fM5ZKi_6M7wpHwPioI$SQ?WD1}leg;FSmQYeK|D1{#x N{s*1ZH6j3@001{%_s{?U literal 0 HcmV?d00001 diff --git a/zakwire/Makefile b/zakwire/Makefile new file mode 100644 index 0000000..4d04c2e --- /dev/null +++ b/zakwire/Makefile @@ -0,0 +1,39 @@ +NAME=testproj +SDCC=sdcc +HEX2BIN=hex2bin + +CCFLAGS=-DSTM8S003 -I../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx +LDFLAGS= -lstm8 -mstm8 --out-fmt-ihx +FLASHFLAGS=-cstlinkv2 -pstm8s003 + +SRC=$(wildcard *.c) +# ATTENTION: FIRST in list should be file with main() +OBJ=$(SRC:%.c=%.rel) +TRASH=$(OBJ) $(SRC:%.c=%.rst) $(SRC:%.c=%.asm) $(SRC:%.c=%.lst) +TRASH+=$(SRC:%.c=%.sym) $(NAME).ihx $(NAME).lk $(NAME).map +INDEPENDENT_HEADERS=../stm8l.h Makefile + +all: $(NAME).bin + +$(SRC) : %.c : %.h $(INDEPENDENT_HEADERS) + @touch $@ + @echo $@ + +%.h: ; + +clean: + rm -f $(TRASH) + +load: $(NAME).bin + stm8flash $(FLASHFLAGS) -wf $(NAME).bin + +%.rel: %.c + $(SDCC) $(CCFLAGS) -c $< + +$(NAME).ihx: $(OBJ) + $(SDCC) $(LDFLAGS) $(OBJ) -o $(NAME).ihx + +$(NAME).bin: $(NAME).ihx + $(HEX2BIN) -p 00 $< + +.PHONY: all diff --git a/zakwire/interrupts.c b/zakwire/interrupts.c new file mode 100644 index 0000000..aaa6a4f --- /dev/null +++ b/zakwire/interrupts.c @@ -0,0 +1,176 @@ +/* + * interrupts.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "interrupts.h" +#include "zacwire.h" + +// Top Level Interrupt +INTERRUPT_HANDLER(TLI_IRQHandler, 0){} + +// Auto Wake Up Interrupt +INTERRUPT_HANDLER(AWU_IRQHandler, 1){} + +// Clock Controller Interrupt +INTERRUPT_HANDLER(CLK_IRQHandler, 2){} + +// External Interrupt PORTA +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3){} + +// External Interrupt PORTB +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4){} + +// External Interrupt PORTC +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5){} + +// External Interrupt PORTD +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6){ + if((PD_IDR & GPIO_PIN3) == 0){ // next bit start + // TIM2_SR1 = 0; + // TIM2_CR1 = TIM_CR1_OPM | TIM_CR1_CEN; + PD_CR2 &= ~GPIO_PIN3; + ZW_catch_bit(); + }; +} + +// External Interrupt PORTE +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7){} + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8){} +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8){} + +// CAN TX Interrupt routine. +INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9){} +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_HANDLER(SPI_IRQHandler, 10){} + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11){ + if(TIM1_SR1 & TIM_SR1_UIF){ // update interrupt + Global_time++; // increase timer + } + TIM1_SR1 = 0; // clear all interrupt flags +} + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12){} + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13){} + +// Timer5 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14){} + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13){} + +// Timer2 Capture/Compare Interrupt +// store the current counter value and wait for next pulse +INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14){ + /* + TIM2_CR1 = 0; // stop timer + if(TIM2_SR2){ // overcapture: noice etc. + TIM2_SR2 = 0; + TIM2_SR1 = 0; + ZW_off(); + return; + } + ZW_catch_bit(); + TIM2_SR1 = 0; + TIM2_CNTRH = 0; + TIM2_CNTRL = 0; + */ +} +/* + TIM2_CCMR2 = 1; // IC2 is mapped on TI2FP2 + TIM2_CCMR1 = 2; // IC1 is mapped on TI2FP1 +*/ +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15){} + +// Timer3 Capture/Compare Interrupt +INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16){} +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17){} + +// UART1 RX Interrupt +INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18){} +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_HANDLER(I2C_IRQHandler, 19){} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20){} + +// UART2 RX interrupt +INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21){} +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20){} + +// UART3 RX interrupt +INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21){} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_HANDLER(ADC2_IRQHandler, 22){} +#else +// ADC1 interrupt +INTERRUPT_HANDLER(ADC1_IRQHandler, 22){ + ADC_value = ADC_DRL; // in right-alignment mode we should first read LSB + ADC_value |= ADC_DRH << 8; + ADC_CSR &= 0x3f; // clear EOC & AWD flags +} +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23){} +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23){} +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24){} diff --git a/zakwire/interrupts.h b/zakwire/interrupts.h new file mode 100644 index 0000000..5a17e8b --- /dev/null +++ b/zakwire/interrupts.h @@ -0,0 +1,147 @@ +/* + * interrupts.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __INTERRUPTS_H__ +#define __INTERRUPTS_H__ + +#include "stm8l.h" + +extern unsigned long Global_time; // global time in ms +extern int ADC_value; // value of last ADC measurement + +// Top Level Interrupt +INTERRUPT_DEFINITION(TLI_IRQHandler, 0); + +// Auto Wake Up Interrupt +INTERRUPT_DEFINITION(AWU_IRQHandler, 1); + +// Clock Controller Interrupt +INTERRUPT_DEFINITION(CLK_IRQHandler, 2); + +// External Interrupt PORTA +INTERRUPT_DEFINITION(EXTI_PORTA_IRQHandler, 3); + +// External Interrupt PORTB +INTERRUPT_DEFINITION(EXTI_PORTB_IRQHandler, 4); + +// External Interrupt PORTC +INTERRUPT_DEFINITION(EXTI_PORTC_IRQHandler, 5); + +// External Interrupt PORTD +INTERRUPT_DEFINITION(EXTI_PORTD_IRQHandler, 6); + +// External Interrupt PORTE +INTERRUPT_DEFINITION(EXTI_PORTE_IRQHandler, 7); + +#ifdef STM8S903 +// External Interrupt PORTF +INTERRUPT_DEFINITION(EXTI_PORTF_IRQHandler, 8); +#endif // STM8S903 + +#if defined (STM8S208) || defined (STM8AF52Ax) +// CAN RX Interrupt routine. +INTERRUPT_DEFINITION(CAN_RX_IRQHandler, 8); + +// CAN TX Interrupt routine. +INTERRUPT_DEFINITION(CAN_TX_IRQHandler, 9); +#endif // STM8S208 || STM8AF52Ax + +// SPI Interrupt routine. +INTERRUPT_DEFINITION(SPI_IRQHandler, 10); + +// Timer1 Update/Overflow/Trigger/Break Interrupt +INTERRUPT_DEFINITION(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); + +// Timer1 Capture/Compare Interrupt routine. +INTERRUPT_DEFINITION(TIM1_CAP_COM_IRQHandler, 12); + +#ifdef STM8S903 +// Timer5 Update/Overflow/Break/Trigger Interrupt +INTERRUPT_DEFINITION(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); + +// Timer5 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM5_CAP_COM_IRQHandler, 14); + +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x +// Timer2 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM2_UPD_OVF_BRK_IRQHandler, 13); + +// Timer2 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM2_CAP_COM_IRQHandler, 14); +#endif // STM8S903 + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) +// Timer3 Update/Overflow/Break Interrupt +INTERRUPT_DEFINITION(TIM3_UPD_OVF_BRK_IRQHandler, 15); + +// Timer3 Capture/Compare Interrupt +INTERRUPT_DEFINITION(TIM3_CAP_COM_IRQHandler, 16); +#endif // STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) +// UART1 TX Interrupt +INTERRUPT_DEFINITION(UART1_TX_IRQHandler, 17); + +// UART1 RX Interrupt +INTERRUPT_DEFINITION(UART1_RX_IRQHandler, 18); +#endif // STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax + +// I2C Interrupt +INTERRUPT_DEFINITION(I2C_IRQHandler, 19); + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +// UART2 TX interrupt +INTERRUPT_DEFINITION(UART2_TX_IRQHandler, 20); + +// UART2 RX interrupt +INTERRUPT_DEFINITION(UART2_RX_IRQHandler, 21); +#endif // STM8S105 or STM8AF626x + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// UART3 TX interrupt +INTERRUPT_DEFINITION(UART3_TX_IRQHandler, 20); + +// UART3 RX interrupt +INTERRUPT_DEFINITION(UART3_RX_IRQHandler, 21); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +// ADC2 interrupt +INTERRUPT_DEFINITION(ADC2_IRQHandler, 22); +#else // STM8S105, STM8S103 or STM8S903 or STM8AF626x +// ADC1 interrupt +INTERRUPT_DEFINITION(ADC1_IRQHandler, 22); +#endif // STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax + +#ifdef STM8S903 +// Timer6 Update/Overflow/Trigger Interrupt +INTERRUPT_DEFINITION(TIM6_UPD_OVF_TRG_IRQHandler, 23); +#else // STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x +// Timer4 Update/Overflow Interrupt +INTERRUPT_DEFINITION(TIM4_UPD_OVF_IRQHandler, 23); +#endif // STM8S903 + +// Eeprom EEC Interrupt +INTERRUPT_DEFINITION(EEPROM_EEC_IRQHandler, 24); + +#endif // __INTERRUPTS_H__ diff --git a/zakwire/led.c b/zakwire/led.c new file mode 100644 index 0000000..4174471 --- /dev/null +++ b/zakwire/led.c @@ -0,0 +1,258 @@ +/* + * led.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "led.h" + +/* + * bits no 7 6 5 4 3 2 1 0 + * dec value 128 64 32 16 8 4 2 1 + */ + +/********** one variant **********/ +/* + * One digit: TABLE: + * ***A*** 0 1 2 3 4 5 6 7 8 9 A B C D E F - h + * * * (A) PB4 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 + * F B (F) PB5 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 + * * * (B) PC5 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 + * ***G*** (G) PC6 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 + * * * (C) PC7 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 + * E C (E) PD1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 0 + * * * ** (D) PD2 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1 1 + * ***D*** *DP* (DP)PD3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + * ** + */ +/* +// PB, mask: 0x30, PB4: 0x10, PB5: 0x20 +#define PB_BLANK 0x30 +static U8 PB_bits[18] = {0,0x30,0x20,0x20,0x10,0,0,0x20,0,0,0,0x10,0,0x30,0,0,0x30,0x10}; +// PC, mask: 0xe0, PC5: 0x20, PC6: 0x40, PC7: 0x80 +#defin PC_BLANK 0xe0 +static U8 PC_bits[18] = {0x40,0x40,0x80,0,0,0x20,0x20,0x40,0,0,0,0x20,0xe0,0,0xa0,0xa0,0xa0,0x20}; +// PD, mask: 0x0e, PD1: 0x02, PD2: 0x04, PD3: 0x08 +#define PD_BLANK 0x0e +static U8 PD_bits[18] = {0x08,0x0e,0x08,0x0a,0x0e,0x0a,0x08,0x0e,0x08,0x0a,0x0c,0x8,0x08,0x08,0x08,0x0c,0x0e,0x0c}; +*/ +/* + * Number of digit on indicator with common anode + * digis 0..3: PC3, PC4, PA3, PD4 + */ + + +/********** current variant **********/ +/* + * One digit: TABLE: + * ***A*** 0 1 2 3 4 5 6 7 8 9 A B C D E F - h + * * * (F) PA1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 + * F B (B) PB4 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 + * * * (A) PB5 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 + * ***G*** (G) PC3 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 + * * * (C) PC4 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 + * E C (DP)PC5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + * * * ** (D) PC6 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1 1 + * ***D*** *DP* (E) PC7 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 0 + * ** + */ + +/* + * Number of digit on indicator with common anode + * digis 0..3: PA3, PD6, PD4, PD1 + */ + +/************* arrays for ports *************/ +// PA, mask: 0x02, PA1 +static U8 PA_bits[18] = {0,2,2,2,0,0,0,2,0,0,0,0,0,2,0,0,2,0}; +#define PA_BLANK 0x02 +// PB, mask: 0x30, PB4:0x10=16, PB5:0x20=32 +#define PB_BLANK 0x30 +static U8 PB_bits[18] = {0,32,0,0,32,16,16,0,0,0,0,48,16,32,16,16,48,48}; +// PC, mask: 0xF8, PC3:0x08=8, PC4:0x10=16, PC5:0x20=32, PC6:0x40=64, PC7:0x80=128 +#define PC_BLANK 0xF8 +static U8 PC_bits[18] = {40,232,48,160,224,160,32,232,32,160,96,32,56,32,48,112,240,96}; + +/** + * Setup for writing a letter + * @param ltr - letter (0..17 for 0..F, - or h | 0x80 for DP, any other value for 'space') + */ +void write_letter(U8 ltr){ + U8 L = ltr & 0x7f; + // first turn all off + PD_ODR &= ~(GPIO_PIN1|GPIO_PIN4|GPIO_PIN6); // turn off other letters + PA_ODR &= ~(PA_BLANK | GPIO_PIN3); // light up everything + PB_ODR &= ~PB_BLANK; + PC_ODR &= ~PC_BLANK; + if(L < 18){ // letter + PA_ODR |= PA_bits[L]; + PB_ODR |= PB_bits[L]; + PC_ODR |= PC_bits[L]; + }else{ // space - turn all OFF + PA_ODR |= PA_BLANK; + PB_ODR |= PB_BLANK; + PC_ODR |= PC_BLANK; + } + if(ltr & 0x80){ // DP + PC_ODR &= ~GPIO_PIN5; + } +} + +/** + * Turn on anode power for digit N (0..3: PA3, PD6, PD4, PD1 -- A0x08, D0x40, D0x10, D0x02) + * @param N - number of digit (0..3), if other - no action (display off) + * @return + */ +void light_up_digit(U8 N){ + switch(N){ + case 0: + PA_ODR |= 0x08; + break; + case 1: + PD_ODR |= 0x40; + break; + case 2: + PD_ODR |= 0x10; + break; + case 3: + PD_ODR |= 0x02; + break; + } +} + +static U8 display_buffer[4] = {' ',' ',' ',' '}; // blank by default +static U8 N_current = 0; // current digit to display + +/** + * fills buffer to display + * @param str - string to display, contains "0..f" for digits, " " for space, "." for DP + * for example: " 1.22" or "h1ab" (something like "0...abc" equivalent to "0.abc" + * register independent! + * any other letter would be omitted + * if NULL - fill buffer with spaces + */ +void set_display_buf(char *str){ + U8 B[4]; + char ch, M = 0, i; + N_current = 0; // refresh current digit number + // empty buffer + for(i = 0; i < 4; i++) + display_buffer[i] = ' '; + if(!str) return; + i = 0; + for(;(ch = *str) && (i < 4); str++){ + M = 0; + if(ch > '/' && ch < ':'){ // digit + M = '0'; + }else if(ch > '`' & ch < 'g'){ // a..f + M = 'a' - 10; + }else if(ch > '@' & ch < 'G'){ // A..F + M = 'A' - 10; + }else if(ch == '-'){ // minus + M = '-' - 16; + }else if(ch == 'h'){ // hex + M = 'h' - 17; + }else if(ch == 'H'){ // hex + M = 'H' - 17; + }else if(ch == '.'){ // DP, set it to previous char + if(i == 0){ // word starts from '.' - make a space with point + B[0] = 0xff; + }else{ // set point for previous character + B[i-1] |= 0x80; + } + continue; + }else if(ch != ' '){ // bad character - continue + continue; + } + B[i] = ch - M; + i++; + } + // now make align to right + ch = 3; + for(M = i-1; M > -1; M--, ch--){ + display_buffer[ch] = B[M]; + } +} + +/** + * Show Nth digit of buffer (function ran by timer) + * @param N - number of digit in buffer (0..3) + */ +void show_buf_digit(U8 N){ + if(N > 3) return; + write_letter(display_buffer[N]); + light_up_digit(N); +} + +/** + * Show next digit - function calls from main() by some system time value amount + */ +void show_next_digit(){ + show_buf_digit(N_current++); + if(N_current > 3) N_current = 0; +} + +/** + * Turn off current digit: to change display brightness + */ +void lights_off(){ + U8 N; + if(N_current) N = N_current - 1; + else N = 3; + light_up_digit(N); +} + +/** + * convert integer value i into string and display it + * @param i - value to display, -999 <= i <= 9999, if wrong, displays "---E" + */ +void display_int(int I){ + int rem; + char N = 3, sign = 0; + if(I < -999 || I > 9999){ + set_display_buf("---E"); + return; + } + set_display_buf(NULL); // empty buffer + if(I == 0){ // just show zero + display_buffer[3] = 0; + return; + } + if(I < 0){ + sign = 1; + I *= -1; + } + do{ + rem = I % 10; + display_buffer[N] = rem; + I /= 10; + }while(--N > -1 && I); + if(sign && N > -1) display_buffer[N] = 16; // minus sign +} + + + +/** + * displays digital point at position i + * @param i - position to display DP, concequent calls can light up many DPs + */ +void display_DP_at_pos(U8 i){ + if(i > 3) return; + display_buffer[i] |= 0x80; +} diff --git a/zakwire/led.h b/zakwire/led.h new file mode 100644 index 0000000..07e148b --- /dev/null +++ b/zakwire/led.h @@ -0,0 +1,50 @@ +/* + * led.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __LED_H__ +#define __LED_H__ + +#include "stm8l.h" + +void set_display_buf(char *str); +void show_buf_digit(U8 N); +void show_next_digit(); +void lights_off(); +void display_int(int i); +void display_DP_at_pos(U8 i); + +/** + * Initialize ports + * PA3, PB4|5, PC3|4|5|6|7, PD1|2|3|4 + * +#define LED_init() do{ \ + PA_DDR = 0x08; PB_DDR = 0x30; PC_DDR = 0xf8; PD_DDR = 0x1e; \ + PA_CR1 = 0x08; PB_CR1 = 0x30; PC_CR1 = 0xf8; PD_CR1 = 0x1e; \ + }while(0) +*/ + +// PA1|3, PB4|5, PC3|4|5|6|7, PD1|4|6 +#define LED_init() do{ \ + PA_DDR = 0x0a; PB_DDR = 0x30; PC_DDR = 0xf8; PD_DDR = 0x52; \ + PA_CR1 = 0x0a; PB_CR1 = 0x30; PC_CR1 = 0xf8; PD_CR1 = 0x52; \ + }while(0) + +#endif // __LED_H__ diff --git a/zakwire/main.c b/zakwire/main.c new file mode 100644 index 0000000..e6d1cb0 --- /dev/null +++ b/zakwire/main.c @@ -0,0 +1,124 @@ +/* + * main.c + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#include "stm8l.h" +#include "interrupts.h" +#include "led.h" +#include "zacwire.h" + +unsigned long Global_time = 0L; // global time in ms +int ADC_value = 0; // value of last ADC measurement +U8 LED_delay = 1; // one digit emitting time + +int main() { + unsigned long T_LED = 0L; // time of last digit update + unsigned long T_time = 0L; // timer + U8 dp_err_pos = 0; + U8 curbit = 0; + // Configure clocking + CLK_CKDIVR = 0; // F_HSI = 16MHz, f_CPU = 16MHz + // Configure pins + CFG_GCR |= 1; // disable SWIM + LED_init(); + // configure PD3[TIM2_CH2] as input for zacwire + PD_CR1 |= GPIO_PIN3; // weak pullup + CCR |= 0x28; // make shure that we are on level 3 + EXTI_CR1 = 0x80; // PDIS = 10 - falling edge + // PA2 is output for zacwire powering + PA_DDR |= GPIO_PIN2; // output + PA_CR1 |= GPIO_PIN2; // push-pull + // Configure Timer1 + // prescaler = f_{in}/f_{tim1} - 1 + // set Timer1 to 1MHz: 16/1 - 1 = 15 + TIM1_PSCRH = 0; + TIM1_PSCRL = 15; // LSB should be written last as it updates prescaler + // auto-reload each 1ms: TIM_ARR = 1000 = 0x03E8 + TIM1_ARRH = 0x03; + TIM1_ARRL = 0xE8; + // interrupts: update + TIM1_IER = TIM_IER_UIE; + // auto-reload + interrupt on overflow + enable + TIM1_CR1 = TIM_CR1_APRE | TIM_CR1_URS | TIM_CR1_CEN; + // Configure Timer2: + // capture/compare channel + // channel CC1 (0->1) stores low pulse length, + // channel CC2 (1->0) stores time period between two consequent zero-transitions + //TIM2_IER = TIM_IER_CC2IE;// |TIM_IER_UIE ; + //TIM2_CCER1 = 0x30; // CC2: enable, capture on 1->0; CC1: disable + // TIM2 frequency == 16MHz / 2^TIM2_PSCR + // main frequency: 1MHz +// TIM2_PSCR = 15; +/* + TIM2_PSCR = 1; // 8MHz + TIM2_CCMR2 = 1; + TIM2_CCER1 = 0x10; // CC2: enable, capture on 0->1 + TIM2_IER = TIM_IER_CC2IE; + */ +/* + // configure ADC + // select PD2[AIN3] & enable interrupt for EOC + ADC_CSR = 0x23; + ADC_TDRL = 0x08; // disable Schmitt triger for AIN3 + // right alignment + ADC_CR2 = 0x08; // don't forget: first read ADC_DRL! + // f_{ADC} = f/18 & continuous non-buffered conversion & wake it up + ADC_CR1 = 0x73; + ADC_CR1 = 0x73; // turn on ADC (this needs second write operation) +*/ + // enable all interrupts + enableInterrupts(); + set_display_buf("----"); // on init show ---- + show_next_digit(); + // Loop + do { + if(((unsigned int)(Global_time - T_time) > 1000) || (T_time > Global_time)){ // once per 3 seconds we start measurement + T_time = Global_time; + if(ZW_data_ready){ // measurement is ready - display results + ZW_data_ready = 0; + display_int(Temperature_value); // fill display buffer with current temperature + display_DP_at_pos(2); // we always show DP here + /*display_int((int)ZW_bits[curbit++]); + if(curbit == 20){ + curbit = 0; + ZW_data_ready = 0; + } + display_DP_at_pos(dp_err_pos++); // turn off old DP + if(dp_err_pos > 3) + dp_err_pos = 0;*/ + }//else + if(!temp_measurement){ // there's no active measurements + ZW_on(); + }else{ // error: no sensor + ZW_off(); + set_display_buf("E 0"); + display_DP_at_pos(dp_err_pos++); // turn off old DP + if(dp_err_pos > 3) + dp_err_pos = 0; + } + } + if((U8)(Global_time - T_LED) > LED_delay){ + T_LED = Global_time; + show_next_digit(); + } + } while(1); +} + diff --git a/zakwire/testproj.bin b/zakwire/testproj.bin new file mode 100644 index 0000000000000000000000000000000000000000..09ccd1bdbcc393dbcfae1965b15590eab24d50be GIT binary patch literal 2807 zcmYioTWs6b^^%toDM}0_$|5bvzNBAbiqx@-EXWe0i<`zs8pn{QWlIx!kh3&c0e)=I z$AIAuaO5h9+@BE$6k!8q#feKa0>*s}*he>DKmI7J=C1<=3@Zjy%^twI0hJPDsCO=9 zBO!E-&OMKN&pj`49o>9y9U-)iZr%sj0(b!M5MUeN0{|c3qk&GS_j_3X0pN3hF2ENr z$)3Ra?*RXJiTBTSRLue8U+~yI1K3^vB0xj7SSccOweT!J=j_<0@BijcXy|I8zk754 z36_(+52S(;ET?6gMS4*PGsaTf{fe1a9r~FoA zQt&ye=yOfVxuPUe(dE4Iwbr%DGr{Yn_{jw2+MLT#{2}M!mDW~l>Qf?gV<~Qr#W+HiEq7JS}{6437#9kE)<+*|R$Z9~w74R51U{gETMyuufT?u{U<3lK2*WxhQM z-tdKZu>O~g&aLAPZ^eT3zYWNubsfCR6w7XsX55r7E!mQkiY2dHC_JTDO{j5I&ZWF2 zP396_qm_#{H*<2s+t^tAXpt{(bm~1vTHIR{7ttbOXWqHtNTcW-uk`@AqPO_~Jw_Ry zb23#3IScfDzSBEsxLIsK%zx$!zq+tgcy4`OSwX|V-Wn#ts`?vbP3~JvPgt>G34y)uZ1t??Jy7MB9VDyW?t97CaI_=|3WCS1N&XNr{D!V?gf z9W+{}vKy}@>Oa;wg6+hU>#*%vpz?C zYnpAY1j(*aGDBToQ7~a0lI7|;Yd*GzSXZ?+!AK~L-YdPy?p~(OfV&t z({)28GTaIxe!*30OH6ta0wByVqSycrW~LK>PaTc=vyI)`1nAXQ1vPEKTyWE{`r*u= z(TCDd>i*?@oq5pFLLCis&K>AzOLoLR(XbYPIbDeOqYdj6knaL{xna!!c^*hmm;~}@ zVOZe`B9Z*PzEvpG1dKPS*S^`evLLkzX|GH8YAqrkZU!){-@B&Zw_AO0^pBf_7pPA7sptApC!y>lMs z4I5uXEJOozbGJwP*p znhG2m+ zsOCng>SBmYjz-~)CDVu-gLf0ujw|Z1@Gh7{(s?Rq(0*EW>WChx{5M>}ECPlRfl^Aq zd>C#+)ltK1P`ybr4R)doZ!R0})+dRfXB@3siVz7x0-=nAp@=9E8(7O0Pb3o)nPprg z^0LWU0=#ZHog?_hT~Okdok+Db@7?oOph@2}<0Rh2K%Fx)Bx4%HFi(@y^)A<}o$>bI z9mz8}NKzzarb*h&l5D+;L+QO0Gf(n8ca+3?O+Djv@tIbBl;r!2Nx+T^xjb+QaM_V} zzcx)KfDOmUm^ncv%qcQ8*s${4^!7l(1_d4zULmiTN5~O#hRoEvJe*j0ZhLz=bC`)= zBd?jq$T9OcIX-Z=<@HH?#XP~}UXx_H*gHc`?CBX`up7KiUN<8oQt!c5OgFP)PBT%c z%Y*Lp9?8I`!5WD(d~c~_U%Hr8&n#`ODuCz6+Rme9uDz54+{n%2Eu}0GRfAnNg!rt4?mf`|Ji-( TiFJR~`ldDe<1be&c+md=CNyUU literal 0 HcmV?d00001 diff --git a/zakwire/zacwire.c b/zakwire/zacwire.c new file mode 100644 index 0000000..3ba6605 --- /dev/null +++ b/zakwire/zacwire.c @@ -0,0 +1,149 @@ +/* + * zacwire.c - functions for zacwire sensor processing + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "stm8l.h" +#include "zacwire.h" +#include "interrupts.h" +#include "led.h" + +// error codes for zacwire bit converting +#define ERR_STROBE_TOO_SHORT 1 +#define ERR_BAD_CRC 2 + +int Temperature_value = 0; // measurement result +U8 ZW_data_ready = 0; // flag - measurement is ready +U8 bit_cntr = 0; // current bit number (in ZW proto - to omit start/crc bits) +U8 temp_measurement = 0; // flag - temperature measurement in progress +U8 ZW_bits[20]; // values of pulse lengths + +/** + * Turn on ZW & start measurement + */ +void ZW_on(){ + U8 i; + //EXTI_CR1 = 0x80; // PDIS = 10 - falling edge + PD_CR2 |= GPIO_PIN3; // turn on interrupts + for(i = 0; i < 20; i++) + ZW_bits[i] = 0; // clear old values + bit_cntr = 0; + ZW_data_ready = 0; + temp_measurement = 1; + PA_ODR |= GPIO_PIN2; // power on zacwire sensor +} + +/** + * Turn off Zacwire + */ +void ZW_off(){ + PD_CR2 &= ~GPIO_PIN3; + TIM2_CR1 = 0; + temp_measurement = 0; + PA_ODR &= ~GPIO_PIN2; // turn off ZW +} + +/** + * Convert 8 bytes from ptr into 8bit value + * @param ptr - pointer to 10 bit word (strobe + 8 data bits + CRC) + * @param val - 8bit value + * @return error code in case of error + */ +U8 get_byte(U8 *ptr, U8 *val){ + U8 i, data = 0, crc = 0; + U8 Strobe = ptr[0]; + if(Strobe < 5){ // strobe too short - error! + return ERR_STROBE_TOO_SHORT; + } + for(i = 1; i < 9; i++){ // get bit data + data <<= 1; + if(ptr[i] < Strobe){ // logic 1 + data |= 1; + crc ^= 1; + } + } + // now check CRC: + if((ptr[9] < Strobe) ^ crc){ // error: bad parity + return ERR_BAD_CRC; + } + *val = data; + return 0; +} + +U8 get_temperature(){ + U8 H, L, err; + long temper; + err = get_byte(ZW_bits, &H); // MSB + if(!err) + err = get_byte(&ZW_bits[10], &L); // LSB + if(err){ + if(err == ERR_BAD_CRC) + set_display_buf("EBAD"); + else + set_display_buf("E DA"); + return 0; + } + /* + for(i = 6; i < 19; i++){ // omit first 5 zeros and strobe bit + if(i == 9 || i == 10) + continue; + if(ZW_bits[i] < 10){ // logic 1 + Zdata |= 1; + } + Zdata <<= 1; + }*/ + // correct temperature is VAL/2047*70-10, but we have integer (float*10), so: + // T = (VAL*700)/2047 - 100, result have only 12 bits, so we can do this + temper = ((long)H<<8 | L) * 700L; + Temperature_value = (int)(temper / 2047L - 100L); + //Temperature_value = ((int)H)<<8 | L; + return 1; +} + +/** + * Get bit value + * TIM2_CCR1H & TIM2_CCR1L is zero pulse length + * TIM2_CCR2H & TIM2_CCR2L is time (for previous counter run) since timer up till 1->0 transition + */ +void ZW_catch_bit(){ +// U8 H = TIM2_CCR2H; // length of previous high level signal +// U8 L = TIM2_CCR2L; + /*if(H){ // error: pulse too long + ZW_off(); + display_int(H << 8 | L); + //set_display_buf("E002"); + return; + } + ZW_bits[bit_cntr++] = L; + */ + U8 i; + while((PD_IDR & GPIO_PIN3) == 0){ + ZW_bits[bit_cntr]++; + for(i = 0; i < 4; i++) + nop(); + } + if(++bit_cntr == 20){ // all bits done + ZW_off(); + if(get_temperature()) + ZW_data_ready = 1; + else + ZW_on(); // in case of error start measurement again + }else + PD_CR2 |= GPIO_PIN3; +} diff --git a/zakwire/zacwire.h b/zakwire/zacwire.h new file mode 100644 index 0000000..b5a6129 --- /dev/null +++ b/zakwire/zacwire.h @@ -0,0 +1,34 @@ +/* + * zacwire.h + * + * Copyright 2014 Edward V. Emelianoff + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#pragma once +#ifndef __ZAKWIRE_H__ +#define __ZAKWIRE_H__ + +#include "stm8l.h" +extern int Temperature_value; // T*10, in degrC +extern U8 ZW_data_ready; +extern U8 temp_measurement; +void ZW_on(); +void ZW_off(); +void ZW_catch_bit(); + + +#endif // __ZAKWIRE_H__ diff --git a/zakwire00.tgz b/zakwire00.tgz new file mode 100644 index 0000000000000000000000000000000000000000..bd9c36375545d6f46da5a40df50c6cabf1b926f2 GIT binary patch literal 9189 zcmV4 z0)iuZJUVa_Xb?SWppou|DB4u)I437xkUZx}4}Q>RWSKax$uHy!>}(IIs@ppn3uQ~1 zIl~sadHXJPYr9o-Z?&Y))W;XPrERah!b^m!n9uXyg&h5sa{RY@tx2+6RC4)(Sd`X8 zNy*q`YftJF3Oln%3`MF7BsU_Ul0C^j7Kkz8ps z_lDY2`Ai=RLbbYoSblJ_m#v+2j&@E&QDND}_SCkv?V$<^grm0ganG3cHI^OO&S-~a zv*y&v4n|H^A3hZhYa9a08oV{B6LdK_aA)e-j-ihqKap8>f?aKxR1i+u)xGyp7rN2! zsaBtDZuQc_ZC37d>dj8$xVg*r8|{-0)5pxvZHL)Ib87V2nZ{7P*@f;5*+|vLskCrh z`7?k7@OIzd>g~P1WobrQ=(GU=sD{Qgi?rHKv_iE<(F!2T9e+0h*S@5V$m;YK5b2kV z$9{37PJ~9YR&Uke(d={&>g8I!eX@si8(Tv`*lHadH$UEGs$mEMJa+w|ARgu|UqPUW z(`=W)+zdM#9=~ASO+vg*N`o)VnP2Nd+$CH;4=y*LOF!HyIPcXn^@Ki zvo;tGGww!O0EVm7FlfR=k!AzBcUehz)64LUU7r0nwEkA_70t2O{!4{|O!mJh<&|7f z7Qz0@igIKBU(2<jO(uV?;tLEg=($9wulR-+X-oHRI`-?4BA8CfJj?KY<-A8VH zXshOyHT}RH*BRSQ%7UE!_;wq z+qBro?CXO|gadWcabL5TGt`))StFa71A2MTJY^5Gv1X|TYfaA#y~hsqo;J2Mroz-% zV-Gd3^#lh;>>~~*E)Hzp1i-4Jo8uDGzz@J2Pe7>f&SY;67hr~&76M7B4q|RGbAsd2 zfbJzTR3{j^HHZ9w%0BucggrDTK+zCD0*&Cn4D?E%SA(gMK@iZHJ#2Iij!!$R-29k5 zEVtX`X6NG)c`fjgOnahnQ2JAMx!q}0PY=s&);evsj!)`ajGbtRmWBWpuy{aH0yg$FN7W76Bm83!tm|Zl z>JtqF+|%?YfSbyCpi0Yyhd@-r9G`RN?1UIuV)}rMO((-HEFJX4F=xe!!vo1?SYzDV z%CNiyz0~nz2q4&r1N{NUzCHl>`-W*+8CEfE2f7p2%1o3cNz6jrDP`E{Nf~L|7KGbg zJafx+!?!|JxMrY2;4A1%cWl6v;Z=mY0Cyhl9NY@rGTai}B6jX;J@!O3rW(}AJJ1<= zDbPcLQ9JG+8o<%m-t;eKjx`u+!8&wUP`&M9aSW|}{akl;+1v}1`ToK-@=&c^{$_1vd*ifGEzvu>ugQF2vYKX-*9ld>ny?55jy*JwS*BmIPuJ$Iz=d z7so0>EVB7zCbCirsIC*7Y5=hg5Ni^P4~WPiX_^E+a?(>ZgecFG^*rfE`B)=9Zq{0x z1hJKF)f5&&ZM7dCVsLG4(rSW*vb_xol!0A<{dkv&PZcqPDvCvkig_%`qHwzpF*U5H zR;61xEH{5neFcaY957y|J6Mm){u62E5!+**iy4B2L%j#Uqd)ZK7I_`@^b1h=tVDQK z1H3durs^Vt#R3*{R4ig~$3qb+dRvT?>Ij{{Y+gK{hvD=l9C%BH4rJqIKCGZ6+dzUcGMB5$M zoRw`i{VcNH0qrYW?+`y{>^Is*@>tshQQ+|wD31s0Q6vlM8M zRHPwL+Rs1>6o>4J+%nbIS{d3cntY>4;Xc-H*b}vrgrbDskRB0JbgK;0vapN=F0Hz#(@%8SCd7~9R+MvS$U>NL1txMRhjn83d#UJYF8=wpF z@@uPptv*N{vinThNq96+u6?6Egg!L7_z7nag`t{XN{WHz5HG)i>2GRJ; zI^N%p&*LE#oh7IZ&*9ZRBN{xx?1-F>S}W*}6nkvT(}-ujwsna6u1x}yaseVh#o#8a zNxGG2ome)@$`sPD8V>|(JY=n*ZAgc7wFyLzW44jNrZc#s=3>v{epT(^u9>C!x;-&e z+^r8dAWK881xiX%?@lLOf`)3^L?yMs%JzmSDzEocTVvubltMg4gpreHmZm-~dA%gw zs}}UiiL<@rnO;&tFJ-2eD2ICy^8+K|lG;6+4hEX_Nsdg(2HVJl?q{UwXNEd{%+4-h z!#+@_h7$tP?0S(M%txKQcg}6c^ycy9KF|%rW_;FgdmuKOObnhIfe8wFWWbA!9aSIO z>=p=da4S$3JHu`<{!YpcuUofV^MinaFYEZGJyk~&L)(SE(v~dWLThzvD5+<+Sjsj> z8m(fG@nemq*iz4Wx0v=9QyuIU5(UUWJ=S_qEe#wgnnG~6+C+oL*m>7&49uQuE-$@(gv1h4`U+Z3x;g0Hkvq>EFs1XsI@qlo{JMKL4GI?1Bpo#gl!u$R zcM&4eSc#`)p%(gPR;e z9F-rtZ-_WEH-F3@_9+Z=N1eN)RL~)Rkh%fv=c_6<^21={19xN@e4RhCoIG+5nzC;H zkv^W<{(vkEC?pLSx&wyVQ@{I=x)+nWA0%`?nBRSC!?VyCR3ygN=fu*U=;qXBs5Anp zBZ?XL&U;^&7U-R$V#qhJ%n`zYDMl(R64muBq^lECACnZ;E1!s{1LD&GI_veYD}rgM zACDu$Q-cX6_lLvvtn`SRupN;@zy~gW;G`C(?Ojqgj_sM+51;{>-k6#30?mVH0)#9( zA|<8o}g`kx`Tlz_kTq6jz0j<$!Dn7TO1lerK~_r-s=qsc&p$^oBTJ z<&&dFF<*ExgxQ+FLpOdOct#*Kn2xz?veYq}U`HQm)-oTbkNxrF?LzhgCPHjt?hE+X z1Ok-MLXAXYF*=%$($FL33Y$^{fimHjk2?iVlEOiD#gZF0{VPz64V`A{yOD zQ5~66P^u{Y2-cmHd~cK{-_C&v;U*}sd_-c@5Y9v-5D!KS;x5V_RBC*#d7g-!kuHoi z+m1yBb{EE{Tw~mfO%GGUl)?0{PN4@Wa?{nRg**lQg-{d4>uBeGFsA6dF-1o86 zosgdBFdZKd_Ndu=_wKR#duY)27?kf(V02-bZ)j} zz=ZvJ%D;fPV4rE0IlC^EN1mGrPv+t)as)XYD6sVg+uXy&PQCi(=QM5vtqu0R>j`ES z4776Q!07Eg-s{=LP&c$xHrpiQfqt#wsw_ zuGv-5{@OY%L_MY+enX%k)-0{`66dv!ry5qf9cf9xN zj(5WhF)h%kJ|5FcR|`nWT@_ZPM!g0#d3lx^^%~T;;{$4h+u9hcCB{I3?!Bb__xwMG z)|NG$IQ9?!8Q_xd|8kQ1{U3e*uN2qti*WJA|G$=t`~R@?Z^D3^FyJN(Sot%+(9((2 zf2Q`(u<}m?w^_%WutSiW0f@N+ghsPdZ?{idoh}Hgc35wxI){yJqy6Uxuo?^vu!Al5 zGa6o=0?iNcRPJ=L5JLIkX#|4gL8uyL?=h_Ev16GAG%bWuJ^XnDitItDKZQYKHADq# z9k)B>1Q_*?I*l$hMnEY`KvfojszgBLmVl}*0#%KG$}a&`TLh{W0abAK`zdhY4NL`w z@~5Gr89E|70}DVW%n%-IZ_0)+og#``vPt1NGd4n2t3}2v#B>*8e>H$Ckhiy>m9=DFzmH$?) z$^3yb}uX2;MKMJ8@fu)9?TS?2S-0ZeLn#II})42wmP880)1d0H4 z#5_QlCOT;~R+|MnMoo%ul{$DPFM&w{qpNKngDV^u=EZgg;)Zk0+OA;!b+Nr`97)|% z%-sHBzuRd)=vLZM!y`%VYNDQ~>32xcpwvBW?DM5GrTK#(2DJ2nVV z!wl$v1EWL&onZPf{S>aDK`e+L3izNyw*VJzaMHhP%0@lzC- zl(qYnL^m=a#e+yC!Q+v<$;bs<_p3EX1G>;7vd&}ubAfawgQJC z&vPKZeCVAg%%lYTuE7dKr{JzZD6*84{Xk6P_coZvvSGz(5G30U!+P>?l!owlWCJ8} zew+@;Ko8QAnzJy2g94jBu0E%^+e}5IUBT(6Gm#}@LPA1?k z092a6I4ygL8PBnZM;%5*KkpQabROs_ZyFyLZXd{P8O~sW;{Q9 znZUxUEY4PnNtIwjsq$9>ejXd^&zs^g3tHE?u}nfeTHLg65|x)TxypQ#n~#`W<+@Ht zNw%AX$lUY7uH^N!;!1K?2GT1dWA!CWk>iY& z#V})KWbASnF~-VL0%K!Z9n;+F>gb~FPol{v2aHixVT`hvG0G~8QC4Ei9F3b@?BzGZ zvT_aG&!RIP=ny4S=44`M$pJ{q07x?cgmtLy^0;*mVRUQlLwD=MKLN|q7hxj|b4U2; z@`dJ|`0;Pj!434;;YlS7>B<9j!0z8?_#rU9R!`^?X$Tw!p^aDlxC%i``C-l9bbU|B zC2pt+^Y*LD{7fOTQ;o1s@%jI9`<+?*=j?ZKapadFo%4}SLU=Yl!DAI|f}g0>>x&I) zz20hr&xLML(6sq`(`k*HYsD)e|M!D`2DBvqC*>8<`~IhxS0tYQ6L0c=uj87@|J{5B zbd&$P$^WhJ8IbQ0PhwvK#TpVn3eqTb0UC~wt!%uts z5R1C&NL@oqYSpqDci(Ck-x&&A}8@UizZ3(b=K5`+j`VwIATwLj8Q*lYa~`j%A>4Wcv@b%?qPWx_MG$b zBs+C;Tt4r(JjB#_C+4N)2j(+SX3xwM-N&muG7sUDaB5z9J%{Eo#w4AamzE!!&p??y zAf93G@4&%%jI5-y^V0I8^BE{BFz0vn@I1UbNjN_*#r!fTL1yWy;vRSIaeH*inG^T# z&D$T~csuGD7M^g&IrJtExT9##J>yP}E0!N|hqo$oPq|CczlRaq^}p$Jy;U#o{MS92 zcqMbtxo@$!?Einj^WR)9Pk;YIhHgyW+IppU(e-ze|WLBw((=@cx~;McmDgu zT4Q7V-~aYU|ABAcee>m)?Vonv`SCk{*nQ{iciwu@`o}L`eDUeGU%v&-@Rym`o)X3 z`uvZfboLzId(Zz9o}K4!!L#-JZ@zo+|Lt8(Y#YZF-sO@axe`tJr*dMa)W&v5DK^C) zMV26@X&gzm6iF~aN>N}XU=)gx4ay`zQgvO%aFoi1a}$s#LVK_+SRr5oB?|P?Yje;c zu;O!1%`v^Dhf)nv)P3*G>>o)vZsWKpz=gD2&d$7f^XBc$o8i9i#rNRdDWQB6&i1kc z&K5e0bKB5-j^H>DDbl+$Y{?{o~PINbZ!r6vR$3 z|F$6eev(fJazt=O1P2uyw`^a3a|Leg@!GaOTvw#+4?o`$tT#%|w7k;p{F7imT1FCf zBw>SUl=WHH@&|NOqV3hs9NuGhQ6{ ztH|hGK?F|k3hTh=U14qYfgn8)M96U!GsXp=W2;X3T<}3;fh*+&xTt<+^*LF>pOpij zS@bV&+dUB^(F%OEDz-bq=@$-TPWMq4Wa|5a z;OzUC;80q>6k6Ye9Qn5d*Q~T0vzF|eSJR-T?&{|6;7nX@{vFw=L~Yg02XKZfxw>hG zGu=&FOX9}9W5X4}ee1BeeiKArJ!Dl&q@{}Ryq+$p<-q2Y-6$(ND-#>mz~4L_Ug`d|{HM}e?n*Y00C4%hFTu)6mu*0Px13*Qz3 z(pkk)77y&5^tF^{c%D}wPdnvlhi_-pJnfS{Te*Kt8G%H<*H-@NnlcEN=izc@O$or| zsFyMvgUcT8GcM6<_c+QAcNA};)CO&FRPTMTqdW_D74QDlL`hs-&wuMENguU~*H(Ah zM34Mdr+j}US87XJN|v;{ETyHAd*h-1P@*KEEIM6@lA8#5TsyK`mXxn%_oM8kBhP@y zZXK3bAKuvh_4rCjf{$-kmbZklHPETCn>V(vEv>+}4e6*Ag}e;I!kDiGQeKDl@!T=1 zTlCoP{PWp>9X@<+e_Q4H#gDdEUYoVtzdoH{S01~!r6P=8Rpud&AoMsvR8T6~X~&L} zfN#sVJT7>gA8lXH&stYMPLwRbwzPU{M@#?xthLiFLpwJfo?rr=^jU%MmP_=xCVet5 z0^I|Z6m~N9tW@xu)1y3V>Xw~2T4)I;&F6J9vRuQd*o=Rs8~DX zgJOs1ky0N+CNVl|TaGzAt*o?zN;_N*DBX&sTRTOMi`|pxp5&5z?WH}hrtN3PRyqe z%}n)d$*REyloTSd63#4CBU23=l&~Z_%}h=q$OvbT;G>Z-wOU4vxnR~8G&hXo?_l&OT`)z3;>#8XfuEr11;ua#0tqO zfK1)}+*0AZAM2`VKKpf^5_9=fAvuR{-24nAR=SY65`YirkI)rFW28I?QObYNhsP`g z;v7^$fe_wD`Sx*#*=T%7^9<7xCMXASGZBBy5OfhA+aiovq$?;wRaXi+PgMKdQZeh# zr!c;tlA24NS3(yHgX9VZgCJ4|OMzkM^o|Vhn&HkUPmAbD`O0q9(uQnaT6hLzx4m%VHN5FQsr!xrBb1Fc>qqL-Z8% z7h(Klz=#E;xGO3ERQA3>j!Hz!{ewINAv=ypXh$GZ$;*SJl-vsswT>yBT=Uq%K*;rZ zF_kQ0Fq+v@@L0aBczMl6@9r$Q9q3*O$ZNQlyD3Z!b7eyGDdWJAJddNN0`vO<2XDt3 zs8(heN=wvfKs(T?-95gylaIcH!8PI>C1mCaV6B`H(AQm%&@kQL=Og7_Z zz>zT4GI&%nW4vGxq*LrEQ>$hj(62Vikf6r`$k6oBMN@Akm6|Vr^nfgnO#sFZOxtAt zFky2!nmpw}M_97QYfItpC4o6lCzmzNMUmHJ^gs(@{r((tDd%^YbZ49#NgL>oHg zE2xnK!1^;}(b|{IFo$h}-!5oKHjmEfAo)xoo7b|c-sk9vT&FlAuyADHxQ!a48x@Fv zYz}k*vk}E-pvD-i55#1pWM_>@LXOAO{3~3$rU&YE3XBI-Db3I#$XustFxBcxBRxj) zR}_Zr7GkK!PjmgJuK!gN^~cx(_@4EDe_v3I|JoM}_fh=saBtK9IqvxP7oHFgFwDsbIjZ&K(1 z)X;8NoLj&^77c6^c{+3wi!)j^MOkU2tSn@U7`))z49dQkO=cId-ghq)6Uj_5Utdl! zM#y%3>J^MeHo@C7`UJ|4inVx zZD90isP5c=ftlSb7};rRuiVg*Yrr<*vXKXbYKaf9wNZ3SgP3#pny`)F7wdMR-NQ$jq4{Jgol($ZiM?%2m7K~{-(9tc^Li)h992Q zMf5Pza8iE2;&0c*rlK!D49hrtn`>++`~%QjdW~o<1nNWUPgqRx_1RKJ8(7aqCkK_> z91O;g<1!A*IaJ+&zKezDO;}B}P&R?UW5V9>y*fWz)|0orw&`FdvdgwZ15CaK@jlM+ zZ7h?n^Ee(RG(r>pR70%}MojVJ%sQ#r;pb)yY@A84v4CkH^2ItN78+$>M(oQ3_DDT+ zks*KBm_JPU$wKck$J*i0T+ox<9G!{*Phs!j{EB+0=$jrUsTlBwN{EsKBho07KIedi z#v|5n64Pp>r-L2~{)}jW{d9&=zzv3Z2AKfeIKg6LsKd?i%i8j|PDwY$p#^NYm3$Y=~F0fb$j*#@U0`d3iHlnt{zwA7_&HeUhIbeEbVGw&%i->Qe#X-ahx=&%=cQ0{|L18O=KY^0_(yYBr@5>1 z7~mi0PL0ou#YSq7Ka8o3wu21t9d)xcO)FC`qJ07E&ZidgLu&ro9i52bM(s*0V%oEa vm{)a?M$4IqY<6TaHsXIhIyH~x(L9<*^JpH;qj@xsCw=@I03DUf0H6Q>Eb93u literal 0 HcmV?d00001