Remove paper cutter servo code

This commit is contained in:
fruchti 2020-05-23 18:49:14 +02:00
parent 128deaee57
commit e4f5946c8c
5 changed files with 2 additions and 88 deletions

View file

@ -1 +1 @@
511 519

View file

@ -18,7 +18,6 @@ static State_t State_Idle(void);
static State_t State_PaperLoad(void); static State_t State_PaperLoad(void);
static State_t State_Printing(void); static State_t State_Printing(void);
static State_t State_PaperFeed(void); static State_t State_PaperFeed(void);
static State_t State_Cutting(void);
static volatile State_t State = {State_Idle}; static volatile State_t State = {State_Idle};
static void InitStepper(void) static void InitStepper(void)
@ -139,27 +138,6 @@ static void InitThermistor(void)
ADC1->CR2 |= ADC_CR2_ADON; ADC1->CR2 |= ADC_CR2_ADON;
} }
static void InitCutter(void)
{
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
GPIOB->CRL = (GPIOB->CRL
& ~(0xf << (4 * PIN_PAPER_CUT)))
| (0x09 << (4 * PIN_PAPER_CUT)) // Output in AF mode, max. 10 MHz
;
// Servo pulse length should be between 1 and 2 ms with a period of 20 ms
TIM4->PSC = 48 - 1; // Divide to one microsecond
TIM4->ARR = 20000; // 50 Hz frequency
TIM4->CCR2 = 1000; // 1 millisecond
TIM4->CCMR1 = TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1;
TIM4->CR1 = TIM_CR1_CEN;
TIM4->CCER = TIM_CCER_CC2E;
NVIC_EnableIRQ(TIM4_IRQn);
}
static bool HasPaper(void) static bool HasPaper(void)
{ {
return !(GPIOB->IDR & (1 << PIN_PAPER)); return !(GPIOB->IDR & (1 << PIN_PAPER));
@ -274,17 +252,6 @@ static State_t State_PaperFeed(void)
return (State_t){State_PaperFeed}; return (State_t){State_PaperFeed};
} }
static State_t State_Cutting(void)
{
// The timer interrupt is deactived once a sufficient number of pulses is
// generated
if(~TIM4->DIER & TIM_DIER_UIE)
{
return (State_t){State_Idle};
}
return (State_t){State_Cutting};
}
static State_t State_Idle(void) static State_t State_Idle(void)
{ {
if(!HasPaper()) if(!HasPaper())
@ -341,30 +308,8 @@ LTP1245_Result_t LTP1245_FeedPaper(int lines)
return LTP1245_OK; return LTP1245_OK;
} }
LTP1245_Result_t LTP1245_Cut(void)
{
do
{
if(!HasPaper())
{
return LTP1245_NO_PAPER;
}
if(!HeadDown())
{
return LTP1245_HEAD_UP;
}
} while(State.fn != State_Idle);
TIM4->CCR2 = 2000;
TIM4->DIER = TIM_DIER_UIE;
State = (State_t){State_Cutting};
return LTP1245_OK;
}
void LTP1245_Init(void) void LTP1245_Init(void)
{ {
InitCutter();
InitDataLines(); InitDataLines();
InitSensors(); InitSensors();
InitStepper(); InitStepper();
@ -500,33 +445,6 @@ void ADC1_2_IRQHandler(void)
} }
} }
void TIM4_IRQHandler(void)
{
if(TIM4->SR & TIM_SR_UIF)
{
static int ct = 0;
if(ct == 0)
{
ct = LTP1245_CUT_DURATION;
}
else
{
ct--;
if(ct == 0)
{
TIM4->DIER &= ~TIM_DIER_UIE;
}
else if(ct == LTP1245_CUT_DURATION / 2)
{
TIM4->CCR2 = 1000; // Back to -90 deg
}
}
TIM4->SR &= ~TIM_SR_UIF;
}
}
void DMA1_Channel5_IRQHandler(void) void DMA1_Channel5_IRQHandler(void)
{ {
DMA1->IFCR = DMA_IFCR_CTCIF5; DMA1->IFCR = DMA_IFCR_CTCIF5;

View file

@ -13,7 +13,6 @@ typedef enum
} LTP1245_Result_t; } LTP1245_Result_t;
#define LTP1245_MAX_DRIVE_FREQ 473 // In Hz #define LTP1245_MAX_DRIVE_FREQ 473 // In Hz
#define LTP1245_CUT_DURATION 50 // In steps of 20 ms
#define LTP1245_BUFFER_LINES 64 #define LTP1245_BUFFER_LINES 64
#define LTP1245_LINEWIDTH 384 // In pixels #define LTP1245_LINEWIDTH 384 // In pixels
#define LTP1245_LINE_BYTES (LTP1245_LINEWIDTH / 8) #define LTP1245_LINE_BYTES (LTP1245_LINEWIDTH / 8)
@ -23,4 +22,3 @@ typedef enum
void LTP1245_Init(void); void LTP1245_Init(void);
LTP1245_Result_t LTP1245_FeedPaper(int lines); LTP1245_Result_t LTP1245_FeedPaper(int lines);
LTP1245_Result_t LTP1245_Print(uint8_t *data, int lines); LTP1245_Result_t LTP1245_Print(uint8_t *data, int lines);
LTP1245_Result_t LTP1245_Cut(void);

View file

@ -18,7 +18,6 @@ int main(void)
LTP1245_FeedPaper(100); LTP1245_FeedPaper(100);
LTP1245_FeedPaper(10); LTP1245_FeedPaper(10);
// LTP1245_Cut();
while(!Camera_Captured); while(!Camera_Captured);

View file

@ -23,7 +23,6 @@
#define PIN_CAMERA_PCLK 4 // PB4 - Camera pixel clock (TIM3_CH1) #define PIN_CAMERA_PCLK 4 // PB4 - Camera pixel clock (TIM3_CH1)
#define PIN_CAMERA_HSYNC 5 // PB5 - Camera VSYNC (TIM3_CH2) #define PIN_CAMERA_HSYNC 5 // PB5 - Camera VSYNC (TIM3_CH2)
#define PIN_HEAD 6 // PB6 - Head up sensor #define PIN_HEAD 6 // PB6 - Head up sensor
#define PIN_PAPER_CUT 7 // PB7 - Paper cutter servo (TIM4_CH2)
#define PIN_CAMERA_SCL 8 // PB8 - Camera control I2C (I2C1_SCL) #define PIN_CAMERA_SCL 8 // PB8 - Camera control I2C (I2C1_SCL)
#define PIN_CAMERA_SDA 9 // PB9 - Camera control I2C (I2C1_SDA) #define PIN_CAMERA_SDA 9 // PB9 - Camera control I2C (I2C1_SDA)
#define PIN_DST1 10 // PB10 - Head drive signal 1 (TIM2_CH3) #define PIN_DST1 10 // PB10 - Head drive signal 1 (TIM2_CH3)