zoukankan      html  css  js  c++  java
  • 嵌入式软件设计第09实验报告

    嵌入式软件设计第09实验报告

    学号:140201101                  姓名:刘子聪

     组别:第7组           实验地点:D19

    一、实验目的:

    1.熟悉WWW技术中的SSI(Server Side Include)技术。

    2.学会使用SSI技术编写代码把当前开发板内RTC的时钟及日期数据送往PC机浏览器显示。

    3.学会使用SSI技术把当前开发板的按键(KEY2、KEY1)次数信息送往PC机浏览器显示。

    二、实验内容:

    1.编写代码完成Web服务器端发送RTC实时时 钟信息的任务。

    2.编写代码完成Web服务器端发送按键(KEY2、KEY1)按键次数的任务。

    三、实验过程描述及结果展示:

    SSI技术简介 服务器端嵌入SSI(Server Side Include)是一种基于服务器的网页制作技术。大多数的WEB服务器等均支持SSI命令。将内容发送到浏览器之前,可以使用“SSI”指令将文本、图形或应用程序信息包含到网页中。因为包含SSI指令的文件要求特殊处理,所以必须为所有SSI文件赋予SSI文件扩展名。默认的扩展名是.stm、.shtm、.shtml。

    SSI是为WEB服务器提供的一套命令,这些命令只要直接嵌入到HTML文档的注释内容之中即可。如:<!=--#include file = “info.htm”-->就是一条SSI指令,其作用是将“info.htm”的内容拷贝到当前页面中。 <!=-- -->是HTML语法中的注释,当WEB服务器不支持SSI时,会忽略这些信息。

    按键与STM32的硬件连接图

    STM32F407芯片与键盘的连接电路图如下所示

    从图中可以看出,4个实体按键未按下去时,PE2,PE3,PE4会读入高电平。反之,为低电平。

    s#include "sys.h"

    #include <string.h>

    #include "delay.h"

    #include "httpd.h"

    #include "lwip/tcp.h"

    #include "fs.h"

    #include "lwip_comm.h"

    void system_init(void);

     void RTCTime_Handler(char *pcInsert);

     void RTCDate_Handler(char *pcInsert);

     void RTCKey1_Handler(char *pcInsert);

     void RTCKey2_Handler(char *pcInsert);

    const char *ppcTAGs[]=

    {

      "time",

    "date",

    "key2",

    "key1"

    };

    u8 key1=0,key2=0;

    void EXTI2_IRQHandler(void){

    delay_ms(10);

    key1++;

    printf("%d ",key1);

    EXTI_ClearITPendingBit(EXTI_Line2);

    }

    void EXTI3_IRQHandler(void){

    delay_ms(10);

    key2++;

    printf("%d ",key2);

    EXTI_ClearITPendingBit(EXTI_Line3);

    }

    void EXTIX_Init(void)

    {

    NVIC_InitTypeDef   NVIC_InitStructure;

    EXTI_InitTypeDef   EXTI_InitStructure;

    KEY_Init(); //按键对应的I/O初始化 

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//使能SYSCFG时钟

    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource2);//PE2 连接到中断线2

    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource3);//PE3 连接到中断线3

    /*配置EXTI_Line2,3,4 */

    EXTI_InitStructure.EXTI_Line = EXTI_Line2 | EXTI_Line3 /*| EXTI_Line4*/;

      EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//中断事件

      EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //下降沿触发

      EXTI_InitStructure.EXTI_LineCmd = ENABLE;//中断线使能

      EXTI_Init(&EXTI_InitStructure);//配置

    NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;//外部中断2

      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x03;//抢占优先级3

      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//子优先级2

      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//使能外部中断通道

      NVIC_Init(&NVIC_InitStructure);//配置

    NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;//外部中断3

      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02;//抢占优先级2

      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//子优先级 2

      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能外部中断通道

      NVIC_Init(&NVIC_InitStructure);//配置

       

    }

    int main(void)

    {

       system_init();//系统化初始化

    //以下代码对RTC进行初始化

    {

    RTC_InitTypeDef RTC_InitStructure;

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);//使能电源接口时钟

    PWR_BackupAccessCmd(ENABLE);//使能RTC+SRAM区域

    RCC_LSEConfig(RCC_LSE_ON);//开启LSE时钟

    RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); //选择LSE时钟作为RTC时钟

    while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET); //等待LSE准备好

    RCC_RTCCLKCmd(ENABLE);//使能RTC时钟

    while(RTC_Wait_Synchro());//等待RTC和APB同步

    RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;//24小时格式

    RTC_InitStructure.RTC_SynchPrediv = 0xFF;//同步预分频器

    RTC_InitStructure.RTC_AsynchPrediv = 0x7F;//异步预分频器

    RTC_Set_Time(10,0,0,0);//设置时间

    RTC_Set_Date(17,3,20,1);//设置日期

    }

        EXTIX_Init();

    //uart_init(115200); //串口初始化

    while(1)

    {

        

         lwip_periodic_handle();//LWIP轮询任务

    }

    }

    //SSI的Handler

    u16_t SSIHandler(int iIndex,char *pcInsert,int iInsertLen)

    {

    switch(iIndex)//iIndex索引号

    {

    case 0:

            RTCTime_Handler(pcInsert);

              break;

    case 1:

          RTCDate_Handler(pcInsert);

              break;

    case 2:

          RTCKey2_Handler(pcInsert);

              break;

    case 3:

          RTCKey1_Handler(pcInsert);

              break;

    }

    return strlen(pcInsert);

    }

    //SSIHandler中需要用到的处理RTC时间的函数

    void RTCTime_Handler(char *pcInsert)

    {

      u8 hour,min,sec,ampm;

    RTC_Get_Time(&hour,&min,&sec,&m);

    *(pcInsert+0) = (char)((hour/10)+0x30);

    *(pcInsert+1) = (char)((hour%10)+0x30);

    *(pcInsert+2) = ':';

      *(pcInsert+3) = (char)((min/10)+0x30);

    *(pcInsert+4) = (char)((min%10)+0x30);

    *(pcInsert+5) = ':';

    *(pcInsert+6) = (char)((sec/10)+0x30);

    *(pcInsert+7) = (char)((sec%10)+0x30);

    }

    void RTCDate_Handler(char *pcInsert)

    {

    u8 year,month,day,week;

    RTC_Get_Date(&year,&month,&day,&week);

    *(pcInsert+0) = '2';

    *(pcInsert+1) = '0';

    *(pcInsert+2) = (char)((year/10)+0x30);

    *(pcInsert+3) = (char)((year%10)+0x30);

    *(pcInsert+4) = '-';

    *(pcInsert+5) = (char)((month/10)+0x30);

    *(pcInsert+6) = (char)((month%10)+0x30);

    *(pcInsert+7) = '-';

    *(pcInsert+8) = (char)((day/10)+0x30);

    *(pcInsert+9) = (char)((day%10)+0x30);

    *(pcInsert+10) = ' ';

    *(pcInsert+11) = 'w';

    *(pcInsert+12) = 'e';

    *(pcInsert+13) = 'e';

    *(pcInsert+14) = 'k';

    *(pcInsert+15) = ':';;

    *(pcInsert+16) = (char)(week+0x30);

    }

    void RTCKey1_Handler(char *pcInsert)

    {

    if (key1<10)

    {

    *(pcInsert+0) = (char)(key1+0x30);

    *(pcInsert+1) = '';

    }

    else

    {

    *(pcInsert+0) = (char)((key1/10)+0x30);

    *(pcInsert+1) = (char)((key1%10)+0x30);

    *(pcInsert+2) = '';

    }

    }

    void RTCKey2_Handler(char *pcInsert)

    {

    if (key2<10)

    {

    *(pcInsert+0) = (char)(key2+0x30);

    *(pcInsert+1) = '';

    }

    else

    {

    *(pcInsert+0) = (char)((key2/10)+0x30);

    *(pcInsert+1) = (char)((key2%10)+0x30);

    *(pcInsert+2) = '';

    }

    }

    四、总结及实验心得:

    熟悉了WWW技术中的SSI(Server Side Include)技术,学会了使用SSI技术编写代码把当前开发板内RTC的时钟及日期数据送往PC机浏览器显示,学会了使用SSI技术把当前开发板的按键(KEY2、KEY1)次数信息送往PC机浏览器显示。

  • 相关阅读:
    openSUSE字体美化
    [转摘]关于创建oracle dblink 过程的几点心得
    IList及泛型集合类转换DataTable
    C# 编码规范和编程好习惯
    随机数和随机字符串
    ThrowActivity 光阴的故事
    数据库的数据 转化为XML 在页面上浏览 光阴的故事
    EventHandlingScopeActivity 光阴的故事
    workflow 角色的使用关键 光阴的故事
    ConditionedActivityGroup 光阴的故事
  • 原文地址:https://www.cnblogs.com/liuzicong12345/p/6623672.html
Copyright © 2011-2022 走看看