Projectthermalprinter
Projectthermalprinter
#include "stdint.h"
#include <stdio.h>
#include "string.h"
/*********************************************************************/
//command structure
typedef struct command
{
char *name;
void (*function)(void);
}cmd_lst;
/**********************************************************************/
//command List,here we have only 1 command but we can add more commands here
directly.
const cmd_lst list[]={
{"print",print}
};
/* print("data u want to print",mode)
this is the command format and mode selection u can see from thermal printer.h*/
/**********************************************************************/
unsigned long int adr,d;
char p_cmd[20];
char temp1[50]={'\0'};
char temp2[50]={'\0'};
/**********************************************************************/
int main(void)
{
bool StanbyWakeUp ;
float Current_STBY;
char ch[50]={'\0'};
uint8_t ind=0,done = 0;
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32l1xx_md.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32l1xx.c file
*/
/* Initializes ADC */
ADC_Icc_Init();
if(!done)
{
if(ch[ind]==8)
{ if(ind!=0)
ind--; // for backspace
}
else ind++;
}
done = 0;
}
break;
/
********************************************************************************
******************************/
// Command parsing
void parse(char *ch)
{
int i=0,j=0;
/*************************************************************************
****/
//Command parsing checks for '('.
while((ch[i]!=40) && (ch[i]!='\0'))
{
p_cmd[i]=ch[i];i++;
}
p_cmd[i]='\0';i++;
/*************************************************************************
****/
//1st data argument parsing.
j=0;i++;
while((ch[i]!=34) && (ch[i]!='\0'))
{
temp1[j]=ch[i];j++;i++;
}
temp1[j]='\0';i++;
/*************************************************************************
****/
//2nd data argument parsing
j=0;i++;
while((ch[i]!=41) && (ch[i]!='\0'))
{
temp2[j]=ch[i];j++;i++;
}
temp2[j]='\0';
}
/
********************************************************************************
*************/
/************************************************************/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
USART_StructInit(&USART1_InitStructure);
USART_Init(USART1, &USART1_InitStructure);
USART_Cmd(USART1, ENABLE);
}
/
********************************************************************************
**********************/
x=temp2[0]-48;
tprint(temp1,x);
void RCC_Configuration(void)
{
/* Enable HSI Clock */
RCC_HSICmd(ENABLE);
/* LSE Enable */
RCC_LSEConfig(RCC_LSE_ON);
/*Disable HSE*/
RCC_HSEConfig(RCC_HSE_OFF);
if(RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET )
{
/* Stay in infinite loop if HSE is not disabled*/
while(1);
}
}
/**
* @brief To initialize the I/O ports
* @caller main
* @param None
* @retval None
*/
void Init_GPIOs (void)
{
/* GPIO, EXTI and NVIC Init structure declaration */
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure the LED_pin as output push-pull for LD3 & LD4 usage*/
GPIO_InitStructure.GPIO_Pin = LD_GREEN_GPIO_PIN | LD_BLUE_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(LD_GPIO_PORT, &GPIO_InitStructure);
/**
* @brief Inserts a delay time.
* @param nTime: specifies the delay time length, in 10 ms.
* @retval None
*/
void Delay(uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
/**
* @brief Decrements the TimingDelay variable.
* @caller SysTick interrupt Handler
* @param None
* @retval None
*/
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
TimingDelay--;
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line
number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
(void)file;
(void)line;
while (1);
}
#endif