• 机器人制作开源方案 | 智能家庭防护机器人


    作者:李尚堰 陈庆达 王立宽 尹婕 张永俊
    单位:哈尔滨剑桥学院
    指导老师:马文龙 韩轶男

    一、设计背景

    随着计算机技术、信息通讯、大数据、智能传感等科学技术的不断发展、融合以及在机器人领域的不断应用,服务机器人产业将呈现出快速发展趋势。为推进我国服务机器人产业快速发展,政府及有关部门相继发布一系列政策,开展下一代机器人技术、智能机器人学习与认知、智能家庭服务机器人、智能公共服务机器人实现批量生产及应用,在很大程度上促进了服务机器人产业的发展。
           智能家居机器人是通过计算机、通信、控制,也就是4C技术建立家庭综合服务于管理集成系统,机器人是IT技术、网络技术与控制技术向居家生活渗透发展的必然结果。

    二、市场调研

      随着人们收入水平的提高以及消费偏好的转变,家庭服务机器人慢慢演变成大众需求,以扫地机器人为代表的家庭服务机器人驶入了发展的快车道。2017年中国家庭服务机器人销售额55.7亿元,2021年增至142.9亿元,复合增长率26.6%。预计2023年家庭服务机器人零售额将达187亿元。

    三、主要技术

    3.1 方案设计

           针对现有技术中存在的问题,本作品的目的在于提供一种家庭守护机器人,它可以通过四足-履带的切换结构,配合超声波传感器对障碍物进行避障,搭配温湿度、气体传感器、火焰传感器,对家庭火源,以及可燃气体的泄露进行实时检测,同时配备树莓派3B进行人机语音交互,对家庭智能化进行一系列的智能化操作以及方便性,为守护家庭保驾护航。
           具体功能:采用四足-履带的驱动结构对障碍物进行避障,采用温湿度传感器将室内温度以及湿度实时显示在led屏幕中,采用火焰传感器、气体传感器对室内火源以及可燃气体进行实时检测,并配合树莓派3B进行语音播报提醒。利用树莓派接入AI百度云人工智能,以及科大讯飞进行人机语言交互,方便获取想要得到的信息,以及智能家居的控制更加的快捷方便。

    3.2 控制系统

           采用arduino控制器控制全车的运动系统以及实现各种功能的传感器,并且通过串口连接的方式接入人机交互模块对家庭守护更加快捷、方便。

    3.3 主体结构

    作品整体结构图

    小车主要由驱动机构、传感器模块以及人机交互模块构成。
    ① 驱动机构

    驱动结构图

           全自动家庭守护机器人采用四足-履带的行进机构,配合超声波完成自主避障,对于较高的障碍物切换为履带模式进行避障,对于较低的障碍物切换为四足进行跨越障。
    ② 传感器模块

    火焰传感器图片

           通过火焰传感器对室内火源进行检测,确定火焰的方位,同时进行语音提示,从而为灭火机构提供灭火方位,实现在发生火灾时能够及时自动灭火,从根源避免火灾的蔓延,减少火灾造成的生命财产损失。

    气体传感器图片

           气体传感器,可以对室内可燃气体进行检测,并及时进行语音播报提醒,并可以通过树莓派进行人机交互,及其打开窗户进行通风换气, 实时保护了家庭人员的安全。

    温湿度传感器图片

           温湿度传感器,可将室内温度以及湿度进行检测,并将温度以及湿度显示在屏幕中,以方便提醒室内人员对室内舒适环境的温度以及湿度做出相应的操作。

    led显示屏图片

    可通过led屏显示当前小车状态和传感器相关数据。
    ③ 人机交互模块

    树莓派3B图片

           人机交互模块,是通过树莓派3B、麦克风以及扩音器构成。可通过人工智能语音进行人机语言交互,可以在室内出现事故时,通过唤醒机器人做出相应的动作,极大的为家庭守护提供了便捷性,同时也为室内活动增加了一份色彩。

    四、创新亮点

    本设计全自动家庭守护机器人,充分考虑到在家庭守护的稳定性,采用多种解决办法,能在较为复杂的地形中可靠的工作,具有良好的适应性。综合分析本次设计具有以下亮点:
    ① 四足-履带行进机构
           机器人通过四足-履带的行进机构,为适应不同场地进行避障以及跨越障碍,让小车在复杂的环境中能更加稳定的工作。履带车形态在平坦或稍崎岖的地貌上能够保持较高的行进速度,降低了四足爬行的功率消耗;四足形态用于跨越障碍,灵活应对各类复杂地形环境,解决了履带结构应对高度落差较大地形难以翻越的痛点,即实现了仿生四足与履带式结构双优势结合的腿履协同。
    ② 传感器模块
           通过不同的传感器模块对室内环境进行检测,为室内守护进行实时的数据传达以及提醒。
    ③ 人机交互模块
           机器人搭配人工交互模块,可方便迅速的对室内守护进行语音提示,并方便的做出应对措施

    五、应用前景

    随着时代的发展,我国消费者的消费观念对包括服务机器人在内的智能化产品需求也逐步增强。由于城市化带来的快节奏生活导致消费者家务时间明显减少,导致消费者对家务机器人购买需求呈现刚性化特征。
           随着工业4.0和物联网技术的发展,技术进步带动力服务机器人智能化程度的迅速提升,同时国内智能手机渗透率较高,消费者使用智能手机作为移动终端远程遥控家庭服务机器人,提升了消费者的用户体验。综上,居民可支配收入、消费观念、城市化进程、技术等多方面因素使得我国家庭服务机器人市场需求呈现迅猛增长的态势。

    更多详细资料请参考 【S023】智能家庭防护机器人

    附录:示例程序

    1. #define t_bit unsigned char
    2. #define t_bool unsigned char
    3. #define t_uint8 unsigned char
    4. #define t_int8 signed char
    5. #define t_uint16 unsigned short
    6. #define t_int16 signed short
    7. #define t_uint32 unsigned int
    8. #define t_int32 signed int
    9. #define t_fix signed int
    10. void cx_NULL_E(void);
    11. void cx_SYS_NullFunc(void);
    12. t_uint8 cx___sysbox__0_sys_iointerface_get_uint8( t_uint32 tmp_addr );
    13. void cx___sysbox__0_sys_iointerface_set_uint8( t_uint32 tmp_addr, t_uint8 tmp_d );
    14. t_uint16 cx___sysbox__0_sys_iointerface_get_uint16( t_uint32 tmp_addr );
    15. void cx___sysbox__0_sys_iointerface_set_uint16( t_uint32 tmp_addr, t_uint16 tmp_d );
    16. t_uint32 cx___sysbox__0_sys_iointerface_get_uint32( t_uint32 tmp_addr );
    17. void cx___sysbox__0_sys_iointerface_set_uint32( t_uint32 tmp_addr, t_uint32 tmp_d );
    18. void cx_youqian_driver_OS_init(void);
    19. void cx_youqian_driver_OS_run(void);
    20. void cx_youqian_driver_SetSpeed( t_int32 tmp_t );
    21. void cx_youqian_driver_dev_init(void);
    22. void cx_youqian_driver_SetValue( t_int32 tmp_d );
    23. void cx_youqian_driver_sim_SetSpeed( t_int32 tmp_t );
    24. void cx_kongzhiqi1_driver_OS_init(void);
    25. void cx_kongzhiqi1_driver_OS_thread(void);
    26. void cx_kongzhiqi1_driver_OS_run(void);
    27. void cx_kongzhiqi1_driver_LightOpen(void);
    28. void cx_kongzhiqi1_driver_LightClose(void);
    29. void cx_kongzhiqi1_driver_LightSwap(void);
    30. void cx_kongzhiqi1_driver_LightFlashTimes( t_int32 tmp_n );
    31. void cx_kongzhiqi1_driver_LightFlash(void);
    32. void cx_kongzhiqi1_driver_delay(void);
    33. void cx_kongzhiqi1_pinMode( t_int32 tmp_p, t_int32 tmp_m );
    34. void cx_kongzhiqi1_digitalWrite( t_int32 tmp_p, t_int32 tmp_d );
    35. t_int32 cx_kongzhiqi1_digitalRead( t_int32 tmp_p );
    36. void cx_youhou_driver_OS_init(void);
    37. void cx_youhou_driver_OS_run(void);
    38. void cx_youhou_driver_SetSpeed( t_int32 tmp_t );
    39. void cx_youhou_driver_dev_init(void);
    40. void cx_youhou_driver_SetValue( t_int32 tmp_d );
    41. void cx_youhou_driver_sim_SetSpeed( t_int32 tmp_t );
    42. void cx_zuohou_driver_OS_init(void);
    43. void cx_zuohou_driver_OS_run(void);
    44. void cx_zuohou_driver_SetSpeed( t_int32 tmp_t );
    45. void cx_zuohou_driver_dev_init(void);
    46. void cx_zuohou_driver_SetValue( t_int32 tmp_d );
    47. void cx_zuohou_driver_sim_SetSpeed( t_int32 tmp_t );
    48. void cx_zuoqian_driver_OS_init(void);
    49. void cx_zuoqian_driver_OS_run(void);
    50. void cx_zuoqian_driver_SetSpeed( t_int32 tmp_t );
    51. void cx_zuoqian_driver_dev_init(void);
    52. void cx_zuoqian_driver_SetValue( t_int32 tmp_d );
    53. void cx_zuoqian_driver_sim_SetSpeed( t_int32 tmp_t );
    54. void cx_madaqudongqi_driver_OS_init(void);
    55. void cx_madaqudongqi_driver_set_t( t_int32 tmp_t );
    56. void cx_madaqudongqi_driver_vex_init(void);
    57. void cx_madaqudongqi_driver_OS_run100us(void);
    58. void cx_youludai_driver_init(void);
    59. void cx_youludai_driver_set_power( t_int32 tmp_p );
    60. void cx_youludai_driver_run_right(void);
    61. void cx_youludai_driver_run_left(void);
    62. void cx_youludai_driver_stop(void);
    63. void cx_youludai_driver_short_stop(void);
    64. void cx_youludai_driver_OS_init(void);
    65. void cx_zuoludai_driver_init(void);
    66. void cx_zuoludai_driver_set_power( t_int32 tmp_p );
    67. void cx_zuoludai_driver_run_right(void);
    68. void cx_zuoludai_driver_run_left(void);
    69. void cx_zuoludai_driver_stop(void);
    70. void cx_zuoludai_driver_short_stop(void);
    71. void cx_zuoludai_driver_OS_init(void);
    72. t_int32 cx_chaoshengbocejuqi_driver_get_value(void);
    73. t_int32 cx_chaoshengbocejuqi_driver_get_good_value(void);
    74. void cx_chaoshengbocejuqi_driver_OS_init(void);
    75. void cx_huoyanchuanganqi_driver_OS_init(void);
    76. void cx_huoyanchuanganqi_driver_OS_run(void);
    77. void cx_wenshiduchuanganqi_driver_OS_init(void);
    78. void cx_wenshiduchuanganqi_driver_OS_run(void);
    79. t_int32 cx_wenshiduchuanganqi_driver_wendu(void);
    80. t_int32 cx_wenshiduchuanganqi_driver_shidu(void);
    81. t_uint32 cx_wenshiduchuanganqi_driver_read(void);
    82. t_uint8 cx_wenshiduchuanganqi_driver_get_byte(void);
    83. void cx_yanshiqi_driver_OS_init(void);
    84. void cx_yanshiqi_driver_OS_thread(void);
    85. void cx_yanshiqi_driver_DelayMillisecond( t_int32 tmp_t );
    86. void cx_yanshiqi_driver_DelaySecond( t_fix tmp_t );
    87. void cx_yanshiqi_driver_DelayMinute( t_int32 tmp_t );
    88. void cx_yanshiqi_driver_DelayHour( t_int32 tmp_t );
    89. void cx_yanshiqi_driver_DelayDay( t_int32 tmp_t );
    90. void cx_yanshiqi_driver_Stop(void);
    91. void cx_yanshiqi_driver_StopCurrent(void);
    92. void cx_yanshiqi_driver_StopAll(void);
    93. void cx_yanwuchuanganqi_driver_OS_init(void);
    94. t_int32 cx_yanwuchuanganqi_driver_get_data(void);
    95. void cx_pingmu1_driver_Refresh(void);
    96. void cx_pingmu1_driver_command_I2C_Init(void);
    97. void cx_pingmu1_driver_command_I2C_A2_set_uint8( t_uint8 tmp_DeviceAddr, t_uint16 tmp_addr, t_uint8 tmp_data );
    98. t_uint8 cx_pingmu1_driver_command_I2C_A2_get_uint8( t_uint8 tmp_DeviceAddr, t_uint16 tmp_addr );
    99. void cx_pingmu1_driver_command_I2C_A1_set_uint8( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr, t_uint8 tmp_data );
    100. t_uint8 cx_pingmu1_driver_command_I2C_A1_get_uint8( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr );
    101. void cx_pingmu1_driver_command_I2C_A1_get_byte2( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr );
    102. void cx_pingmu1_driver_command_I2C_A1_get_byte4( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr );
    103. void cx_pingmu1_driver_command_I2C_A1_get_byte6( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr );
    104. void cx_pingmu1_driver_command_I2C_start_iic(void);
    105. void cx_pingmu1_driver_command_I2C_end_iic(void);
    106. void cx_pingmu1_driver_command_I2C_wait(void);
    107. void cx_pingmu1_driver_command_I2C_write_byte( t_uint8 tmp_data );
    108. t_uint8 cx_pingmu1_driver_command_I2C_read_byte(void);
    109. void cx_pingmu1_driver_command_I2C_Ack(void);
    110. void cx_pingmu1_driver_command_I2C_NoAck(void);
    111. void cx_pingmu1_driver_command_I2C_delay_1us(void);
    112. void cx_pingmu1_driver_command_OS_init(void);
    113. void cx_pingmu1_driver_command_write_command( t_uint8 tmp_C );
    114. void cx_pingmu1_driver_command_write_data( t_uint8 tmp_D );
    115. void cx_pingmu1_driver_OS_thread(void);
    116. void cx_pingmu1_driver_Init(void);
    117. void cx_pingmu1_driver_Clear(void);
    118. void cx_pingmu1_driver_set_refresh(void);
    119. void cx_pingmu1_driver_pixel( t_int32 tmp_x, t_int32 tmp_y );
    120. void cx_pingmu1_driver_clear_pixel( t_int32 tmp_x, t_int32 tmp_y );
    121. void cx_pingmu1_driver_pixel1( t_int32 tmp_x, t_int32 tmp_y );
    122. void cx_pingmu1_driver_pixel0( t_int32 tmp_x, t_int32 tmp_y );
    123. t_int32 cx_pingmu1_driver_get_pixel( t_int32 tmp_x, t_int32 tmp_y );
    124. void cx_pingmu1_driver_Move( t_int32 tmp_v, t_int32 tmp_vy );
    125. void cx_pingmu1_driver_OS_init(void);
    126. void cx_chaoshengduoji_driver_OS_init(void);
    127. void cx_chaoshengduoji_driver_OS_run(void);
    128. void cx_chaoshengduoji_driver_SetSpeed( t_int32 tmp_t );
    129. void cx_chaoshengduoji_driver_dev_init(void);
    130. void cx_chaoshengduoji_driver_SetValue( t_int32 tmp_d );
    131. void cx_chaoshengduoji_driver_sim_SetSpeed( t_int32 tmp_t );
    132. void cx_xinxixianshiqi_driver_OS_init(void);
    133. void cx_xinxixianshiqi_driver_clear(void);
    134. void cx_xinxixianshiqi_driver_clear_line( t_int32 tmp_line );
    135. void cx_xinxixianshiqi_driver_show_text( t_int32 tmp_line, t_int32 tmp_column, t_int8 tmp_string[] );
    136. void cx_xinxixianshiqi_driver_show_text_f( t_int32 tmp_line, t_int32 tmp_column, t_int8 tmp_string[] );
    137. void cx_xinxixianshiqi_driver_show_number_f( t_int32 tmp_line, t_int32 tmp_column, t_int32 tmp_data0 );
    138. void cx_xinxixianshiqi_driver_show_number_ff( t_int32 tmp_line, t_int32 tmp_column, t_int32 tmp_data0 );
    139. void cx_xinxixianshiqi_driver_show_number( t_int32 tmp_line, t_int32 tmp_column, t_int32 tmp_data0 );
    140. void cx_xinxixianshiqi_driver_set_format( t_int32 tmp_c, t_int32 tmp_n );
    141. void cx_xinxixianshiqi_driver_clear_format(void);
    142. void cx_dianzhenzifuxianshiqi_driver_OS_init(void);
    143. void cx_dianzhenzifuxianshiqi_driver_clear(void);
    144. void cx_dianzhenzifuxianshiqi_driver_clear_line( t_int32 tmp_line );
    145. void cx_dianzhenzifuxianshiqi_driver_print_line1( t_int32 tmp_x, t_int32 tmp_y, t_int32 tmp_c );
    146. void cx_dianzhenzifuxianshiqi_driver_print_line( t_int32 tmp_YY, t_int32 tmp_XX, t_int32 tmp_c );
    147. void cx_dianzhenzifuxianshiqi_driver_DrawChar( t_int8 tmp_PerWidth, t_#.点阵字符显示器.driver.icon *tmp_tfont, t_uint16 tmp_BufferIndex, t_int16 tmp_X, t_int16 tmp_Y );
    148. void cx_dianzhenzifuxianshiqi_driver_SetEnglishFont( t_#.点阵字符显示器.driver.icon *tmp_icon );
    149. void cx_dianzhenzifuxianshiqi_driver_SetChinesFont( t_#.点阵字符显示器.driver.icon *tmp_icon );
    150. void cx_dianzhenzifuxianshiqi_driver_SetEnglishFontDefault(void);
    151. void cx_yuyinlangduqi_driver_OS_init(void);
    152. void cx_yuyinlangduqi_driver_set_baud( t_int32 tmp_b );
    153. void cx_yuyinlangduqi_driver_print_string( t_int8 tmp_s[] );
    154. void cx_yuyinlangduqi_driver_print_number( t_int32 tmp_data0 );
    155. void cx_yuyinlangduqi_driver_print_char( t_int32 tmp_d );
    156. t_int32 cx_yuyinlangduqi_driver_get_byte(void);
    157. void cx_SYS_Servo_OS_init(void);
    158. void cx_SYS_Servo_SetValue( t_int32 tmp_d );
    159. void cx_SYS_Servo_timer2_compA(void);
    160. void cx_SYS_Servo_Clear(void);
    161. void cx_SYS_Servo_SetPin(void);
    162. void cx_OS0_REMO_ModuleWrite( t_int32 tmp_d, t_int32 tmp_d1 );
    163. t_int32 cx_OS0_REMO_ModuleRead( t_int32 tmp_d );
    164. void cx_OS0_Delayer_Init(void);
    165. void cx_OS0_Delayer_Run(void);
    166. t_bool cx_OS0_Delayer_Running(void);
    167. void cx_OS0_Delayer_Stop( t_uint16 tmp_cid );
    168. void cx_OS0_Delayer_StopAll(void);
    169. void cx_OS0_Delayer_Wait( t_int32 tmp_t );
    170. t_int32 cx_OS0_GetSysTick(void);
    171. t_uint32 cx_OS0_GetSysTickU(void);
    172. void cx_OS0_OS_init(void);
    173. void cx_OS0_CloseWatchdog(void);
    174. void cx_OS0_MACRO_TIMER_ON(void);
    175. void cx_OS0_MACRO_TIMER_OFF(void);
    176. void cx_OS0_TimerInit(void);
    177. void cx_OS0_OS_run(void);
    178. void cx_OS0_DriverInit(void);
    179. void cx_OS0_CreateDriver( void (*tmp_Handle)(void), t_uint8 tmp_MaxTick );
    180. void cx_OS0_CreateDriver100us( void (*tmp_Handle)(void) );
    181. void cx_OS0_RunDriverList(void);
    182. void cx_OS0_RunDriver100usList(void);
    183. void cx_OS0_D_CALL( void (*tmp_Handle)(void) );
    184. void cx_OS0_Start(void);
    185. void cx_sys_delayer_delay_n_10us( t_uint8 tmp_t );
    186. void cx_sys_delayer_delay_n_1us( t_uint8 tmp_t );
    187. void cx_sys_delayer_delay_ms( t_int32 tmp_t );
    188. void cx_Sim_onInitDefault(void);
    189. void cx_Sim_onDrawDefault(void);
    190. void cx_Sim_onKeyEventDefault( t_bool tmp_down, t_int32 tmp_key );
    191. t_int32 cx_Sim_crux_AddVar( t_int32 tmp_v );
    192. t_int32 cx_Sim_crux_Run( t_int32 tmp_v );
    193. void cx_Sim_OS_init(void);
    194. void cx_Sim_OS_thread(void);
    195. void cx_Sim_Clear(void);
    196. void cx_Sim_DrawCircle( t_int32 tmp_x, t_int32 tmp_y, t_int32 tmp_r );
    197. void cx_Sim_FillCircle( t_int32 tmp_x, t_int32 tmp_y, t_int32 tmp_r );
    198. void cx_main0(void);
    199. void cx_Setup(void);
    200. void cx_Loop(void);
    201. void cx_xiaocheqianjin(void);
    202. void cx_xiaochetingzhi(void);
    203. void cx_xiaochezuozhuan(void);
    204. void cx_xiaocheyouzhuan(void);
    205. void cx_xiaochedaoche(void);
    206. void cx_xiaochexingtai(void);
    207. void cx_kongzhiqi1_fanfuzhixing(void);
    208. void cx_sizuxingtai(void);
    209. void cx_xingzou(void);
    210. void cx_huoyanchuanganqi_tancedaohuoyanshi(void);
    211. void cx_kongzhiqi1_chushihua(void);
    212. void cx_pingmu(void);
    213. void cx_OS_VarInit(void);
    214. t_int32 cx_SYS_Tick;
    215. t_uint8 cx_SYS_Loop;
    216. t_int32 cx_CInsIndex;
    217. t_uint8 cx_youqian_driver_OS_time;
    218. t_int32 cx_youqian_driver_tick;
    219. t_int32 cx_youqian_driver_ti;
    220. t_int32 cx_youqian_driver_Angle;
    221. t_int32 cx_youqian_driver_C_Angle;
    222. #define cx_kongzhiqi1_driver_RES_SP_LOW SP_LOW
    223. #define cx_kongzhiqi1_driver_RES_SP_HIGH SP_HIGH
    224. #define cx_kongzhiqi1_driver_RES_SP SP
    225. #define cx_kongzhiqi1_driver_RES_SREG SREG
    226. #define cx_kongzhiqi1_driver_RES_PINB PINB
    227. #define cx_kongzhiqi1_driver_RES_DDRB DDRB
    228. #define cx_kongzhiqi1_driver_RES_PORTB PORTB
    229. #define cx_kongzhiqi1_driver_RES_PINC PINC
    230. #define cx_kongzhiqi1_driver_RES_DDRC DDRC
    231. #define cx_kongzhiqi1_driver_RES_PORTC PORTC
    232. #define cx_kongzhiqi1_driver_RES_PIND PIND
    233. #define cx_kongzhiqi1_driver_RES_DDRD DDRD
    234. #define cx_kongzhiqi1_driver_RES_PORTD PORTD
    235. #define cx_kongzhiqi1_driver_RES_WDTCSR WDTCSR
    236. #define cx_kongzhiqi1_driver_RES_MCUSR MCUSR
    237. #define cx_kongzhiqi1_driver_RES_TCCR0A TCCR0A
    238. #define cx_kongzhiqi1_driver_RES_TCCR0B TCCR0B
    239. #define cx_kongzhiqi1_driver_RES_TCNT0 TCNT0
    240. #define cx_kongzhiqi1_driver_RES_OCR0A OCR0A
    241. #define cx_kongzhiqi1_driver_RES_OCR0B OCR0B
    242. #define cx_kongzhiqi1_driver_RES_TIMSK0 TIMSK0
    243. #define cx_kongzhiqi1_driver_RES_TIFR0 TIFR0
    244. #define cx_kongzhiqi1_driver_RES_ADCL ADCL
    245. #define cx_kongzhiqi1_driver_RES_ADCH ADCH
    246. #define cx_kongzhiqi1_driver_RES_ADCSRA ADCSRA
    247. #define cx_kongzhiqi1_driver_RES_ADCSRB ADCSRB
    248. #define cx_kongzhiqi1_driver_RES_ADMUX ADMUX
    249. #define cx_kongzhiqi1_driver_RES_DIDR0 DIDR0
    250. #define cx_kongzhiqi1_driver_RES_EICRA EICRA
    251. #define cx_kongzhiqi1_driver_RES_EIMSK EIMSK
    252. #define cx_kongzhiqi1_driver_RES_EIFR EIFR
    253. #define cx_kongzhiqi1_driver_RES_OCR1BH OCR1BH
    254. #define cx_kongzhiqi1_driver_RES_OCR1BL OCR1BL
    255. #define cx_kongzhiqi1_driver_RES_OCR1AH OCR1AH
    256. #define cx_kongzhiqi1_driver_RES_OCR1AL OCR1AL
    257. #define cx_kongzhiqi1_driver_RES_TCNT1H TCNT1H
    258. #define cx_kongzhiqi1_driver_RES_TCNT1L TCNT1L
    259. #define cx_kongzhiqi1_driver_RES_TCCR1C TCCR1C
    260. #define cx_kongzhiqi1_driver_RES_TCCR1B TCCR1B
    261. #define cx_kongzhiqi1_driver_RES_TCCR1A TCCR1A
    262. #define cx_kongzhiqi1_driver_RES_TIMSK1 TIMSK1
    263. #define cx_kongzhiqi1_driver_RES_TIFR1 TIFR1
    264. #define cx_kongzhiqi1_driver_RES_OCR2B OCR2B
    265. #define cx_kongzhiqi1_driver_RES_OCR2A OCR2A
    266. #define cx_kongzhiqi1_driver_RES_TCNT2 TCNT2
    267. #define cx_kongzhiqi1_driver_RES_TCCR2B TCCR2B
    268. #define cx_kongzhiqi1_driver_RES_TCCR2A TCCR2A
    269. #define cx_kongzhiqi1_driver_RES_TIMSK2 TIMSK2
    270. #define cx_kongzhiqi1_driver_RES_TIFR2 TIFR2
    271. #define cx_kongzhiqi1_driver_RES_UCSR0A UCSR0A
    272. #define cx_kongzhiqi1_driver_RES_UCSR0B UCSR0B
    273. #define cx_kongzhiqi1_driver_RES_UCSR0C UCSR0C
    274. #define cx_kongzhiqi1_driver_RES_UBRR0L UBRR0L
    275. #define cx_kongzhiqi1_driver_RES_UBRR0H UBRR0H
    276. #define cx_kongzhiqi1_driver_RES_UDR0 UDR0
    277. #define cx_kongzhiqi1_driver_RES_EECR EECR
    278. #define cx_kongzhiqi1_driver_RES_EEDR EEDR
    279. #define cx_kongzhiqi1_driver_RES_EEARL EEARL
    280. #define cx_kongzhiqi1_driver_RES_EEARH EEARH
    281. #define cx_kongzhiqi1_driver_RES_SPCR SPCR
    282. #define cx_kongzhiqi1_driver_RES_SPSR SPSR
    283. #define cx_kongzhiqi1_driver_RES_SPDR SPDR
    284. #define cx_kongzhiqi1_driver_RES_SMCR SMCR
    285. #define cx_kongzhiqi1_driver_RES_MCUCSR MCUCSR
    286. #define cx_kongzhiqi1_driver_RES_MCUCR MCUCR
    287. t_uint8 cx_kongzhiqi1_driver_OS_time;
    288. t_uint8 cx_kongzhiqi1_driver_OS_EventFlag;
    289. t_uint8 cx_kongzhiqi1_driver_swap;
    290. t_int32 cx_kongzhiqi1_driver_FlashNumber;
    291. t_bool cx_kongzhiqi1_driver_FlashOpen;
    292. t_bool cx_kongzhiqi1_driver_FlashForever;
    293. t_bit cx_kongzhiqi1_GND_D0_DIR;
    294. t_bit cx_kongzhiqi1_GND_D0_IN;
    295. t_bit cx_kongzhiqi1_GND_D0_OUT;
    296. t_bit cx_kongzhiqi1_GND_D0_PUL;
    297. t_bit cx_kongzhiqi1_GND1_D0_DIR;
    298. t_bit cx_kongzhiqi1_GND1_D0_IN;
    299. t_bit cx_kongzhiqi1_GND1_D0_OUT;
    300. t_bit cx_kongzhiqi1_GND1_D0_PUL;
    301. t_bit cx_kongzhiqi1_GND2_D0_DIR;
    302. t_bit cx_kongzhiqi1_GND2_D0_IN;
    303. t_bit cx_kongzhiqi1_GND2_D0_OUT;
    304. t_bit cx_kongzhiqi1_GND2_D0_PUL;
    305. t_bit cx_kongzhiqi1_VCC1_D0_DIR;
    306. t_bit cx_kongzhiqi1_VCC1_D0_IN;
    307. t_bit cx_kongzhiqi1_VCC1_D0_OUT;
    308. t_bit cx_kongzhiqi1_VCC1_D0_PUL;
    309. t_bit cx_kongzhiqi1_VCC2_D0_DIR;
    310. t_bit cx_kongzhiqi1_VCC2_D0_IN;
    311. t_bit cx_kongzhiqi1_VCC2_D0_OUT;
    312. t_bit cx_kongzhiqi1_VCC2_D0_PUL;
    313. t_uint8 cx_youhou_driver_OS_time;
    314. t_int32 cx_youhou_driver_tick;
    315. t_int32 cx_youhou_driver_ti;
    316. t_int32 cx_youhou_driver_Angle;
    317. t_int32 cx_youhou_driver_C_Angle;
    318. t_uint8 cx_zuohou_driver_OS_time;
    319. t_int32 cx_zuohou_driver_tick;
    320. t_int32 cx_zuohou_driver_ti;
    321. t_int32 cx_zuohou_driver_Angle;
    322. t_int32 cx_zuohou_driver_C_Angle;
    323. t_uint8 cx_zuoqian_driver_OS_time;
    324. t_int32 cx_zuoqian_driver_tick;
    325. t_int32 cx_zuoqian_driver_ti;
    326. t_int32 cx_zuoqian_driver_Angle;
    327. t_int32 cx_zuoqian_driver_C_Angle;
    328. t_int8 cx_madaqudongqi_driver_valueA;
    329. t_int8 cx_madaqudongqi_driver_valueB;
    330. t_bit cx_madaqudongqi_driver_DTA1;
    331. t_bit cx_madaqudongqi_driver_DTA2;
    332. t_bit cx_madaqudongqi_driver_DTB1;
    333. t_bit cx_madaqudongqi_driver_DTB2;
    334. t_int8 cx_madaqudongqi_driver_tick;
    335. t_int8 cx_madaqudongqi_driver_T;
    336. t_int8 cx_madaqudongqi_driver_tt;
    337. t_uint8 cx_huoyanchuanganqi_driver_OS_EventFlag;
    338. t_bool cx_huoyanchuanganqi_driver_key0_press;
    339. t_uint8 cx_huoyanchuanganqi_driver_OS_time;
    340. t_bit cx_huoyanchuanganqi_driver_last_key0_press;
    341. t_uint8 cx_wenshiduchuanganqi_driver_OS_time;
    342. t_int32 cx_wenshiduchuanganqi_driver_v_wendu;
    343. t_int32 cx_wenshiduchuanganqi_driver_v_shidu;
    344. t_bool cx_wenshiduchuanganqi_driver_NeedRefresh;
    345. t_uint8 cx_wenshiduchuanganqi_driver_tick;
    346. t_uint16 cx_wenshiduchuanganqi_driver_tickout;
    347. t_uint8 cx_pingmu1_driver_command_I2C_byte0;
    348. t_uint8 cx_pingmu1_driver_command_I2C_byte1;
    349. t_uint8 cx_pingmu1_driver_command_I2C_byte2;
    350. t_uint8 cx_pingmu1_driver_command_I2C_byte3;
    351. t_uint8 cx_pingmu1_driver_command_I2C_byte4;
    352. t_uint8 cx_pingmu1_driver_command_I2C_byte5;
    353. t_int8 cx_pingmu1_driver_Offset;
    354. t_int32 cx_pingmu1_driver_PenWidth;
    355. t_int32 cx_pingmu1_driver_ForColor;
    356. t_int32 cx_pingmu1_driver_BackColor;
    357. t_int32 cx_pingmu1_driver_Width;
    358. t_int32 cx_pingmu1_driver_Height;
    359. t_bool cx_pingmu1_driver_NeedRefresh;
    360. t_uint8 cx_pingmu1_driver_buffer[1024];
    361. t_bool cx_pingmu1_driver_dot_set;
    362. t_uint8 cx_chaoshengduoji_driver_OS_time;
    363. t_int32 cx_chaoshengduoji_driver_tick;
    364. t_int32 cx_chaoshengduoji_driver_ti;
    365. t_int32 cx_chaoshengduoji_driver_Angle;
    366. t_int32 cx_chaoshengduoji_driver_C_Angle;
    367. t_int8 cx_xinxixianshiqi_driver_number_buffer[11];
    368. t_int8 cx_xinxixianshiqi_driver_bchar;
    369. t_int8 cx_xinxixianshiqi_driver_number;
    370. t_int8 cx_dianzhenzifuxianshiqi_driver_char_PerWidth;
    1. const t_uint8 cx_dianzhenzifuxianshiqi_driver_font[] = { 128, 6, 58, 2, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 0, 0, 0, 0, 3, 0, 3, 0, 0, 36, 244, 47, 244, 47, 36, 198, 137, 255, 145, 99, 0, 112, 142, 185, 78, 184, 128, 2, 197, 50, 76, 163, 64, 0, 3, 0, 0, 0, 0, 0, 0, 0, 126, 129, 0, 0, 0, 129, 126, 0, 0, 36, 24, 126, 24, 36, 0, 8, 8, 127, 8, 8, 0, 0, 128, 192, 0, 0, 0, 8, 8, 8, 8, 8, 0, 0, 192, 192, 0, 0, 0, 128, 96, 24, 6, 1, 0, 126, 129, 129, 129, 126, 0, 0, 130, 255, 128, 0, 0, 198, 161, 145, 137, 134, 0, 66, 129, 137, 137, 118, 0, 48, 44, 34, 255, 32, 0, 79, 137, 137, 137, 113, 0, 126, 137, 137, 137, 112, 0, 3, 1, 249, 7, 1, 0, 118, 137, 137, 137, 118, 0, 14, 145, 145, 145, 126, 0, 0, 0, 132, 0, 0, 0, 0, 128, 200, 0, 0, 0, 0, 8, 20, 34, 65, 0, 36, 36, 36, 36, 36, 0, 0, 0, 65, 34, 20, 8, 6, 1, 177, 9, 6, 0, 126, 129, 185, 165, 190, 0, 252, 34, 33, 34, 252, 0, 129, 255, 137, 137, 118, 0, 126, 129, 129, 129, 67, 0, 129, 255, 129, 129, 126, 0, 129, 255, 137, 157, 195, 0, 129, 255, 137, 29, 3, 0, 60, 66, 129, 145, 115, 0, 255, 8, 8, 8, 255, 0, 0, 129, 255, 129, 0, 0, 193, 129, 255, 1, 1, 0, 129, 255, 137, 52, 195, 0, 129, 255, 129, 128, 192, 0, 255, 15, 240, 15, 255, 0, 255, 7, 28, 112, 255, 0, 126, 129, 129, 129, 126, 0, 129, 255, 137, 9, 6, 0, 126, 129, 177, 193, 126, 0, 255, 17, 17, 113, 206, 0, 198, 137, 137, 145, 99, 0, 3, 129, 255, 129, 3, 0, 127, 128, 128, 128, 127, 0, 7, 56, 224, 56, 7, 0, 7, 248, 15, 248, 7, 0, 129, 231, 24, 231, 129, 0, 1, 135, 248, 135, 1, 0, 131, 225, 153, 135, 193, 0, 0, 255, 129, 129, 0, 0, 1, 6, 24, 96, 128, 0, 0, 129, 129, 255, 0, 0, 4, 2, 1, 2, 4, 0, 128, 128, 128, 128, 128, 0, 1, 2, 0, 0, 0, 0, 64, 168, 168, 248, 128, 0, 1, 255, 136, 136, 112, 0, 112, 136, 136, 152, 0, 0, 112, 136, 137, 255, 128, 0, 112, 168, 168, 168, 176, 0, 8, 254, 9, 9, 0, 0, 16, 168, 168, 168, 248, 0, 129, 255, 136, 8, 240, 0, 0, 0, 249, 0, 0, 0, 0, 192, 136, 249, 0, 0, 129, 255, 32, 80, 136, 0, 0, 1, 255, 128, 128, 0, 248, 8, 248, 8, 240, 0, 8, 248, 8, 8, 240, 0, 112, 136, 136, 112, 0, 0, 252, 36, 36, 56, 0, 0, 56, 36, 36, 252, 0, 0, 136, 248, 144, 8, 8, 0, 0, 152, 168, 168, 200, 0, 0, 8, 126, 136, 128, 0, 120, 128, 136, 248, 128, 0, 24, 96, 128, 96, 24, 0, 24, 224, 56, 224, 24, 0, 136, 216, 32, 216, 136, 0, 136, 184, 192, 96, 24, 0, 0, 136, 232, 152, 136, 0, 0, 24, 231, 129, 0, 0, 0, 0, 0, 255, 0, 0, 0, 129, 231, 24, 0, 0, 8, 4, 4, 8, 4, 0 };
    2. t_bit cx_yuyinlangduqi_driver_TX_IN;
    3. t_uint16 cx_yuyinlangduqi_driver_BitTick;
    4. t_uint16 cx_yuyinlangduqi_driver_BitTick_D32;
    5. t_uint16 cx_yuyinlangduqi_driver_BitTick_C;
    6. t_int8 cx_yuyinlangduqi_driver_number_buffer[11];
    7. t_uint8 cx_SYS_Servo_TickNumber;
    8. t_uint8 cx_SYS_Servo_PWM[8];
    9. t_uint8 cx_SYS_Servo_n;
    10. t_uint8 cx_SYS_Servo_out_put;
    11. t_uint8 cx_SYS_Servo_tick;
    12. t_uint8 cx_SYS_Servo_PWM_A;
    13. t_uint16 cx_OS0_ID_list[12];
    14. t_int32 cx_OS0_time_list[12];
    15. t_bool cx_OS0_enable_list[12];
    16. t_uint16 cx_OS0_Delayer_tempID;
    17. t_bool cx_OS0_EnableSchedule;
    18. t_bool cx_OS0_Delayer_Pause;
    19. t_uint32 cx_OS0_SysTick;
    20. t_uint16 cx_OS0_CurrentTaskIndex;
    21. t_uint8 cx_OS0_TickList[8];
    22. t_uint8 cx_OS0_MaxTickList[8];
    23. void (*cx_OS0_DriverHandleList[8])(void);
    24. t_uint8 cx_OS0_DriverNumber;
    25. void (*cx_OS0_Driver100usHandleList[1])(void);
    26. t_uint8 cx_OS0_Driver100usNumber;
    27. t_uint8 cx_OS0_tick;
    28. t_uint8 cx_OS0_DebugTick;
    29. void (*cx_OS0_s_Handle)(void);
    30. t_bool cx_xiaocheqianjin_en_;
    31. t_uint8 cx_xiaocheqianjin_flg_;
    32. t_bool cx_xiaochetingzhi_en_;
    33. t_uint8 cx_xiaochetingzhi_flg_;
    34. t_bool cx_xiaochezuozhuan_en_;
    35. t_uint8 cx_xiaochezuozhuan_flg_;
    36. t_bool cx_xiaocheyouzhuan_en_;
    37. t_uint8 cx_xiaocheyouzhuan_flg_;
    38. t_bool cx_xiaochedaoche_en_;
    39. t_uint8 cx_xiaochedaoche_flg_;
    40. t_bool cx_xiaochexingtai_en_;
    41. t_uint8 cx_xiaochexingtai_flg_;
    42. t_bool cx_kongzhiqi1_fanfuzhixing_en_;
    43. t_uint8 cx_kongzhiqi1_fanfuzhixing_flg_;
    44. t_bool cx_sizuxingtai_en_;
    45. t_uint8 cx_sizuxingtai_flg_;
    46. t_bool cx_xingzou_en_;
    47. t_uint8 cx_xingzou_flg_;
    48. t_bool cx_huoyanchuanganqi_tancedaohuoyanshi_en_;
    49. t_uint8 cx_huoyanchuanganqi_tancedaohuoyanshi_flg_;
    50. t_bool cx_kongzhiqi1_chushihua_en_;
    51. t_uint8 cx_kongzhiqi1_chushihua_flg_;
    52. t_bool cx_pingmu_en_;
    53. t_uint8 cx_pingmu_flg_;
    54. void cx_NULL_E(void)
    55. {
    56. }
    57. void cx_SYS_NullFunc(void)
    58. {
    59. }
    60. t_uint8 cx___sysbox__0_sys_iointerface_get_uint8( t_uint32 tmp_addr )
    61. {
    62. return 0;
    63. }
    64. void cx___sysbox__0_sys_iointerface_set_uint8( t_uint32 tmp_addr, t_uint8 tmp_d )
    65. {
    66. }
    67. t_uint16 cx___sysbox__0_sys_iointerface_get_uint16( t_uint32 tmp_addr )
    68. {
    69. return 0;
    70. }
    71. void cx___sysbox__0_sys_iointerface_set_uint16( t_uint32 tmp_addr, t_uint16 tmp_d )
    72. {
    73. }
    74. t_uint32 cx___sysbox__0_sys_iointerface_get_uint32( t_uint32 tmp_addr )
    75. {
    76. return 0;
    77. }
    78. void cx___sysbox__0_sys_iointerface_set_uint32( t_uint32 tmp_addr, t_uint32 tmp_d )
    79. {
    80. }
    81. void cx_youqian_driver_OS_init(void)
    82. {
    83. cx_youqian_driver_dev_init();
    84. cx_kongzhiqi1_driver_RES_DDRB |= 8;
    85. cx_kongzhiqi1_driver_RES_PORTB &= 247;
    86. if( cx_SYS_Tick < 10 ) {
    87. cx_youqian_driver_OS_time = 10;
    88. }
    89. else {
    90. cx_youqian_driver_OS_time = (t_uint8)(t_uint16)(t_uint32)cx_SYS_Tick;
    91. }
    92. cx_youqian_driver_tick = 0;
    93. cx_youqian_driver_ti = 0;
    94. cx_youqian_driver_C_Angle = 0;
    95. cx_youqian_driver_SetValue( cx_youqian_driver_C_Angle );
    96. cx_youqian_driver_SetSpeed( 1000 );
    97. }
    98. void cx_youqian_driver_OS_run(void)
    99. {
    100. if( cx_youqian_driver_C_Angle == cx_youqian_driver_Angle ) {
    101. cx_youqian_driver_ti = 0;
    102. return;
    103. }
    104. cx_youqian_driver_ti = cx_youqian_driver_ti + (cx_youqian_driver_tick);
    105. if( cx_youqian_driver_ti >= 1000 ) {
    106. t_int32 tmp_dv = cx_youqian_driver_ti / 1000;
    107. cx_youqian_driver_ti = cx_youqian_driver_ti % 1000;
    108. if( cx_youqian_driver_C_Angle > cx_youqian_driver_Angle ) {
    109. cx_youqian_driver_C_Angle = cx_youqian_driver_C_Angle - (tmp_dv);
    110. if( cx_youqian_driver_C_Angle < cx_youqian_driver_Angle ) {
    111. cx_youqian_driver_C_Angle = cx_youqian_driver_Angle;
    112. }
    113. cx_youqian_driver_SetValue( cx_youqian_driver_C_Angle );
    114. }
    115. else {
    116. cx_youqian_driver_C_Angle = cx_youqian_driver_C_Angle + (tmp_dv);
    117. if( cx_youqian_driver_C_Angle > cx_youqian_driver_Angle ) {
    118. cx_youqian_driver_C_Angle = cx_youqian_driver_Angle;
    119. }
    120. cx_youqian_driver_SetValue( cx_youqian_driver_C_Angle );
    121. }
    122. }
    123. }
    124. void cx_youqian_driver_SetSpeed( t_int32 tmp_t )
    125. {
    126. if( tmp_t < 0 ) {
    127. tmp_t = 0;
    128. }
    129. if( tmp_t > 1000 ) {
    130. tmp_t = 1000;
    131. }
    132. cx_youqian_driver_tick = tmp_t * (t_int8)cx_youqian_driver_OS_time;
    133. cx_youqian_driver_sim_SetSpeed( tmp_t );
    134. }
    135. void cx_youqian_driver_dev_init(void)
    136. {
    137. }
    138. void cx_youqian_driver_SetValue( t_int32 tmp_d )
    139. {
    140. tmp_d = -tmp_d * 55 / 90 + 90;
    141. if( tmp_d < 0 ) {
    142. tmp_d = 0;
    143. }
    144. if( tmp_d > 180 ) {
    145. tmp_d = 180;
    146. }
    147. cx_SYS_Servo_PWM[0] = (t_uint8)(t_uint16)(t_uint32)tmp_d;
    148. }
    149. void cx_youqian_driver_sim_SetSpeed( t_int32 tmp_t )
    150. {
    151. }
    152. void cx_kongzhiqi1_driver_OS_init(void)
    153. {
    154. cx_kongzhiqi1_driver_FlashOpen = 0;
    155. cx_kongzhiqi1_driver_FlashForever = 0;
    156. cx_kongzhiqi1_driver_FlashNumber = 0;
    157. cx_kongzhiqi1_driver_swap = 0;
    158. cx_kongzhiqi1_driver_OS_time = 50;
    159. cx_kongzhiqi1_driver_OS_EventFlag = 0;
    160. cx_kongzhiqi1_driver_OS_EventFlag |= 1;
    161. t_uint16 _cx_lc_1 = 10;
    162. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    163. cx_kongzhiqi1_driver_delay();
    164. }
    165. cx_kongzhiqi1_driver_RES_DDRB |= 32;
    166. cx_kongzhiqi1_driver_RES_PORTB &= 223;
    167. }
    168. void cx_kongzhiqi1_driver_OS_thread(void)
    169. {
    170. cx_kongzhiqi1_driver_OS_EventFlag |= 2;
    171. }
    172. void cx_kongzhiqi1_driver_OS_run(void)
    173. {
    174. if( !cx_kongzhiqi1_driver_FlashOpen ) {
    175. return;
    176. }
    177. cx_kongzhiqi1_driver_swap = cx_kongzhiqi1_driver_swap % (10);
    178. t_bit tmp_OUT;
    179. if( cx_kongzhiqi1_driver_swap < 1 ) {
    180. tmp_OUT = 1;
    181. }
    182. else {
    183. tmp_OUT = 0;
    184. }
    185. cx_kongzhiqi1_driver_swap = cx_kongzhiqi1_driver_swap + (1);
    186. if( cx_kongzhiqi1_driver_FlashForever ) {
    187. (tmp_OUT) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 32): (cx_kongzhiqi1_driver_RES_PORTB &= 223);
    188. return;
    189. }
    190. if( cx_kongzhiqi1_driver_FlashNumber == 0 ) {
    191. cx_kongzhiqi1_driver_FlashOpen = 0;
    192. return;
    193. }
    194. if( ((cx_kongzhiqi1_driver_RES_PORTB >> 5) & 1) == 1 && tmp_OUT == 0 ) {
    195. cx_kongzhiqi1_driver_FlashNumber = cx_kongzhiqi1_driver_FlashNumber - (1);
    196. }
    197. (tmp_OUT) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 32): (cx_kongzhiqi1_driver_RES_PORTB &= 223);
    198. }
    199. void cx_kongzhiqi1_driver_LightOpen(void)
    200. {
    201. cx_kongzhiqi1_driver_FlashOpen = 0;
    202. cx_kongzhiqi1_driver_RES_PORTB |= 32;
    203. }
    204. void cx_kongzhiqi1_driver_LightClose(void)
    205. {
    206. cx_kongzhiqi1_driver_FlashOpen = 0;
    207. cx_kongzhiqi1_driver_RES_PORTB &= 223;
    208. }
    209. void cx_kongzhiqi1_driver_LightSwap(void)
    210. {
    211. cx_kongzhiqi1_driver_FlashOpen = 0;
    212. ((((cx_kongzhiqi1_driver_RES_PORTB >> 5) & 1)^1)) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 32): (cx_kongzhiqi1_driver_RES_PORTB &= 223);
    213. }
    214. void cx_kongzhiqi1_driver_LightFlashTimes( t_int32 tmp_n )
    215. {
    216. cx_kongzhiqi1_driver_FlashNumber = tmp_n;
    217. cx_kongzhiqi1_driver_swap = 0;
    218. cx_kongzhiqi1_driver_FlashForever = 0;
    219. cx_kongzhiqi1_driver_FlashOpen = 1;
    220. }
    221. void cx_kongzhiqi1_driver_LightFlash(void)
    222. {
    223. cx_kongzhiqi1_driver_FlashNumber = 0;
    224. cx_kongzhiqi1_driver_FlashForever = 1;
    225. cx_kongzhiqi1_driver_FlashOpen = 1;
    226. }
    227. void cx_kongzhiqi1_driver_delay(void)
    228. {
    229. t_uint16 _cx_lc_1 = 250;
    230. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    231. t_uint16 _cx_lc_3 = 250;
    232. for( t_uint16 _cx_lc_2 = 0; _cx_lc_2 < _cx_lc_3; _cx_lc_2++ ) {
    233. }
    234. }
    235. }
    236. void cx_kongzhiqi1_pinMode( t_int32 tmp_p, t_int32 tmp_m )
    237. {
    238. if( tmp_p > 19 || tmp_p < 0 ) {
    239. return;
    240. }
    241. t_bit tmp_b;
    242. if( tmp_m != 0 ) {
    243. tmp_b = 1;
    244. }
    245. else {
    246. tmp_b = 0;
    247. }
    248. switch( (t_uint8)(t_uint16)(t_uint32)tmp_p ) {
    249. case 0:
    250. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 1): (cx_kongzhiqi1_driver_RES_DDRD &= 254);
    251. break;
    252. case 1:
    253. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 2): (cx_kongzhiqi1_driver_RES_DDRD &= 253);
    254. break;
    255. case 2:
    256. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 4): (cx_kongzhiqi1_driver_RES_DDRD &= 251);
    257. break;
    258. case 3:
    259. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 8): (cx_kongzhiqi1_driver_RES_DDRD &= 247);
    260. break;
    261. case 4:
    262. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 16): (cx_kongzhiqi1_driver_RES_DDRD &= 239);
    263. break;
    264. case 5:
    265. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 32): (cx_kongzhiqi1_driver_RES_DDRD &= 223);
    266. break;
    267. case 6:
    268. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 64): (cx_kongzhiqi1_driver_RES_DDRD &= 191);
    269. break;
    270. case 7:
    271. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRD |= 128): (cx_kongzhiqi1_driver_RES_DDRD &= 127);
    272. break;
    273. case 8:
    274. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRB |= 1): (cx_kongzhiqi1_driver_RES_DDRB &= 254);
    275. break;
    276. case 9:
    277. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRB |= 2): (cx_kongzhiqi1_driver_RES_DDRB &= 253);
    278. break;
    279. case 10:
    280. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRB |= 4): (cx_kongzhiqi1_driver_RES_DDRB &= 251);
    281. break;
    282. case 11:
    283. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRB |= 8): (cx_kongzhiqi1_driver_RES_DDRB &= 247);
    284. break;
    285. case 12:
    286. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRB |= 16): (cx_kongzhiqi1_driver_RES_DDRB &= 239);
    287. break;
    288. case 13:
    289. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRB |= 32): (cx_kongzhiqi1_driver_RES_DDRB &= 223);
    290. break;
    291. case 14:
    292. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRC |= 1): (cx_kongzhiqi1_driver_RES_DDRC &= 254);
    293. break;
    294. case 15:
    295. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRC |= 2): (cx_kongzhiqi1_driver_RES_DDRC &= 253);
    296. break;
    297. case 16:
    298. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRC |= 4): (cx_kongzhiqi1_driver_RES_DDRC &= 251);
    299. break;
    300. case 17:
    301. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRC |= 8): (cx_kongzhiqi1_driver_RES_DDRC &= 247);
    302. break;
    303. case 18:
    304. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRC |= 16): (cx_kongzhiqi1_driver_RES_DDRC &= 239);
    305. break;
    306. case 19:
    307. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_DDRC |= 32): (cx_kongzhiqi1_driver_RES_DDRC &= 223);
    308. break;
    309. default:
    310. break;
    311. }
    312. }
    313. void cx_kongzhiqi1_digitalWrite( t_int32 tmp_p, t_int32 tmp_d )
    314. {
    315. if( tmp_p > 19 || tmp_p < 0 ) {
    316. return;
    317. }
    318. t_bit tmp_b;
    319. if( tmp_d != 0 ) {
    320. tmp_b = 1;
    321. }
    322. else {
    323. tmp_b = 0;
    324. }
    325. switch( (t_uint8)(t_uint16)(t_uint32)tmp_p ) {
    326. case 0:
    327. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 1): (cx_kongzhiqi1_driver_RES_PORTD &= 254);
    328. break;
    329. case 1:
    330. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 2): (cx_kongzhiqi1_driver_RES_PORTD &= 253);
    331. break;
    332. case 2:
    333. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 4): (cx_kongzhiqi1_driver_RES_PORTD &= 251);
    334. break;
    335. case 3:
    336. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 8): (cx_kongzhiqi1_driver_RES_PORTD &= 247);
    337. break;
    338. case 4:
    339. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 16): (cx_kongzhiqi1_driver_RES_PORTD &= 239);
    340. break;
    341. case 5:
    342. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 32): (cx_kongzhiqi1_driver_RES_PORTD &= 223);
    343. break;
    344. case 6:
    345. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 64): (cx_kongzhiqi1_driver_RES_PORTD &= 191);
    346. break;
    347. case 7:
    348. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 128): (cx_kongzhiqi1_driver_RES_PORTD &= 127);
    349. break;
    350. case 8:
    351. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 1): (cx_kongzhiqi1_driver_RES_PORTB &= 254);
    352. break;
    353. case 9:
    354. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 2): (cx_kongzhiqi1_driver_RES_PORTB &= 253);
    355. break;
    356. case 10:
    357. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 4): (cx_kongzhiqi1_driver_RES_PORTB &= 251);
    358. break;
    359. case 11:
    360. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 8): (cx_kongzhiqi1_driver_RES_PORTB &= 247);
    361. break;
    362. case 12:
    363. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 16): (cx_kongzhiqi1_driver_RES_PORTB &= 239);
    1. break;
    2. case 13:
    3. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 32): (cx_kongzhiqi1_driver_RES_PORTB &= 223);
    4. break;
    5. case 14:
    6. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTC |= 1): (cx_kongzhiqi1_driver_RES_PORTC &= 254);
    7. break;
    8. case 15:
    9. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTC |= 2): (cx_kongzhiqi1_driver_RES_PORTC &= 253);
    10. break;
    11. case 16:
    12. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTC |= 4): (cx_kongzhiqi1_driver_RES_PORTC &= 251);
    13. break;
    14. case 17:
    15. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTC |= 8): (cx_kongzhiqi1_driver_RES_PORTC &= 247);
    16. break;
    17. case 18:
    18. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTC |= 16): (cx_kongzhiqi1_driver_RES_PORTC &= 239);
    19. break;
    20. case 19:
    21. (tmp_b) != 0 ? (cx_kongzhiqi1_driver_RES_PORTC |= 32): (cx_kongzhiqi1_driver_RES_PORTC &= 223);
    22. break;
    23. default:
    24. break;
    25. }
    26. }
    27. t_int32 cx_kongzhiqi1_digitalRead( t_int32 tmp_p )
    28. {
    29. if( tmp_p > 19 || tmp_p < 0 ) {
    30. return 0;
    31. }
    32. t_bit tmp_b;
    33. switch( (t_uint8)(t_uint16)(t_uint32)tmp_p ) {
    34. case 0:
    35. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 0) & 1);
    36. break;
    37. case 1:
    38. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 1) & 1);
    39. break;
    40. case 2:
    41. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 2) & 1);
    42. break;
    43. case 3:
    44. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 3) & 1);
    45. break;
    46. case 4:
    47. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 4) & 1);
    48. break;
    49. case 5:
    50. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 5) & 1);
    51. break;
    52. case 6:
    53. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 6) & 1);
    54. break;
    55. case 7:
    56. tmp_b = ((cx_kongzhiqi1_driver_RES_PIND >> 7) & 1);
    57. break;
    58. case 8:
    59. tmp_b = ((cx_kongzhiqi1_driver_RES_PINB >> 0) & 1);
    60. break;
    61. case 9:
    62. tmp_b = ((cx_kongzhiqi1_driver_RES_PINB >> 1) & 1);
    63. break;
    64. case 10:
    65. tmp_b = ((cx_kongzhiqi1_driver_RES_PINB >> 2) & 1);
    66. break;
    67. case 11:
    68. tmp_b = ((cx_kongzhiqi1_driver_RES_PINB >> 3) & 1);
    69. break;
    70. case 12:
    71. tmp_b = ((cx_kongzhiqi1_driver_RES_PINB >> 4) & 1);
    72. break;
    73. case 13:
    74. tmp_b = ((cx_kongzhiqi1_driver_RES_PINB >> 5) & 1);
    75. break;
    76. case 14:
    77. tmp_b = ((cx_kongzhiqi1_driver_RES_PINC >> 0) & 1);
    78. break;
    79. case 15:
    80. tmp_b = ((cx_kongzhiqi1_driver_RES_PINC >> 1) & 1);
    81. break;
    82. case 16:
    83. tmp_b = ((cx_kongzhiqi1_driver_RES_PINC >> 2) & 1);
    84. break;
    85. case 17:
    86. tmp_b = ((cx_kongzhiqi1_driver_RES_PINC >> 3) & 1);
    87. break;
    88. case 18:
    89. tmp_b = ((cx_kongzhiqi1_driver_RES_PINC >> 4) & 1);
    90. break;
    91. case 19:
    92. tmp_b = ((cx_kongzhiqi1_driver_RES_PINC >> 5) & 1);
    93. break;
    94. default:
    95. break;
    96. }
    97. if( tmp_b == 0 ) {
    98. return 0;
    99. }
    100. else {
    101. return 1;
    102. }
    103. return 0;
    104. }
    105. void cx_youhou_driver_OS_init(void)
    106. {
    107. cx_youhou_driver_dev_init();
    108. cx_kongzhiqi1_driver_RES_DDRD |= 16;
    109. cx_kongzhiqi1_driver_RES_PORTD &= 239;
    110. if( cx_SYS_Tick < 10 ) {
    111. cx_youhou_driver_OS_time = 10;
    112. }
    113. else {
    114. cx_youhou_driver_OS_time = (t_uint8)(t_uint16)(t_uint32)cx_SYS_Tick;
    115. }
    116. cx_youhou_driver_tick = 0;
    117. cx_youhou_driver_ti = 0;
    118. cx_youhou_driver_C_Angle = 0;
    119. cx_youhou_driver_SetValue( cx_youhou_driver_C_Angle );
    120. cx_youhou_driver_SetSpeed( 1000 );
    121. }
    122. void cx_youhou_driver_OS_run(void)
    123. {
    124. if( cx_youhou_driver_C_Angle == cx_youhou_driver_Angle ) {
    125. cx_youhou_driver_ti = 0;
    126. return;
    127. }
    128. cx_youhou_driver_ti = cx_youhou_driver_ti + (cx_youhou_driver_tick);
    129. if( cx_youhou_driver_ti >= 1000 ) {
    130. t_int32 tmp_dv = cx_youhou_driver_ti / 1000;
    131. cx_youhou_driver_ti = cx_youhou_driver_ti % 1000;
    132. if( cx_youhou_driver_C_Angle > cx_youhou_driver_Angle ) {
    133. cx_youhou_driver_C_Angle = cx_youhou_driver_C_Angle - (tmp_dv);
    134. if( cx_youhou_driver_C_Angle < cx_youhou_driver_Angle ) {
    135. cx_youhou_driver_C_Angle = cx_youhou_driver_Angle;
    136. }
    137. cx_youhou_driver_SetValue( cx_youhou_driver_C_Angle );
    138. }
    139. else {
    140. cx_youhou_driver_C_Angle = cx_youhou_driver_C_Angle + (tmp_dv);
    141. if( cx_youhou_driver_C_Angle > cx_youhou_driver_Angle ) {
    142. cx_youhou_driver_C_Angle = cx_youhou_driver_Angle;
    143. }
    144. cx_youhou_driver_SetValue( cx_youhou_driver_C_Angle );
    145. }
    146. }
    147. }
    148. void cx_youhou_driver_SetSpeed( t_int32 tmp_t )
    149. {
    150. if( tmp_t < 0 ) {
    151. tmp_t = 0;
    152. }
    153. if( tmp_t > 1000 ) {
    154. tmp_t = 1000;
    155. }
    156. cx_youhou_driver_tick = tmp_t * (t_int8)cx_youhou_driver_OS_time;
    157. cx_youhou_driver_sim_SetSpeed( tmp_t );
    158. }
    159. void cx_youhou_driver_dev_init(void)
    160. {
    161. }
    162. void cx_youhou_driver_SetValue( t_int32 tmp_d )
    163. {
    164. tmp_d = -tmp_d * 55 / 90 + 90;
    165. if( tmp_d < 0 ) {
    166. tmp_d = 0;
    167. }
    168. if( tmp_d > 180 ) {
    169. tmp_d = 180;
    170. }
    171. cx_SYS_Servo_PWM[1] = (t_uint8)(t_uint16)(t_uint32)tmp_d;
    172. }
    173. void cx_youhou_driver_sim_SetSpeed( t_int32 tmp_t )
    174. {
    175. }
    176. void cx_zuohou_driver_OS_init(void)
    177. {
    178. cx_zuohou_driver_dev_init();
    179. cx_kongzhiqi1_driver_RES_DDRB |= 1;
    180. cx_kongzhiqi1_driver_RES_PORTB &= 254;
    181. if( cx_SYS_Tick < 10 ) {
    182. cx_zuohou_driver_OS_time = 10;
    183. }
    184. else {
    185. cx_zuohou_driver_OS_time = (t_uint8)(t_uint16)(t_uint32)cx_SYS_Tick;
    186. }
    187. cx_zuohou_driver_tick = 0;
    188. cx_zuohou_driver_ti = 0;
    189. cx_zuohou_driver_C_Angle = 0;
    190. cx_zuohou_driver_SetValue( cx_zuohou_driver_C_Angle );
    191. cx_zuohou_driver_SetSpeed( 1000 );
    192. }
    193. void cx_zuohou_driver_OS_run(void)
    194. {
    195. if( cx_zuohou_driver_C_Angle == cx_zuohou_driver_Angle ) {
    196. cx_zuohou_driver_ti = 0;
    197. return;
    198. }
    199. cx_zuohou_driver_ti = cx_zuohou_driver_ti + (cx_zuohou_driver_tick);
    200. if( cx_zuohou_driver_ti >= 1000 ) {
    201. t_int32 tmp_dv = cx_zuohou_driver_ti / 1000;
    202. cx_zuohou_driver_ti = cx_zuohou_driver_ti % 1000;
    203. if( cx_zuohou_driver_C_Angle > cx_zuohou_driver_Angle ) {
    204. cx_zuohou_driver_C_Angle = cx_zuohou_driver_C_Angle - (tmp_dv);
    205. if( cx_zuohou_driver_C_Angle < cx_zuohou_driver_Angle ) {
    206. cx_zuohou_driver_C_Angle = cx_zuohou_driver_Angle;
    207. }
    208. cx_zuohou_driver_SetValue( cx_zuohou_driver_C_Angle );
    209. }
    210. else {
    211. cx_zuohou_driver_C_Angle = cx_zuohou_driver_C_Angle + (tmp_dv);
    212. if( cx_zuohou_driver_C_Angle > cx_zuohou_driver_Angle ) {
    213. cx_zuohou_driver_C_Angle = cx_zuohou_driver_Angle;
    214. }
    215. cx_zuohou_driver_SetValue( cx_zuohou_driver_C_Angle );
    216. }
    217. }
    218. }
    219. void cx_zuohou_driver_SetSpeed( t_int32 tmp_t )
    220. {
    221. if( tmp_t < 0 ) {
    222. tmp_t = 0;
    223. }
    224. if( tmp_t > 1000 ) {
    225. tmp_t = 1000;
    226. }
    227. cx_zuohou_driver_tick = tmp_t * (t_int8)cx_zuohou_driver_OS_time;
    228. cx_zuohou_driver_sim_SetSpeed( tmp_t );
    229. }
    230. void cx_zuohou_driver_dev_init(void)
    231. {
    232. }
    233. void cx_zuohou_driver_SetValue( t_int32 tmp_d )
    234. {
    235. tmp_d = -tmp_d * 55 / 90 + 90;
    236. if( tmp_d < 0 ) {
    237. tmp_d = 0;
    238. }
    239. if( tmp_d > 180 ) {
    240. tmp_d = 180;
    241. }
    242. cx_SYS_Servo_PWM[2] = (t_uint8)(t_uint16)(t_uint32)tmp_d;
    243. }
    244. void cx_zuohou_driver_sim_SetSpeed( t_int32 tmp_t )
    245. {
    246. }
    247. void cx_zuoqian_driver_OS_init(void)
    248. {
    249. cx_zuoqian_driver_dev_init();
    250. cx_kongzhiqi1_driver_RES_DDRB |= 16;
    251. cx_kongzhiqi1_driver_RES_PORTB &= 239;
    252. if( cx_SYS_Tick < 10 ) {
    253. cx_zuoqian_driver_OS_time = 10;
    254. }
    255. else {
    256. cx_zuoqian_driver_OS_time = (t_uint8)(t_uint16)(t_uint32)cx_SYS_Tick;
    257. }
    258. cx_zuoqian_driver_tick = 0;
    259. cx_zuoqian_driver_ti = 0;
    260. cx_zuoqian_driver_C_Angle = 0;
    261. cx_zuoqian_driver_SetValue( cx_zuoqian_driver_C_Angle );
    262. cx_zuoqian_driver_SetSpeed( 1000 );
    263. }
    264. void cx_zuoqian_driver_OS_run(void)
    265. {
    266. if( cx_zuoqian_driver_C_Angle == cx_zuoqian_driver_Angle ) {
    267. cx_zuoqian_driver_ti = 0;
    268. return;
    269. }
    270. cx_zuoqian_driver_ti = cx_zuoqian_driver_ti + (cx_zuoqian_driver_tick);
    271. if( cx_zuoqian_driver_ti >= 1000 ) {
    272. t_int32 tmp_dv = cx_zuoqian_driver_ti / 1000;
    273. cx_zuoqian_driver_ti = cx_zuoqian_driver_ti % 1000;
    274. if( cx_zuoqian_driver_C_Angle > cx_zuoqian_driver_Angle ) {
    275. cx_zuoqian_driver_C_Angle = cx_zuoqian_driver_C_Angle - (tmp_dv);
    276. if( cx_zuoqian_driver_C_Angle < cx_zuoqian_driver_Angle ) {
    277. cx_zuoqian_driver_C_Angle = cx_zuoqian_driver_Angle;
    278. }
    279. cx_zuoqian_driver_SetValue( cx_zuoqian_driver_C_Angle );
    280. }
    281. else {
    282. cx_zuoqian_driver_C_Angle = cx_zuoqian_driver_C_Angle + (tmp_dv);
    283. if( cx_zuoqian_driver_C_Angle > cx_zuoqian_driver_Angle ) {
    284. cx_zuoqian_driver_C_Angle = cx_zuoqian_driver_Angle;
    285. }
    286. cx_zuoqian_driver_SetValue( cx_zuoqian_driver_C_Angle );
    287. }
    288. }
    289. }
    290. void cx_zuoqian_driver_SetSpeed( t_int32 tmp_t )
    291. {
    292. if( tmp_t < 0 ) {
    293. tmp_t = 0;
    294. }
    295. if( tmp_t > 1000 ) {
    296. tmp_t = 1000;
    297. }
    298. cx_zuoqian_driver_tick = tmp_t * (t_int8)cx_zuoqian_driver_OS_time;
    299. cx_zuoqian_driver_sim_SetSpeed( tmp_t );
    300. }
    301. void cx_zuoqian_driver_dev_init(void)
    302. {
    303. }
    304. void cx_zuoqian_driver_SetValue( t_int32 tmp_d )
    305. {
    306. tmp_d = -tmp_d * 55 / 90 + 90;
    307. if( tmp_d < 0 ) {
    308. tmp_d = 0;
    309. }
    310. if( tmp_d > 180 ) {
    311. tmp_d = 180;
    312. }
    313. cx_SYS_Servo_PWM[3] = (t_uint8)(t_uint16)(t_uint32)tmp_d;
    314. }
    315. void cx_zuoqian_driver_sim_SetSpeed( t_int32 tmp_t )
    316. {
    317. }
    318. void cx_madaqudongqi_driver_OS_init(void)
    319. {
    320. cx_kongzhiqi1_driver_RES_DDRB |= 4;
    321. cx_kongzhiqi1_driver_RES_PORTB &= 251;
    322. cx_kongzhiqi1_driver_RES_DDRB |= 2;
    323. cx_kongzhiqi1_driver_RES_PORTB &= 253;
    324. cx_kongzhiqi1_driver_RES_DDRD |= 64;
    325. cx_kongzhiqi1_driver_RES_PORTD &= 191;
    326. cx_kongzhiqi1_driver_RES_DDRD |= 32;
    327. cx_kongzhiqi1_driver_RES_PORTD &= 223;
    328. cx_madaqudongqi_driver_valueA = 100;
    329. cx_madaqudongqi_driver_valueB = 100;
    330. cx_madaqudongqi_driver_tick = 0;
    331. cx_madaqudongqi_driver_DTA1 = 0;
    332. cx_madaqudongqi_driver_DTA2 = 0;
    333. cx_madaqudongqi_driver_DTB1 = 0;
    334. cx_madaqudongqi_driver_DTB2 = 0;
    335. cx_madaqudongqi_driver_T = (t_int8)(t_int16)1;
    336. cx_madaqudongqi_driver_tt = 0;
    337. cx_madaqudongqi_driver_vex_init();
    338. }
    339. void cx_madaqudongqi_driver_set_t( t_int32 tmp_t )
    340. {
    341. cx_madaqudongqi_driver_T = (t_int8)(t_int16)tmp_t;
    342. cx_madaqudongqi_driver_tt = 0;
    343. }
    344. void cx_madaqudongqi_driver_vex_init(void)
    345. {
    346. }
    347. void cx_madaqudongqi_driver_OS_run100us(void)
    348. {
    349. cx_madaqudongqi_driver_tt = cx_madaqudongqi_driver_tt + (1);
    350. if( cx_madaqudongqi_driver_tt < cx_madaqudongqi_driver_T ) {
    351. return;
    352. }
    353. cx_madaqudongqi_driver_tt = 0;
    354. cx_madaqudongqi_driver_tick = cx_madaqudongqi_driver_tick % (100);
    355. t_bool tmp_ResetA = cx_madaqudongqi_driver_tick == 0;
    356. t_bool tmp_ResetB = tmp_ResetA;
    357. if( cx_madaqudongqi_driver_tick >= cx_madaqudongqi_driver_valueA ) {
    358. cx_kongzhiqi1_driver_RES_PORTB &= 251;
    359. cx_kongzhiqi1_driver_RES_PORTB &= 253;
    360. tmp_ResetA = 0;
    361. }
    362. if( tmp_ResetA ) {
    363. (cx_madaqudongqi_driver_DTA1) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 4): (cx_kongzhiqi1_driver_RES_PORTB &= 251);
    364. (cx_madaqudongqi_driver_DTA2) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 2): (cx_kongzhiqi1_driver_RES_PORTB &= 253);
    365. }
    366. if( cx_madaqudongqi_driver_tick >= cx_madaqudongqi_driver_valueB ) {
    367. cx_kongzhiqi1_driver_RES_PORTD &= 191;
    368. cx_kongzhiqi1_driver_RES_PORTD &= 223;
    369. tmp_ResetB = 0;
    370. }
    371. if( tmp_ResetB ) {
    372. (cx_madaqudongqi_driver_DTB1) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 64): (cx_kongzhiqi1_driver_RES_PORTD &= 191);
    373. (cx_madaqudongqi_driver_DTB2) != 0 ? (cx_kongzhiqi1_driver_RES_PORTD |= 32): (cx_kongzhiqi1_driver_RES_PORTD &= 223);
    374. }
    375. cx_madaqudongqi_driver_tick = cx_madaqudongqi_driver_tick + (1);
    376. }
    377. void cx_youludai_driver_init(void)
    378. {
    379. }
    380. void cx_youludai_driver_set_power( t_int32 tmp_p )
    381. {
    382. if( tmp_p < 0 ) {
    383. tmp_p = 0;
    384. }
    385. if( tmp_p > 100 ) {
    1. tmp_p = 100;
    2. }
    3. cx_madaqudongqi_driver_valueB = (t_int8)(t_int16)tmp_p;
    4. }
    5. void cx_youludai_driver_run_right(void)
    6. {
    7. cx_kongzhiqi1_driver_RES_PORTD |= 32;
    8. cx_madaqudongqi_driver_DTB2 = 1;
    9. cx_kongzhiqi1_driver_RES_PORTD &= 191;
    10. cx_madaqudongqi_driver_DTB1 = 0;
    11. }
    12. void cx_youludai_driver_run_left(void)
    13. {
    14. cx_kongzhiqi1_driver_RES_PORTD |= 64;
    15. cx_madaqudongqi_driver_DTB1 = 1;
    16. cx_kongzhiqi1_driver_RES_PORTD &= 223;
    17. cx_madaqudongqi_driver_DTB2 = 0;
    18. }
    19. void cx_youludai_driver_stop(void)
    20. {
    21. cx_kongzhiqi1_driver_RES_PORTD &= 191;
    22. cx_madaqudongqi_driver_DTB1 = 0;
    23. cx_kongzhiqi1_driver_RES_PORTD &= 223;
    24. cx_madaqudongqi_driver_DTB2 = 0;
    25. }
    26. void cx_youludai_driver_short_stop(void)
    27. {
    28. cx_kongzhiqi1_driver_RES_PORTD |= 64;
    29. cx_madaqudongqi_driver_DTB1 = 1;
    30. cx_kongzhiqi1_driver_RES_PORTD |= 32;
    31. cx_madaqudongqi_driver_DTB1 = 1;
    32. }
    33. void cx_youludai_driver_OS_init(void)
    34. {
    35. cx_youludai_driver_init();
    36. cx_youludai_driver_stop();
    37. }
    38. void cx_zuoludai_driver_init(void)
    39. {
    40. }
    41. void cx_zuoludai_driver_set_power( t_int32 tmp_p )
    42. {
    43. if( tmp_p < 0 ) {
    44. tmp_p = 0;
    45. }
    46. if( tmp_p > 100 ) {
    47. tmp_p = 100;
    48. }
    49. cx_madaqudongqi_driver_valueA = (t_int8)(t_int16)tmp_p;
    50. }
    51. void cx_zuoludai_driver_run_right(void)
    52. {
    53. cx_kongzhiqi1_driver_RES_PORTB |= 2;
    54. cx_madaqudongqi_driver_DTA2 = 1;
    55. cx_kongzhiqi1_driver_RES_PORTB &= 251;
    56. cx_madaqudongqi_driver_DTA1 = 0;
    57. }
    58. void cx_zuoludai_driver_run_left(void)
    59. {
    60. cx_kongzhiqi1_driver_RES_PORTB |= 4;
    61. cx_madaqudongqi_driver_DTA1 = 1;
    62. cx_kongzhiqi1_driver_RES_PORTB &= 253;
    63. cx_madaqudongqi_driver_DTA2 = 0;
    64. }
    65. void cx_zuoludai_driver_stop(void)
    66. {
    67. cx_kongzhiqi1_driver_RES_PORTB &= 251;
    68. cx_madaqudongqi_driver_DTA1 = 0;
    69. cx_kongzhiqi1_driver_RES_PORTB &= 253;
    70. cx_madaqudongqi_driver_DTA2 = 0;
    71. }
    72. void cx_zuoludai_driver_short_stop(void)
    73. {
    74. cx_kongzhiqi1_driver_RES_PORTB |= 4;
    75. cx_madaqudongqi_driver_DTA1 = 1;
    76. cx_kongzhiqi1_driver_RES_PORTB |= 2;
    77. cx_madaqudongqi_driver_DTA1 = 1;
    78. }
    79. void cx_zuoludai_driver_OS_init(void)
    80. {
    81. cx_zuoludai_driver_init();
    82. cx_zuoludai_driver_stop();
    83. }
    84. t_int32 cx_chaoshengbocejuqi_driver_get_value(void)
    85. {
    86. cx_kongzhiqi1_driver_RES_PORTC |= 2;
    87. t_uint16 _cx_lc_1 = 10;
    88. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    89. }
    90. cx_kongzhiqi1_driver_RES_PORTC &= 253;
    91. t_int16 tmp_d = 0;
    92. while( tmp_d < 1000 && ((cx_kongzhiqi1_driver_RES_PINC >> 0) & 1) == 0 ) {
    93. tmp_d = tmp_d + (1);
    94. }
    95. tmp_d = 0;
    96. while( tmp_d < 3000 && ((cx_kongzhiqi1_driver_RES_PINC >> 0) & 1) == 1 ) {
    97. tmp_d = tmp_d + (1);
    98. }
    99. t_int32 tmp_dd = tmp_d;
    100. return tmp_dd * 269 / 500 - 10;
    101. }
    102. t_int32 cx_chaoshengbocejuqi_driver_get_good_value(void)
    103. {
    104. return cx_chaoshengbocejuqi_driver_get_value();
    105. }
    106. void cx_chaoshengbocejuqi_driver_OS_init(void)
    107. {
    108. cx_kongzhiqi1_driver_RES_DDRC |= 2;
    109. cx_kongzhiqi1_driver_RES_PORTC &= 253;
    110. cx_kongzhiqi1_driver_RES_DDRC &= 254;
    111. cx_kongzhiqi1_driver_RES_PORTC |= 1;
    112. }
    113. void cx_huoyanchuanganqi_driver_OS_init(void)
    114. {
    115. cx_kongzhiqi1_driver_RES_DDRC &= 251;
    116. cx_kongzhiqi1_driver_RES_PORTC |= 4;
    117. cx_huoyanchuanganqi_driver_OS_time = 1;
    118. cx_huoyanchuanganqi_driver_OS_EventFlag = 0;
    119. cx_huoyanchuanganqi_driver_last_key0_press = 0;
    120. }
    121. void cx_huoyanchuanganqi_driver_OS_run(void)
    122. {
    123. t_bit tmp_KEY0 = (((cx_kongzhiqi1_driver_RES_PINC >> 2) & 1)^1);
    124. t_bit tmp_key0_down = tmp_KEY0 & (cx_huoyanchuanganqi_driver_last_key0_press^1);
    125. t_bit tmp_key0_up = (tmp_KEY0^1) & cx_huoyanchuanganqi_driver_last_key0_press;
    126. if( tmp_key0_down == 1 ) {
    127. cx_huoyanchuanganqi_driver_OS_EventFlag |= 1;
    128. }
    129. if( tmp_key0_up == 1 ) {
    130. cx_huoyanchuanganqi_driver_OS_EventFlag |= 2;
    131. }
    132. cx_huoyanchuanganqi_driver_last_key0_press = tmp_KEY0;
    133. if( tmp_KEY0 == 1 ) {
    134. cx_huoyanchuanganqi_driver_key0_press = 1;
    135. }
    136. else {
    137. cx_huoyanchuanganqi_driver_key0_press = 0;
    138. }
    139. }
    140. void cx_wenshiduchuanganqi_driver_OS_init(void)
    141. {
    142. cx_kongzhiqi1_driver_RES_DDRD |= 8;
    143. cx_kongzhiqi1_driver_RES_PORTD |= 8;
    144. cx_wenshiduchuanganqi_driver_OS_time = 250;
    145. cx_wenshiduchuanganqi_driver_NeedRefresh = 1;
    146. }
    147. void cx_wenshiduchuanganqi_driver_OS_run(void)
    148. {
    149. cx_wenshiduchuanganqi_driver_tick = cx_wenshiduchuanganqi_driver_tick + (1);
    150. if( cx_wenshiduchuanganqi_driver_tick == 10 ) {
    151. cx_wenshiduchuanganqi_driver_tick = 0;
    152. if( cx_wenshiduchuanganqi_driver_NeedRefresh ) {
    153. cx_wenshiduchuanganqi_driver_NeedRefresh = 0;
    154. t_uint32 tmp_d = cx_wenshiduchuanganqi_driver_read();
    155. t_uint32 tmp_u_wendu = ((tmp_d >> 8) & 255);
    156. t_uint32 tmp_u_shidu = ((tmp_d >> 24) & 255);
    157. cx_wenshiduchuanganqi_driver_v_wendu = (t_int32)tmp_u_wendu;
    158. if( ((tmp_d >> 7) & 1) == 1 ) {
    159. cx_wenshiduchuanganqi_driver_v_wendu = -cx_wenshiduchuanganqi_driver_v_wendu;
    160. }
    161. cx_wenshiduchuanganqi_driver_v_shidu = (t_int32)tmp_u_shidu;
    162. }
    163. }
    164. }
    165. t_int32 cx_wenshiduchuanganqi_driver_wendu(void)
    166. {
    167. cx_wenshiduchuanganqi_driver_NeedRefresh = 1;
    168. return cx_wenshiduchuanganqi_driver_v_wendu;
    169. }
    170. t_int32 cx_wenshiduchuanganqi_driver_shidu(void)
    171. {
    172. cx_wenshiduchuanganqi_driver_NeedRefresh = 1;
    173. return cx_wenshiduchuanganqi_driver_v_shidu;
    174. }
    175. t_uint32 cx_wenshiduchuanganqi_driver_read(void)
    176. {
    177. cx_kongzhiqi1_driver_RES_PORTD &= 247;
    178. t_uint16 _cx_lc_1 = 10;
    179. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    180. cx_sys_delayer_delay_n_10us( 180 );
    181. }
    182. cx_kongzhiqi1_driver_RES_PORTD |= 8;
    183. cx_sys_delayer_delay_n_10us( 3 );
    184. cx_kongzhiqi1_driver_RES_DDRD &= 247;
    185. cx_wenshiduchuanganqi_driver_tickout = 0;
    186. while( ((cx_kongzhiqi1_driver_RES_PIND >> 3) & 1) == 1 && cx_wenshiduchuanganqi_driver_tickout < 30000 ) {
    187. cx_wenshiduchuanganqi_driver_tickout = cx_wenshiduchuanganqi_driver_tickout + (1);
    188. }
    189. cx_wenshiduchuanganqi_driver_tickout = 0;
    190. while( ((cx_kongzhiqi1_driver_RES_PIND >> 3) & 1) == 0 && cx_wenshiduchuanganqi_driver_tickout < 30000 ) {
    191. cx_wenshiduchuanganqi_driver_tickout = cx_wenshiduchuanganqi_driver_tickout + (1);
    192. }
    193. cx_wenshiduchuanganqi_driver_tickout = 0;
    194. while( ((cx_kongzhiqi1_driver_RES_PIND >> 3) & 1) == 1 && cx_wenshiduchuanganqi_driver_tickout < 30000 ) {
    195. cx_wenshiduchuanganqi_driver_tickout = cx_wenshiduchuanganqi_driver_tickout + (1);
    196. }
    197. t_uint32 tmp_d;
    198. tmp_d |= (t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 24; tmp_d &= ((t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 24) | 16777215;
    199. tmp_d |= (t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 16; tmp_d &= ((t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 16) | 4278255615;
    200. tmp_d |= (t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 8; tmp_d &= ((t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 8) | 4294902015;
    201. tmp_d |= (t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 0; tmp_d &= ((t_uint32)(cx_wenshiduchuanganqi_driver_get_byte()) << 0) | 4294967040;
    202. t_uint8 tmp_sum = cx_wenshiduchuanganqi_driver_get_byte();
    203. cx_kongzhiqi1_driver_RES_DDRD |= 8;
    204. return tmp_d;
    205. }
    206. t_uint8 cx_wenshiduchuanganqi_driver_get_byte(void)
    207. {
    208. t_uint8 tmp_d;
    209. t_uint16 _cx_lc_1 = 8;
    210. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    211. tmp_d = tmp_d << (1);
    212. cx_wenshiduchuanganqi_driver_tickout = 0;
    213. while( ((cx_kongzhiqi1_driver_RES_PIND >> 3) & 1) == 0 && cx_wenshiduchuanganqi_driver_tickout < 30000 ) {
    214. cx_wenshiduchuanganqi_driver_tickout = cx_wenshiduchuanganqi_driver_tickout + (1);
    215. }
    216. cx_sys_delayer_delay_n_10us( 5 );
    217. (((cx_kongzhiqi1_driver_RES_PIND >> 3) & 1)) != 0 ? (tmp_d |= 1): (tmp_d &= 254);
    218. cx_wenshiduchuanganqi_driver_tickout = 0;
    219. while( ((cx_kongzhiqi1_driver_RES_PIND >> 3) & 1) == 1 && cx_wenshiduchuanganqi_driver_tickout < 30000 ) {
    220. cx_wenshiduchuanganqi_driver_tickout = cx_wenshiduchuanganqi_driver_tickout + (1);
    221. }
    222. }
    223. return tmp_d;
    224. }
    225. void cx_yanshiqi_driver_OS_init(void)
    226. {
    227. }
    228. void cx_yanshiqi_driver_OS_thread(void)
    229. {
    230. }
    231. void cx_yanshiqi_driver_DelayMillisecond( t_int32 tmp_t )
    232. {
    233. t_int32 tmp_tt = tmp_t;
    234. if( tmp_tt != 0 ) {
    235. cx_OS0_Delayer_tempID = 39;
    236. cx_OS0_Delayer_Wait( tmp_tt );
    237. }
    238. }
    239. void cx_yanshiqi_driver_DelaySecond( t_fix tmp_t )
    240. {
    241. t_uint32 tmp_d = (t_uint32)tmp_t;
    242. tmp_d = tmp_d * 1000 / 1024;
    243. cx_yanshiqi_driver_DelayMillisecond( (t_int32)tmp_d );
    244. }
    245. void cx_yanshiqi_driver_DelayMinute( t_int32 tmp_t )
    246. {
    247. cx_yanshiqi_driver_DelayMillisecond( tmp_t * 60000 );
    248. }
    249. void cx_yanshiqi_driver_DelayHour( t_int32 tmp_t )
    250. {
    251. cx_yanshiqi_driver_DelayMillisecond( tmp_t * 3600000 );
    252. }
    253. void cx_yanshiqi_driver_DelayDay( t_int32 tmp_t )
    254. {
    255. cx_yanshiqi_driver_DelayMillisecond( tmp_t * 86400000 );
    256. }
    257. void cx_yanshiqi_driver_Stop(void)
    258. {
    259. cx_OS0_Delayer_Stop( 39 );
    260. }
    261. void cx_yanshiqi_driver_StopCurrent(void)
    262. {
    263. cx_OS0_Delayer_Stop( 39 );
    264. }
    265. void cx_yanshiqi_driver_StopAll(void)
    266. {
    267. cx_OS0_Delayer_StopAll();
    268. }
    269. void cx_yanwuchuanganqi_driver_OS_init(void)
    270. {
    271. }
    272. t_int32 cx_yanwuchuanganqi_driver_get_data(void)
    273. {
    274. t_uint16 tmp_data = analogRead( 4 );
    275. t_uint32 tmp_d = tmp_data;
    276. return 0 + (t_int32)tmp_d * (1023 - 0 + 1) / 1024;
    277. }
    278. void cx_pingmu1_driver_Refresh(void)
    279. {
    280. cx_pingmu1_driver_OS_thread();
    281. }
    282. void cx_pingmu1_driver_command_I2C_Init(void)
    283. {
    284. cx_kongzhiqi1_driver_RES_DDRC |= 8;
    285. cx_kongzhiqi1_driver_RES_PORTC |= 8;
    286. cx_kongzhiqi1_driver_RES_DDRD |= 4;
    287. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    288. cx_pingmu1_driver_command_I2C_start_iic();
    289. cx_pingmu1_driver_command_I2C_end_iic();
    290. cx_pingmu1_driver_command_I2C_delay_1us();
    291. }
    292. void cx_pingmu1_driver_command_I2C_A2_set_uint8( t_uint8 tmp_DeviceAddr, t_uint16 tmp_addr, t_uint8 tmp_data )
    293. {
    294. cx_pingmu1_driver_command_I2C_start_iic();
    295. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr );
    296. cx_pingmu1_driver_command_I2C_write_byte( ((tmp_addr >> 8) & 255) );
    297. cx_pingmu1_driver_command_I2C_write_byte( ((tmp_addr >> 0) & 255) );
    298. cx_pingmu1_driver_command_I2C_write_byte( tmp_data );
    299. cx_pingmu1_driver_command_I2C_end_iic();
    300. }
    301. t_uint8 cx_pingmu1_driver_command_I2C_A2_get_uint8( t_uint8 tmp_DeviceAddr, t_uint16 tmp_addr )
    302. {
    303. cx_pingmu1_driver_command_I2C_start_iic();
    304. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr );
    305. cx_pingmu1_driver_command_I2C_write_byte( ((tmp_addr >> 8) & 255) );
    306. cx_pingmu1_driver_command_I2C_write_byte( ((tmp_addr >> 0) & 255) );
    307. cx_pingmu1_driver_command_I2C_start_iic();
    308. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr | 1 );
    309. t_uint8 tmp_data = cx_pingmu1_driver_command_I2C_read_byte();
    310. cx_pingmu1_driver_command_I2C_NoAck();
    311. cx_pingmu1_driver_command_I2C_end_iic();
    312. return tmp_data;
    313. }
    1. void cx_pingmu1_driver_command_I2C_A1_set_uint8( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr, t_uint8 tmp_data )
    2. {
    3. cx_pingmu1_driver_command_I2C_start_iic();
    4. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr );
    5. cx_pingmu1_driver_command_I2C_write_byte( tmp_addr );
    6. cx_pingmu1_driver_command_I2C_write_byte( tmp_data );
    7. cx_pingmu1_driver_command_I2C_end_iic();
    8. }
    9. t_uint8 cx_pingmu1_driver_command_I2C_A1_get_uint8( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr )
    10. {
    11. cx_pingmu1_driver_command_I2C_start_iic();
    12. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr );
    13. cx_pingmu1_driver_command_I2C_write_byte( tmp_addr );
    14. cx_pingmu1_driver_command_I2C_start_iic();
    15. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr | 1 );
    16. t_uint8 tmp_data = cx_pingmu1_driver_command_I2C_read_byte();
    17. cx_pingmu1_driver_command_I2C_NoAck();
    18. cx_pingmu1_driver_command_I2C_end_iic();
    19. return tmp_data;
    20. }
    21. void cx_pingmu1_driver_command_I2C_A1_get_byte2( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr )
    22. {
    23. cx_pingmu1_driver_command_I2C_start_iic();
    24. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr );
    25. cx_pingmu1_driver_command_I2C_write_byte( tmp_addr );
    26. cx_pingmu1_driver_command_I2C_start_iic();
    27. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr | 1 );
    28. cx_pingmu1_driver_command_I2C_byte0 = cx_pingmu1_driver_command_I2C_read_byte();
    29. cx_pingmu1_driver_command_I2C_Ack();
    30. cx_pingmu1_driver_command_I2C_byte1 = cx_pingmu1_driver_command_I2C_read_byte();
    31. cx_pingmu1_driver_command_I2C_NoAck();
    32. cx_pingmu1_driver_command_I2C_end_iic();
    33. }
    34. void cx_pingmu1_driver_command_I2C_A1_get_byte4( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr )
    35. {
    36. cx_pingmu1_driver_command_I2C_start_iic();
    37. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr );
    38. cx_pingmu1_driver_command_I2C_write_byte( tmp_addr );
    39. cx_pingmu1_driver_command_I2C_start_iic();
    40. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr | 1 );
    41. cx_pingmu1_driver_command_I2C_byte0 = cx_pingmu1_driver_command_I2C_read_byte();
    42. cx_pingmu1_driver_command_I2C_Ack();
    43. cx_pingmu1_driver_command_I2C_byte1 = cx_pingmu1_driver_command_I2C_read_byte();
    44. cx_pingmu1_driver_command_I2C_Ack();
    45. cx_pingmu1_driver_command_I2C_byte2 = cx_pingmu1_driver_command_I2C_read_byte();
    46. cx_pingmu1_driver_command_I2C_Ack();
    47. cx_pingmu1_driver_command_I2C_byte3 = cx_pingmu1_driver_command_I2C_read_byte();
    48. cx_pingmu1_driver_command_I2C_NoAck();
    49. cx_pingmu1_driver_command_I2C_end_iic();
    50. }
    51. void cx_pingmu1_driver_command_I2C_A1_get_byte6( t_uint8 tmp_DeviceAddr, t_uint8 tmp_addr )
    52. {
    53. cx_pingmu1_driver_command_I2C_start_iic();
    54. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr );
    55. cx_pingmu1_driver_command_I2C_write_byte( tmp_addr );
    56. cx_pingmu1_driver_command_I2C_start_iic();
    57. cx_pingmu1_driver_command_I2C_write_byte( tmp_DeviceAddr | 1 );
    58. cx_pingmu1_driver_command_I2C_byte0 = cx_pingmu1_driver_command_I2C_read_byte();
    59. cx_pingmu1_driver_command_I2C_Ack();
    60. cx_pingmu1_driver_command_I2C_byte1 = cx_pingmu1_driver_command_I2C_read_byte();
    61. cx_pingmu1_driver_command_I2C_Ack();
    62. cx_pingmu1_driver_command_I2C_byte2 = cx_pingmu1_driver_command_I2C_read_byte();
    63. cx_pingmu1_driver_command_I2C_Ack();
    64. cx_pingmu1_driver_command_I2C_byte3 = cx_pingmu1_driver_command_I2C_read_byte();
    65. cx_pingmu1_driver_command_I2C_Ack();
    66. cx_pingmu1_driver_command_I2C_byte4 = cx_pingmu1_driver_command_I2C_read_byte();
    67. cx_pingmu1_driver_command_I2C_Ack();
    68. cx_pingmu1_driver_command_I2C_byte5 = cx_pingmu1_driver_command_I2C_read_byte();
    69. cx_pingmu1_driver_command_I2C_NoAck();
    70. cx_pingmu1_driver_command_I2C_end_iic();
    71. }
    72. void cx_pingmu1_driver_command_I2C_start_iic(void)
    73. {
    74. cx_kongzhiqi1_driver_RES_PORTC |= 8;
    75. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    76. cx_pingmu1_driver_command_I2C_delay_1us();
    77. cx_kongzhiqi1_driver_RES_PORTC &= 247;
    78. cx_pingmu1_driver_command_I2C_delay_1us();
    79. cx_kongzhiqi1_driver_RES_PORTD &= 251;
    80. cx_pingmu1_driver_command_I2C_delay_1us();
    81. }
    82. void cx_pingmu1_driver_command_I2C_end_iic(void)
    83. {
    84. cx_kongzhiqi1_driver_RES_PORTC &= 247;
    85. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    86. cx_pingmu1_driver_command_I2C_delay_1us();
    87. cx_kongzhiqi1_driver_RES_PORTC |= 8;
    88. cx_pingmu1_driver_command_I2C_delay_1us();
    89. }
    90. void cx_pingmu1_driver_command_I2C_wait(void)
    91. {
    92. cx_kongzhiqi1_driver_RES_DDRC &= 247;
    93. cx_kongzhiqi1_driver_RES_PORTC |= 8;
    94. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    95. while( ((cx_kongzhiqi1_driver_RES_PINC >> 3) & 1) == 1 ) {
    96. }
    97. cx_kongzhiqi1_driver_RES_PORTD &= 251;
    98. cx_pingmu1_driver_command_I2C_delay_1us();
    99. cx_kongzhiqi1_driver_RES_DDRC |= 8;
    100. cx_pingmu1_driver_command_I2C_delay_1us();
    101. }
    102. void cx_pingmu1_driver_command_I2C_write_byte( t_uint8 tmp_data )
    103. {
    104. t_uint16 _cx_lc_1 = 8;
    105. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    106. (((tmp_data >> 7) & 1)) != 0 ? (cx_kongzhiqi1_driver_RES_PORTC |= 8): (cx_kongzhiqi1_driver_RES_PORTC &= 247);
    107. tmp_data = tmp_data << (1);
    108. cx_pingmu1_driver_command_I2C_delay_1us();
    109. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    110. cx_pingmu1_driver_command_I2C_delay_1us();
    111. cx_kongzhiqi1_driver_RES_PORTD &= 251;
    112. cx_pingmu1_driver_command_I2C_delay_1us();
    113. }
    114. cx_pingmu1_driver_command_I2C_wait();
    115. }
    116. t_uint8 cx_pingmu1_driver_command_I2C_read_byte(void)
    117. {
    118. t_uint8 tmp_data;
    119. cx_kongzhiqi1_driver_RES_DDRC &= 247;
    120. cx_kongzhiqi1_driver_RES_PORTC |= 8;
    121. cx_pingmu1_driver_command_I2C_delay_1us();
    122. t_uint16 _cx_lc_1 = 8;
    123. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    124. tmp_data = tmp_data << (1);
    125. (((cx_kongzhiqi1_driver_RES_PINC >> 3) & 1)) != 0 ? (tmp_data |= 1): (tmp_data &= 254);
    126. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    127. cx_pingmu1_driver_command_I2C_delay_1us();
    128. cx_kongzhiqi1_driver_RES_PORTD &= 251;
    129. cx_pingmu1_driver_command_I2C_delay_1us();
    130. }
    131. cx_kongzhiqi1_driver_RES_DDRC |= 8;
    132. return tmp_data;
    133. }
    134. void cx_pingmu1_driver_command_I2C_Ack(void)
    135. {
    136. cx_kongzhiqi1_driver_RES_PORTC &= 247;
    137. cx_pingmu1_driver_command_I2C_delay_1us();
    138. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    139. cx_pingmu1_driver_command_I2C_delay_1us();
    140. cx_kongzhiqi1_driver_RES_PORTD &= 251;
    141. cx_pingmu1_driver_command_I2C_delay_1us();
    142. }
    143. void cx_pingmu1_driver_command_I2C_NoAck(void)
    144. {
    145. cx_kongzhiqi1_driver_RES_PORTC |= 8;
    146. cx_pingmu1_driver_command_I2C_delay_1us();
    147. cx_kongzhiqi1_driver_RES_PORTD |= 4;
    148. cx_pingmu1_driver_command_I2C_delay_1us();
    149. cx_kongzhiqi1_driver_RES_PORTD &= 251;
    150. cx_pingmu1_driver_command_I2C_delay_1us();
    151. }
    152. void cx_pingmu1_driver_command_I2C_delay_1us(void)
    153. {
    154. cx_sys_delayer_delay_n_1us( 1 );
    155. }
    156. void cx_pingmu1_driver_command_OS_init(void)
    157. {
    158. cx_pingmu1_driver_command_I2C_Init();
    159. cx_pingmu1_driver_command_write_command( 174 );
    160. cx_pingmu1_driver_command_write_command( 0 );
    161. cx_pingmu1_driver_command_write_command( 16 );
    162. cx_pingmu1_driver_command_write_command( 64 );
    163. cx_pingmu1_driver_command_write_command( 129 );
    164. cx_pingmu1_driver_command_write_command( 207 );
    165. cx_pingmu1_driver_command_write_command( 161 );
    166. cx_pingmu1_driver_command_write_command( 200 );
    167. cx_pingmu1_driver_command_write_command( 166 );
    168. cx_pingmu1_driver_command_write_command( 168 );
    169. cx_pingmu1_driver_command_write_command( 63 );
    170. cx_pingmu1_driver_command_write_command( 211 );
    171. cx_pingmu1_driver_command_write_command( 0 );
    172. cx_pingmu1_driver_command_write_command( 213 );
    173. cx_pingmu1_driver_command_write_command( 128 );
    174. cx_pingmu1_driver_command_write_command( 217 );
    175. cx_pingmu1_driver_command_write_command( 241 );
    176. cx_pingmu1_driver_command_write_command( 218 );
    177. cx_pingmu1_driver_command_write_command( 18 );
    178. cx_pingmu1_driver_command_write_command( 219 );
    179. cx_pingmu1_driver_command_write_command( 64 );
    180. cx_pingmu1_driver_command_write_command( 32 );
    181. cx_pingmu1_driver_command_write_command( 2 );
    182. cx_pingmu1_driver_command_write_command( 141 );
    183. cx_pingmu1_driver_command_write_command( 20 );
    184. cx_pingmu1_driver_command_write_command( 164 );
    185. cx_pingmu1_driver_command_write_command( 166 );
    186. cx_pingmu1_driver_command_write_command( 175 );
    187. }
    188. void cx_pingmu1_driver_command_write_command( t_uint8 tmp_C )
    189. {
    190. cx_pingmu1_driver_command_I2C_start_iic();
    191. cx_pingmu1_driver_command_I2C_write_byte( 120 );
    192. cx_pingmu1_driver_command_I2C_write_byte( 0 );
    193. cx_pingmu1_driver_command_I2C_write_byte( tmp_C );
    194. cx_pingmu1_driver_command_I2C_end_iic();
    195. }
    196. void cx_pingmu1_driver_command_write_data( t_uint8 tmp_D )
    197. {
    198. cx_pingmu1_driver_command_I2C_start_iic();
    199. cx_pingmu1_driver_command_I2C_write_byte( 120 );
    200. cx_pingmu1_driver_command_I2C_write_byte( 64 );
    201. cx_pingmu1_driver_command_I2C_write_byte( tmp_D );
    202. cx_pingmu1_driver_command_I2C_end_iic();
    203. }
    204. void cx_pingmu1_driver_OS_thread(void)
    205. {
    206. if( cx_pingmu1_driver_NeedRefresh ) {
    207. cx_pingmu1_driver_NeedRefresh = 0;
    208. t_uint8 tmp_line = 0;
    209. t_uint16 tmp_index = 0;
    210. t_uint16 _cx_lc_1 = 8;
    211. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    212. cx_pingmu1_driver_command_write_command( 176 + tmp_line );
    213. cx_pingmu1_driver_command_write_command( 0 + (t_uint8)cx_pingmu1_driver_Offset );
    214. cx_pingmu1_driver_command_write_command( 16 );
    215. tmp_line = tmp_line + (1);
    216. t_uint16 _cx_lc_3 = 128;
    217. for( t_uint16 _cx_lc_2 = 0; _cx_lc_2 < _cx_lc_3; _cx_lc_2++ ) {
    218. cx_pingmu1_driver_command_write_data( cx_pingmu1_driver_buffer[tmp_index] );
    219. tmp_index = tmp_index + (1);
    220. }
    221. }
    222. }
    223. }
    224. void cx_pingmu1_driver_Init(void)
    225. {
    226. if( 0 ) {
    227. cx_pingmu1_driver_Height = 128;
    228. cx_pingmu1_driver_Width = 8 * 8;
    229. }
    230. else {
    231. cx_pingmu1_driver_Width = 128;
    232. cx_pingmu1_driver_Height = 8 * 8;
    233. }
    234. cx_pingmu1_driver_PenWidth = 1;
    235. cx_pingmu1_driver_ForColor = 1;
    236. cx_pingmu1_driver_BackColor = 0;
    237. cx_pingmu1_driver_NeedRefresh = 0;
    238. cx_pingmu1_driver_Clear();
    239. }
    240. void cx_pingmu1_driver_Clear(void)
    241. {
    242. t_uint8 tmp_d = 0;
    243. if( cx_pingmu1_driver_BackColor < 0 ) {
    244. return;
    245. }
    246. if( cx_pingmu1_driver_BackColor == 0 ) {
    247. tmp_d = 0;
    248. }
    249. else {
    250. tmp_d = 255;
    251. }
    252. for( t_int16 tmp_i = 0; tmp_i < 1024; ) {
    253. cx_pingmu1_driver_buffer[tmp_i] = tmp_d;
    254. tmp_i = tmp_i + (1);
    255. }
    256. cx_pingmu1_driver_NeedRefresh = 1;
    257. }
    258. void cx_pingmu1_driver_set_refresh(void)
    259. {
    260. cx_pingmu1_driver_NeedRefresh = 1;
    261. }
    262. void cx_pingmu1_driver_pixel( t_int32 tmp_x, t_int32 tmp_y )
    263. {
    264. if( cx_pingmu1_driver_ForColor < 0 ) {
    265. return;
    266. }
    267. if( cx_pingmu1_driver_ForColor == 0 ) {
    268. cx_pingmu1_driver_dot_set = 0;
    269. }
    270. else {
    271. cx_pingmu1_driver_dot_set = 1;
    272. }
    273. cx_pingmu1_driver_pixel1( tmp_x, tmp_y );
    274. }
    275. void cx_pingmu1_driver_clear_pixel( t_int32 tmp_x, t_int32 tmp_y )
    276. {
    277. if( cx_pingmu1_driver_BackColor < 0 ) {
    278. return;
    279. }
    280. if( cx_pingmu1_driver_BackColor == 0 ) {
    1. cx_pingmu1_driver_dot_set = 0;
    2. }
    3. else {
    4. cx_pingmu1_driver_dot_set = 1;
    5. }
    6. cx_pingmu1_driver_pixel1( tmp_x, tmp_y );
    7. }
    8. void cx_pingmu1_driver_pixel1( t_int32 tmp_x, t_int32 tmp_y )
    9. {
    10. if( tmp_x < 0 || tmp_x >= cx_pingmu1_driver_Width || tmp_y < 0 || tmp_y >= cx_pingmu1_driver_Height ) {
    11. return;
    12. }
    13. if( 0 ) {
    14. tmp_x = cx_pingmu1_driver_Width - 1 - tmp_x;
    15. }
    16. if( 0 ) {
    17. tmp_y = cx_pingmu1_driver_Height - 1 - tmp_y;
    18. }
    19. if( 0 ) {
    20. t_int32 tmp_t = tmp_x;
    21. tmp_x = tmp_y;
    22. tmp_y = tmp_t;
    23. }
    24. if( cx_pingmu1_driver_PenWidth == 1 ) {
    25. cx_pingmu1_driver_pixel0( tmp_x, tmp_y );
    26. }
    27. if( cx_pingmu1_driver_PenWidth < 1 ) {
    28. return;
    29. }
    30. t_int32 tmp_x0 = tmp_x - cx_pingmu1_driver_PenWidth / 2;
    31. tmp_y = tmp_y - cx_pingmu1_driver_PenWidth / 2;
    32. t_uint16 _cx_lc_1 = cx_pingmu1_driver_PenWidth;
    33. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    34. t_int32 tmp_xx0 = tmp_x0;
    35. t_uint16 _cx_lc_3 = cx_pingmu1_driver_PenWidth;
    36. for( t_uint16 _cx_lc_2 = 0; _cx_lc_2 < _cx_lc_3; _cx_lc_2++ ) {
    37. cx_pingmu1_driver_pixel0( tmp_xx0, tmp_y );
    38. tmp_xx0 = tmp_xx0 + (1);
    39. }
    40. tmp_y = tmp_y + (1);
    41. }
    42. }
    43. void cx_pingmu1_driver_pixel0( t_int32 tmp_x, t_int32 tmp_y )
    44. {
    45. t_int8 tmp_m = (t_int8)(t_int16)tmp_y % 8;
    46. t_uint16 tmp_yy = (t_uint16)(t_uint32)tmp_y;
    47. t_uint16 tmp_index = tmp_yy / 8;
    48. tmp_index = tmp_index * (t_uint16)128 + (t_uint16)(t_uint32)tmp_x;
    49. t_uint8 tmp_data = cx_pingmu1_driver_buffer[tmp_index];
    50. if( cx_pingmu1_driver_dot_set ) {
    51. tmp_data = tmp_data | (1 << (t_uint8)tmp_m);
    52. }
    53. else {
    54. tmp_data = tmp_data & (~(1 << (t_uint8)tmp_m));
    55. }
    56. cx_pingmu1_driver_buffer[tmp_index] = tmp_data;
    57. cx_pingmu1_driver_NeedRefresh = 1;
    58. }
    59. t_int32 cx_pingmu1_driver_get_pixel( t_int32 tmp_x, t_int32 tmp_y )
    60. {
    61. if( tmp_x < 0 || tmp_x >= cx_pingmu1_driver_Width || tmp_y < 0 || tmp_y >= cx_pingmu1_driver_Height ) {
    62. return 1;
    63. }
    64. if( 0 ) {
    65. tmp_x = cx_pingmu1_driver_Width - 1 - tmp_x;
    66. }
    67. if( 0 ) {
    68. tmp_y = cx_pingmu1_driver_Height - 1 - tmp_y;
    69. }
    70. if( 0 ) {
    71. t_int32 tmp_t = tmp_x;
    72. tmp_x = tmp_y;
    73. tmp_y = tmp_t;
    74. }
    75. t_int8 tmp_m = (t_int8)(t_int16)tmp_y % 8;
    76. t_uint16 tmp_yy = (t_uint16)(t_uint32)tmp_y;
    77. t_uint16 tmp_index = tmp_yy / 8;
    78. tmp_index = tmp_index * (t_uint16)128 + (t_uint16)(t_uint32)tmp_x;
    79. t_uint8 tmp_data = cx_pingmu1_driver_buffer[tmp_index];
    80. tmp_data = tmp_data >> ((t_uint8)tmp_m);
    81. if( ((tmp_data >> 0) & 1) == 1 ) {
    82. return 1;
    83. }
    84. else {
    85. return 0;
    86. }
    87. return 0;
    88. }
    89. void cx_pingmu1_driver_Move( t_int32 tmp_v, t_int32 tmp_vy )
    90. {
    91. t_uint8 tmp_yy = (t_uint8)(t_uint16)(t_uint32)tmp_vy;
    92. t_uint8 tmp_off = tmp_yy % 8;
    93. tmp_yy = tmp_yy / (8);
    94. t_uint8 tmp_sft = (t_uint8)(t_uint16)(t_uint32)tmp_v;
    95. for( t_uint8 tmp_x = 4; tmp_x < 92; ) {
    96. t_uint8 tmp_lastData = 0;
    97. t_uint8 tmp_y;
    98. for( tmp_y = 0; tmp_y <= tmp_yy; ) {
    99. t_uint16 tmp_index = tmp_y;
    100. tmp_index = tmp_index * (t_uint16)128 + tmp_x;
    101. t_uint16 tmp_data = cx_pingmu1_driver_buffer[tmp_index];
    102. if( tmp_y == tmp_yy ) {
    103. if( tmp_off == 0 ) {
    104. break;
    105. }
    106. t_uint8 tmp_b = 255 << tmp_off;
    107. tmp_lastData = tmp_lastData | (((tmp_data >> 0) & 255) << tmp_sft);
    108. tmp_lastData = tmp_lastData & (~tmp_b);
    109. tmp_data = tmp_data & (tmp_b);
    110. }
    111. else {
    112. tmp_data = tmp_data << (tmp_sft);
    113. }
    114. tmp_data |= (t_uint16)(((tmp_data >> 0) & 255) | tmp_lastData) << 0; tmp_data &= ((t_uint16)(((tmp_data >> 0) & 255) | tmp_lastData) << 0) | 65280;
    115. cx_pingmu1_driver_buffer[tmp_index] = ((tmp_data >> 0) & 255);
    116. t_uint32 tmp_dd = ((tmp_data >> 0) & 255);
    117. tmp_lastData = ((tmp_data >> 8) & 255);
    118. tmp_y = tmp_y + (1);
    119. }
    120. tmp_x = tmp_x + (1);
    121. }
    122. cx_pingmu1_driver_NeedRefresh = 1;
    123. }
    124. void cx_pingmu1_driver_OS_init(void)
    125. {
    126. cx_pingmu1_driver_Offset = 2;
    127. cx_pingmu1_driver_command_OS_init();
    128. cx_pingmu1_driver_Init();
    129. }
    130. void cx_chaoshengduoji_driver_OS_init(void)
    131. {
    132. cx_chaoshengduoji_driver_dev_init();
    133. cx_kongzhiqi1_driver_RES_DDRD |= 128;
    134. cx_kongzhiqi1_driver_RES_PORTD &= 127;
    135. if( cx_SYS_Tick < 10 ) {
    136. cx_chaoshengduoji_driver_OS_time = 10;
    137. }
    138. else {
    139. cx_chaoshengduoji_driver_OS_time = (t_uint8)(t_uint16)(t_uint32)cx_SYS_Tick;
    140. }
    141. cx_chaoshengduoji_driver_tick = 0;
    142. cx_chaoshengduoji_driver_ti = 0;
    143. cx_chaoshengduoji_driver_C_Angle = 0;
    144. cx_chaoshengduoji_driver_SetValue( cx_chaoshengduoji_driver_C_Angle );
    145. cx_chaoshengduoji_driver_SetSpeed( 1000 );
    146. }
    147. void cx_chaoshengduoji_driver_OS_run(void)
    148. {
    149. if( cx_chaoshengduoji_driver_C_Angle == cx_chaoshengduoji_driver_Angle ) {
    150. cx_chaoshengduoji_driver_ti = 0;
    151. return;
    152. }
    153. cx_chaoshengduoji_driver_ti = cx_chaoshengduoji_driver_ti + (cx_chaoshengduoji_driver_tick);
    154. if( cx_chaoshengduoji_driver_ti >= 1000 ) {
    155. t_int32 tmp_dv = cx_chaoshengduoji_driver_ti / 1000;
    156. cx_chaoshengduoji_driver_ti = cx_chaoshengduoji_driver_ti % 1000;
    157. if( cx_chaoshengduoji_driver_C_Angle > cx_chaoshengduoji_driver_Angle ) {
    158. cx_chaoshengduoji_driver_C_Angle = cx_chaoshengduoji_driver_C_Angle - (tmp_dv);
    159. if( cx_chaoshengduoji_driver_C_Angle < cx_chaoshengduoji_driver_Angle ) {
    160. cx_chaoshengduoji_driver_C_Angle = cx_chaoshengduoji_driver_Angle;
    161. }
    162. cx_chaoshengduoji_driver_SetValue( cx_chaoshengduoji_driver_C_Angle );
    163. }
    164. else {
    165. cx_chaoshengduoji_driver_C_Angle = cx_chaoshengduoji_driver_C_Angle + (tmp_dv);
    166. if( cx_chaoshengduoji_driver_C_Angle > cx_chaoshengduoji_driver_Angle ) {
    167. cx_chaoshengduoji_driver_C_Angle = cx_chaoshengduoji_driver_Angle;
    168. }
    169. cx_chaoshengduoji_driver_SetValue( cx_chaoshengduoji_driver_C_Angle );
    170. }
    171. }
    172. }
    173. void cx_chaoshengduoji_driver_SetSpeed( t_int32 tmp_t )
    174. {
    175. if( tmp_t < 0 ) {
    176. tmp_t = 0;
    177. }
    178. if( tmp_t > 1000 ) {
    179. tmp_t = 1000;
    180. }
    181. cx_chaoshengduoji_driver_tick = tmp_t * (t_int8)cx_chaoshengduoji_driver_OS_time;
    182. cx_chaoshengduoji_driver_sim_SetSpeed( tmp_t );
    183. }
    184. void cx_chaoshengduoji_driver_dev_init(void)
    185. {
    186. }
    187. void cx_chaoshengduoji_driver_SetValue( t_int32 tmp_d )
    188. {
    189. tmp_d = -tmp_d * 55 / 90 + 90;
    190. if( tmp_d < 0 ) {
    191. tmp_d = 0;
    192. }
    193. if( tmp_d > 180 ) {
    194. tmp_d = 180;
    195. }
    196. cx_SYS_Servo_PWM[4] = (t_uint8)(t_uint16)(t_uint32)tmp_d;
    197. }
    198. void cx_chaoshengduoji_driver_sim_SetSpeed( t_int32 tmp_t )
    199. {
    200. }
    201. void cx_xinxixianshiqi_driver_OS_init(void)
    202. {
    203. cx_xinxixianshiqi_driver_bchar = 32;
    204. cx_xinxixianshiqi_driver_number = 0;
    205. }
    206. void cx_xinxixianshiqi_driver_clear(void)
    207. {
    208. cx_dianzhenzifuxianshiqi_driver_clear();
    209. }
    210. void cx_xinxixianshiqi_driver_clear_line( t_int32 tmp_line )
    211. {
    212. cx_dianzhenzifuxianshiqi_driver_clear_line( tmp_line );
    213. }
    214. void cx_xinxixianshiqi_driver_show_text( t_int32 tmp_line, t_int32 tmp_column, t_int8 tmp_string[] )
    215. {
    216. t_int16 tmp_i = 0;
    217. while( true ) {
    218. t_uint8 tmp_ch = (t_uint8)tmp_string[tmp_i];
    219. if( tmp_ch == 0 ) {
    220. return;
    221. }
    222. t_uint32 tmp_cc = tmp_ch;
    223. if( tmp_ch > 127 ) {
    224. tmp_i = tmp_i + (1);
    225. tmp_cc |= (t_uint32)(tmp_ch) << 0; tmp_cc &= ((t_uint32)(tmp_ch) << 0) | 4294967040;
    226. tmp_cc |= (t_uint32)((t_uint8)tmp_string[tmp_i]) << 8; tmp_cc &= ((t_uint32)((t_uint8)tmp_string[tmp_i]) << 8) | 4294902015;
    227. }
    228. cx_dianzhenzifuxianshiqi_driver_print_line( tmp_line, tmp_column, (t_int32)tmp_cc );
    229. tmp_column = tmp_column + (cx_dianzhenzifuxianshiqi_driver_char_PerWidth);
    230. tmp_i = tmp_i + (1);
    231. }
    232. }
    233. void cx_xinxixianshiqi_driver_show_text_f( t_int32 tmp_line, t_int32 tmp_column, t_int8 tmp_string[] )
    234. {
    235. t_int16 tmp_i = 0;
    236. t_uint8 tmp_ch;
    237. while( true ) {
    238. tmp_ch = (t_uint8)tmp_string[tmp_i];
    239. if( tmp_ch == 0 ) {
    240. break;
    241. }
    242. tmp_i = tmp_i + (1);
    243. }
    244. t_uint16 _cx_lc_1 = tmp_i;
    245. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    246. tmp_i = tmp_i - (1);
    247. tmp_ch = (t_uint8)tmp_string[tmp_i];
    248. t_uint32 tmp_cc = tmp_ch;
    249. if( tmp_ch > 127 ) {
    250. tmp_i = tmp_i + (1);
    251. tmp_cc |= (t_uint32)(tmp_ch) << 0; tmp_cc &= ((t_uint32)(tmp_ch) << 0) | 4294967040;
    252. tmp_cc |= (t_uint32)((t_uint8)tmp_string[tmp_i]) << 8; tmp_cc &= ((t_uint32)((t_uint8)tmp_string[tmp_i]) << 8) | 4294902015;
    253. }
    254. cx_dianzhenzifuxianshiqi_driver_print_line( tmp_line, tmp_column, (t_int32)tmp_cc );
    255. tmp_column = tmp_column - (cx_dianzhenzifuxianshiqi_driver_char_PerWidth);
    256. }
    257. }
    258. void cx_xinxixianshiqi_driver_show_number_f( t_int32 tmp_line, t_int32 tmp_column, t_int32 tmp_data0 )
    259. {
    260. cx_xinxixianshiqi_driver_show_number_ff( tmp_line, tmp_column, tmp_data0 );
    261. }
    262. void cx_xinxixianshiqi_driver_show_number_ff( t_int32 tmp_line, t_int32 tmp_column, t_int32 tmp_data0 )
    263. {
    264. t_bool tmp_isNeg;
    265. t_uint32 tmp_data;
    266. if( tmp_data0 >= 0 ) {
    267. tmp_data = (t_uint32)tmp_data0;
    268. tmp_isNeg = 0;
    269. }
    270. else {
    271. tmp_data = (t_uint32)-tmp_data0;
    272. tmp_isNeg = 1;
    273. }
    274. t_int8 tmp_i = 0;
    275. t_int8 tmp_ch = 0;
    276. while( true ) {
    277. tmp_ch = 48 + (t_int8)(t_uint8)(t_uint16)(tmp_data % 10);
    278. cx_xinxixianshiqi_driver_number_buffer[tmp_i] = tmp_ch;
    279. tmp_i = tmp_i + (1);
    280. tmp_data = tmp_data / (10);
    281. if( tmp_data == 0 ) {
    282. break;
    283. }
    284. }
    285. if( tmp_isNeg ) {
    286. cx_xinxixianshiqi_driver_number_buffer[tmp_i] = 45;
    287. tmp_i = tmp_i + (1);
    288. }
    289. if( cx_xinxixianshiqi_driver_number != 0 && tmp_i < cx_xinxixianshiqi_driver_number ) {
    290. t_int8 tmp_x = cx_xinxixianshiqi_driver_number - tmp_i;
    291. t_int8 tmp_y = tmp_i;
    292. t_uint16 _cx_lc_1 = tmp_x;
    293. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    294. cx_xinxixianshiqi_driver_number_buffer[tmp_y] = cx_xinxixianshiqi_driver_bchar;
    295. tmp_y = tmp_y + (1);
    296. }
    297. tmp_i = cx_xinxixianshiqi_driver_number;
    298. }
    299. t_int8 tmp_j = 0;
    300. t_uint16 _cx_lc_3 = tmp_i;
    301. for( t_uint16 _cx_lc_2 = 0; _cx_lc_2 < _cx_lc_3; _cx_lc_2++ ) {
    302. tmp_ch = cx_xinxixianshiqi_driver_number_buffer[tmp_j];
    303. cx_dianzhenzifuxianshiqi_driver_print_line( tmp_line, tmp_column, tmp_ch );
    304. tmp_j = tmp_j + (1);
    305. tmp_column = tmp_column - (cx_dianzhenzifuxianshiqi_driver_char_PerWidth);
    306. }
    307. }
    308. void cx_xinxixianshiqi_driver_show_number( t_int32 tmp_line, t_int32 tmp_column, t_int32 tmp_data0 )
    309. {
    310. t_bool tmp_isNeg;
    311. t_uint32 tmp_data;
    312. if( tmp_data0 >= 0 ) {
    313. tmp_data = (t_uint32)tmp_data0;
    314. tmp_isNeg = 0;
    315. }
    316. else {
    317. tmp_data = (t_uint32)-tmp_data0;
    318. tmp_isNeg = 1;
    319. }
    320. t_int8 tmp_i = 0;
    321. t_int8 tmp_ch = 0;
    322. while( true ) {
    323. tmp_ch = 48 + (t_int8)(t_uint8)(t_uint16)(tmp_data % 10);
    324. cx_xinxixianshiqi_driver_number_buffer[tmp_i] = tmp_ch;
    325. tmp_i = tmp_i + (1);
    326. tmp_data = tmp_data / (10);
    327. if( tmp_data == 0 ) {
    328. break;
    329. }
    330. }
    331. if( tmp_isNeg ) {
    332. cx_xinxixianshiqi_driver_number_buffer[tmp_i] = 45;
    333. tmp_i = tmp_i + (1);
    334. }
    335. if( cx_xinxixianshiqi_driver_number != 0 && tmp_i < cx_xinxixianshiqi_driver_number ) {
    336. t_int8 tmp_x = cx_xinxixianshiqi_driver_number - tmp_i;
    337. t_int8 tmp_y = tmp_i;
    338. t_uint16 _cx_lc_1 = tmp_x;
    339. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    340. cx_xinxixianshiqi_driver_number_buffer[tmp_y] = cx_xinxixianshiqi_driver_bchar;
    341. tmp_y = tmp_y + (1);
    342. }
    343. tmp_i = cx_xinxixianshiqi_driver_number;
    344. }
    345. t_uint16 _cx_lc_3 = tmp_i;
    346. for( t_uint16 _cx_lc_2 = 0; _cx_lc_2 < _cx_lc_3; _cx_lc_2++ ) {
    347. tmp_i = tmp_i - (1);
    348. tmp_ch = cx_xinxixianshiqi_driver_number_buffer[tmp_i];
    349. cx_dianzhenzifuxianshiqi_driver_print_line( tmp_line, tmp_column, tmp_ch );
    350. tmp_column = tmp_column + (cx_dianzhenzifuxianshiqi_driver_char_PerWidth);
    351. }
    352. }
    353. void cx_xinxixianshiqi_driver_set_format( t_int32 tmp_c, t_int32 tmp_n )
    354. {
    355. cx_xinxixianshiqi_driver_bchar = (t_int8)(t_int16)tmp_c;
    356. if( cx_xinxixianshiqi_driver_bchar < 32 ) {
    357. cx_xinxixianshiqi_driver_bchar = cx_xinxixianshiqi_driver_bchar + (48);
    358. }
    359. cx_xinxixianshiqi_driver_number = (t_int8)(t_int16)tmp_n;
    360. if( cx_xinxixianshiqi_driver_number > 11 ) {
    361. cx_xinxixianshiqi_driver_number = 11;
    362. }
    363. }
    364. void cx_xinxixianshiqi_driver_clear_format(void)
    365. {
    366. cx_xinxixianshiqi_driver_number = 0;
    367. }
    368. void cx_dianzhenzifuxianshiqi_driver_OS_init(void)
    369. {
    370. cx_dianzhenzifuxianshiqi_driver_SetEnglishFontDefault();
    371. }
    372. void cx_dianzhenzifuxianshiqi_driver_clear(void)
    373. {
    374. cx_pingmu1_driver_Clear();
    375. }
    376. void cx_dianzhenzifuxianshiqi_driver_clear_line( t_int32 tmp_line )
    377. {
    378. }
    379. void cx_dianzhenzifuxianshiqi_driver_print_line1( t_int32 tmp_x, t_int32 tmp_y, t_int32 tmp_c )
    380. {
    381. cx_dianzhenzifuxianshiqi_driver_print_line( tmp_y, tmp_x, tmp_c );
    382. }
    383. void cx_dianzhenzifuxianshiqi_driver_print_line( t_int32 tmp_YY, t_int32 tmp_XX, t_int32 tmp_c )
    384. {
    385. if( tmp_c < 32 ) {
    386. tmp_c = tmp_c + (48);
    387. }
    388. tmp_c = tmp_c - (32);
    389. t_int16 tmp_X = (t_int16)tmp_XX;
    390. t_int16 tmp_Y = (t_int16)tmp_YY;
    391. t_uint16 tmp_BufferIndex = 0;
    392. t_uint8 tmp_length = 0;
    393. t_uint8 tmp_t = (*cx_dianzhenzifuxianshiqi_driver_EnglishFont);
    394. if( tmp_t == 129 && tmp_c <= 127 ) {
    395. t_uint8 tmp_cc = (t_uint8)(t_uint16)(t_uint32)tmp_c;
    396. tmp_length = (*cx_dianzhenzifuxianshiqi_driver_EnglishFont)[0];
    397. tmp_BufferIndex = (tmp_length + 1);
    398. for( t_uint8 tmp_i = 0; tmp_i < tmp_length; ) {
    399. if( (*cx_dianzhenzifuxianshiqi_driver_EnglishFont)[1 + tmp_i] == tmp_cc + 32 ) {
    400. tmp_c = (t_int8)tmp_i;
    401. break;
    402. }
    403. tmp_i = tmp_i + (1);
    404. }
    405. }
    406. if( tmp_c > 127 ) {
    407. t_uint16 tmp_cc1 = (t_uint16)(t_uint32)tmp_c;
    408. tmp_length = (*cx_dianzhenzifuxianshiqi_driver_ChineseFont)[0];
    409. for( t_uint8 tmp_i1 = 0; tmp_i1 < tmp_length; ) {
    410. t_uint16 tmp_gb2312 = 0;
    411. tmp_gb2312 |= (t_uint16)((*cx_dianzhenzifuxianshiqi_driver_ChineseFont)[1 + tmp_i1]) << 0; tmp_gb2312 &= ((t_uint16)((*cx_dianzhenzifuxianshiqi_driver_ChineseFont)[1 + tmp_i1]) << 0) | 65280;
    412. tmp_gb2312 |= (t_uint16)((*cx_dianzhenzifuxianshiqi_driver_ChineseFont)[2 + tmp_i1]) << 8; tmp_gb2312 &= ((t_uint16)((*cx_dianzhenzifuxianshiqi_driver_ChineseFont)[2 + tmp_i1]) << 8) | 255;
    413. if( tmp_gb2312 == tmp_cc1 + 32 ) {
    414. tmp_c = (t_int8)tmp_i1 / 2;
    415. break;
    416. }
    417. tmp_i1 = tmp_i1 + (2);
    418. }
    419. cx_dianzhenzifuxianshiqi_driver_char_PerWidth = (*cx_dianzhenzifuxianshiqi_driver_ChineseFont);
    420. tmp_BufferIndex = (tmp_length + 1);
    421. tmp_BufferIndex = tmp_BufferIndex + (((t_uint16)(t_uint32)tmp_c * (t_uint8)cx_dianzhenzifuxianshiqi_driver_char_PerWidth));
    422. cx_dianzhenzifuxianshiqi_driver_DrawChar( cx_dianzhenzifuxianshiqi_driver_char_PerWidth, (*cx_dianzhenzifuxianshiqi_driver_ChineseFont), tmp_BufferIndex, tmp_X, tmp_Y );
    423. }
    424. else {
    425. cx_dianzhenzifuxianshiqi_driver_char_PerWidth = (*cx_dianzhenzifuxianshiqi_driver_EnglishFont);
    426. tmp_BufferIndex = tmp_BufferIndex + (((t_uint16)(t_uint32)tmp_c * (t_uint8)cx_dianzhenzifuxianshiqi_driver_char_PerWidth));
    427. cx_dianzhenzifuxianshiqi_driver_DrawChar( cx_dianzhenzifuxianshiqi_driver_char_PerWidth, (*cx_dianzhenzifuxianshiqi_driver_EnglishFont), tmp_BufferIndex, tmp_X, tmp_Y );
    428. }
    429. cx_pingmu1_driver_set_refresh();
    430. }
    431. void cx_dianzhenzifuxianshiqi_driver_DrawChar( t_int8 tmp_PerWidth, t_#.点阵字符显示器.driver.icon *tmp_tfont, t_uint16 tmp_BufferIndex, t_int16 tmp_X, t_int16 tmp_Y )
    432. {
    433. t_uint16 tmp_ColumnE = (*tmp_tfont) * 256 + (*tmp_tfont);
    434. t_uint8 tmp_lineNE = (*tmp_tfont);
    435. t_uint16 tmp_line = tmp_lineNE;
    436. if( tmp_lineNE % 8 == 0 && tmp_lineNE != 0 ) {
    437. tmp_lineNE = tmp_lineNE / 8;
    438. }
    439. else {
    440. tmp_lineNE = tmp_lineNE / 8 + 1;
    441. }
    442. for( t_uint8 tmp_i = 0; tmp_i < (t_uint8)tmp_PerWidth; ) {
    443. t_uint16 tmp_bindex = tmp_BufferIndex + tmp_i;
    444. t_int16 tmp_yy = tmp_Y;
    445. for( t_uint8 tmp_j = 0; tmp_j < tmp_lineNE; ) {
    446. t_uint8 tmp_data = (*tmp_tfont)[tmp_bindex];
    447. t_uint16 _cx_lc_1 = 8;
    448. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    449. if( ((tmp_data >> 0) & 1) == 1 ) {
    450. cx_pingmu1_driver_pixel( tmp_X, tmp_yy );
    451. }
    452. else {
    453. cx_pingmu1_driver_clear_pixel( tmp_X, tmp_yy );
    454. }
    455. tmp_data = tmp_data >> (1);
    456. tmp_yy = tmp_yy + (1);
    457. if( tmp_Y + (t_int16)tmp_line <= tmp_yy ) {
    458. break;
    459. }
    460. }
    461. tmp_bindex = tmp_bindex + (tmp_ColumnE);
    462. tmp_j = tmp_j + (1);
    463. }
    464. tmp_X = tmp_X + (1);
    465. tmp_i = tmp_i + (1);
    466. }
    467. }
    468. void cx_dianzhenzifuxianshiqi_driver_SetEnglishFont( t_#.点阵字符显示器.driver.icon *tmp_icon )
    469. {
    470. (*cx_dianzhenzifuxianshiqi_driver_EnglishFont) = &((*tmp_icon));
    471. }
    472. void cx_dianzhenzifuxianshiqi_driver_SetChinesFont( t_#.点阵字符显示器.driver.icon *tmp_icon )
    473. {
    474. (*cx_dianzhenzifuxianshiqi_driver_ChineseFont) = &((*tmp_icon));
    475. }
    476. void cx_dianzhenzifuxianshiqi_driver_SetEnglishFontDefault(void)
    477. {
    478. (*cx_dianzhenzifuxianshiqi_driver_EnglishFont) = &(cx_dianzhenzifuxianshiqi_driver_font);
    479. }
    480. void cx_yuyinlangduqi_driver_OS_init(void)
    481. {
    482. cx_kongzhiqi1_driver_RES_DDRB |= 32;
    483. cx_kongzhiqi1_driver_RES_PORTB |= 32;
    484. cx_yuyinlangduqi_driver_set_baud( 9600 );
    485. }
    486. void cx_yuyinlangduqi_driver_set_baud( t_int32 tmp_b )
    487. {
    488. cx_yuyinlangduqi_driver_BitTick = (t_uint16)(t_int16)(16000000 / tmp_b / 24);
    489. cx_yuyinlangduqi_driver_BitTick_C = cx_yuyinlangduqi_driver_BitTick - 3;
    490. cx_yuyinlangduqi_driver_BitTick_D32 = cx_yuyinlangduqi_driver_BitTick * 3 / 2;
    491. }
    492. void cx_yuyinlangduqi_driver_print_string( t_int8 tmp_s[] )
    493. {
    494. t_uint16 tmp_i = 0;
    495. while( tmp_s[tmp_i] != 0 ) {
    496. tmp_i = tmp_i + (1);
    497. }
    498. t_uint8 tmp_CSUM = 0;
    499. cx_yuyinlangduqi_driver_print_char( 253 );
    500. tmp_CSUM = tmp_CSUM ^ (253);
    501. cx_yuyinlangduqi_driver_print_char( 0 );
    502. tmp_CSUM = tmp_CSUM ^ (0);
    503. cx_yuyinlangduqi_driver_print_char( (t_int16)tmp_i + 3 );
    504. tmp_CSUM = tmp_CSUM ^ ((((tmp_i >> 0) & 255) + 3));
    505. cx_yuyinlangduqi_driver_print_char( 1 );
    506. tmp_CSUM = tmp_CSUM ^ (1);
    507. cx_yuyinlangduqi_driver_print_char( 0 );
    508. tmp_CSUM = tmp_CSUM ^ (0);
    509. tmp_i = 0;
    510. while( tmp_s[tmp_i] != 0 ) {
    511. cx_yuyinlangduqi_driver_print_char( tmp_s[tmp_i] );
    512. tmp_CSUM = tmp_CSUM ^ ((t_uint8)tmp_s[tmp_i]);
    513. tmp_i = tmp_i + (1);
    514. }
    515. t_uint32 tmp_d = tmp_CSUM;
    516. cx_yuyinlangduqi_driver_print_char( (t_int32)tmp_d );
    517. }
    518. void cx_yuyinlangduqi_driver_print_number( t_int32 tmp_data0 )
    519. {
    520. t_bool tmp_isNeg;
    521. t_uint32 tmp_data;
    522. if( tmp_data0 >= 0 ) {
    523. tmp_data = (t_uint32)tmp_data0;
    524. tmp_isNeg = 0;
    525. }
    526. else {
    527. tmp_data = (t_uint32)-tmp_data0;
    528. tmp_isNeg = 1;
    529. }
    530. t_int16 tmp_i = 0;
    531. while( true ) {
    532. t_int8 tmp_ch = 48 + (t_int8)(t_uint8)(t_uint16)(tmp_data % 10);
    533. cx_yuyinlangduqi_driver_number_buffer[tmp_i] = tmp_ch;
    534. tmp_i = tmp_i + (1);
    535. tmp_data = tmp_data / (10);
    536. if( tmp_data == 0 ) {
    537. if( tmp_isNeg ) {
    538. cx_yuyinlangduqi_driver_number_buffer[tmp_i] = 45;
    539. tmp_i = tmp_i + (1);
    540. }
    541. break;
    542. }
    543. }
    544. do {
    545. tmp_i = tmp_i - (1);
    546. cx_yuyinlangduqi_driver_print_char( cx_yuyinlangduqi_driver_number_buffer[tmp_i] );
    547. }
    548. while( tmp_i != 0 );
    549. }
    550. void cx_yuyinlangduqi_driver_print_char( t_int32 tmp_d )
    551. {
    552. t_uint8 tmp_data = (t_uint8)(t_int8)(t_int16)tmp_d;
    553. cx_kongzhiqi1_driver_RES_PORTB &= 223;
    554. t_uint16 _cx_lc_1 = cx_yuyinlangduqi_driver_BitTick;
    555. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    556. }
    557. t_uint16 _cx_lc_3 = 8;
    558. for( t_uint16 _cx_lc_2 = 0; _cx_lc_2 < _cx_lc_3; _cx_lc_2++ ) {
    559. (((tmp_data >> 0) & 1)) != 0 ? (cx_kongzhiqi1_driver_RES_PORTB |= 32): (cx_kongzhiqi1_driver_RES_PORTB &= 223);
    560. tmp_data = tmp_data >> (1);
    561. t_uint16 _cx_lc_5 = cx_yuyinlangduqi_driver_BitTick_C;
    562. for( t_uint16 _cx_lc_4 = 0; _cx_lc_4 < _cx_lc_5; _cx_lc_4++ ) {
    563. }
    564. }
    565. cx_kongzhiqi1_driver_RES_PORTB |= 32;
    566. t_uint16 _cx_lc_7 = cx_yuyinlangduqi_driver_BitTick;
    567. for( t_uint16 _cx_lc_6 = 0; _cx_lc_6 < _cx_lc_7; _cx_lc_6++ ) {
    568. }
    569. t_uint16 _cx_lc_9 = 500;
    570. for( t_uint16 _cx_lc_8 = 0; _cx_lc_8 < _cx_lc_9; _cx_lc_8++ ) {
    571. }
    572. }
    573. t_int32 cx_yuyinlangduqi_driver_get_byte(void)
    574. {
    575. t_uint8 tmp_data;
    576. while( cx_yuyinlangduqi_driver_TX_IN == 1 ) {
    577. }
    578. t_uint16 _cx_lc_1 = cx_yuyinlangduqi_driver_BitTick_D32;
    579. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    580. }
    581. t_uint16 _cx_lc_3 = 8;
    582. for( t_uint16 _cx_lc_2 = 0; _cx_lc_2 < _cx_lc_3; _cx_lc_2++ ) {
    583. tmp_data = tmp_data >> (1);
    584. (cx_yuyinlangduqi_driver_TX_IN) != 0 ? (tmp_data |= 128): (tmp_data &= 127);
    585. t_uint16 _cx_lc_5 = cx_yuyinlangduqi_driver_BitTick_C;
    586. for( t_uint16 _cx_lc_4 = 0; _cx_lc_4 < _cx_lc_5; _cx_lc_4++ ) {
    587. }
    588. }
    589. t_uint16 _cx_lc_7 = cx_yuyinlangduqi_driver_BitTick;
    590. for( t_uint16 _cx_lc_6 = 0; _cx_lc_6 < _cx_lc_7; _cx_lc_6++ ) {
    591. }
    592. t_uint32 tmp_d = tmp_data;
    593. return (t_int32)tmp_d;
    594. }
    595. void cx_SYS_Servo_OS_init(void)
    596. {
    597. cx_kongzhiqi1_driver_RES_TCCR2A = 0;
    598. cx_kongzhiqi1_driver_RES_TCCR2B = 9;
    599. t_uint32 tmp_f = 16000000;
    600. cx_kongzhiqi1_driver_RES_OCR2A = (t_uint8)(t_uint16)(tmp_f / 100000);
    601. cx_kongzhiqi1_driver_RES_TIMSK2 = 2;
    602. cx_SYS_Servo_n = 0;
    603. cx_SYS_Servo_tick = 0;
    604. cx_SYS_Servo_out_put = 1;
    605. cx_SYS_Servo_PWM_A = 60;
    606. cx_SYS_Servo_TickNumber = 250;
    607. }
    608. void cx_SYS_Servo_SetValue( t_int32 tmp_d )
    609. {
    610. cx_SYS_Servo_PWM[0] = (t_uint8)(t_uint16)(t_uint32)tmp_d;
    611. }
    612. void cx_SYS_Servo_timer2_compA(void)
    613. {
    614. }
    615. void cx_SYS_Servo_Clear(void)
    616. {
    617. cx_kongzhiqi1_driver_RES_PORTB &= 247;
    618. cx_kongzhiqi1_driver_RES_PORTD &= 239;
    619. cx_kongzhiqi1_driver_RES_PORTB &= 254;
    620. cx_kongzhiqi1_driver_RES_PORTB &= 239;
    621. cx_kongzhiqi1_driver_RES_PORTD &= 127;
    622. }
    623. void cx_SYS_Servo_SetPin(void)
    624. {
    625. cx_kongzhiqi1_driver_RES_PORTB |= 8;
    626. cx_kongzhiqi1_driver_RES_PORTB &= 247;
    627. cx_kongzhiqi1_driver_RES_PORTD |= 16;
    628. cx_kongzhiqi1_driver_RES_PORTD &= 239;
    629. cx_kongzhiqi1_driver_RES_PORTB |= 1;
    630. cx_kongzhiqi1_driver_RES_PORTB &= 254;
    631. cx_kongzhiqi1_driver_RES_PORTB |= 16;
    632. cx_kongzhiqi1_driver_RES_PORTB &= 239;
    633. cx_kongzhiqi1_driver_RES_PORTD |= 128;
    634. cx_kongzhiqi1_driver_RES_PORTD &= 127;
    635. }
    636. void cx_OS0_REMO_ModuleWrite( t_int32 tmp_d, t_int32 tmp_d1 )
    637. {
    638. }
    639. t_int32 cx_OS0_REMO_ModuleRead( t_int32 tmp_d )
    640. {
    641. return 0;
    642. }
    643. void cx_OS0_Delayer_Init(void)
    644. {
    645. cx_OS0_EnableSchedule = 1;
    646. cx_OS0_Delayer_Pause = 0;
    647. }
    648. void cx_OS0_Delayer_Run(void)
    649. {
    650. if( cx_OS0_Delayer_Pause ) {
    651. return;
    652. }
    653. for( t_uint8 tmp_i = 0; tmp_i < 12; ) {
    654. if( cx_OS0_enable_list[tmp_i] ) {
    655. cx_OS0_time_list[tmp_i] = cx_OS0_time_list[tmp_i] - (cx_SYS_Tick);
    656. if( cx_OS0_time_list[tmp_i] <= 0 ) {
    657. cx_OS0_enable_list[tmp_i] = 0;
    658. }
    659. }
    660. tmp_i = tmp_i + (1);
    661. }
    662. }
    663. t_bool cx_OS0_Delayer_Running(void)
    664. {
    665. return cx_OS0_enable_list[cx_OS0_CurrentTaskIndex];
    666. }
    667. void cx_OS0_Delayer_Stop( t_uint16 tmp_cid )
    668. {
    669. for( t_uint8 tmp_i = 0; tmp_i < 12; ) {
    670. if( cx_OS0_ID_list[tmp_i] == tmp_cid ) {
    671. cx_OS0_time_list[tmp_i] = 0;
    672. cx_OS0_enable_list[tmp_i] = 0;
    673. }
    674. tmp_i = tmp_i + (1);
    675. }
    676. }
    677. void cx_OS0_Delayer_StopAll(void)
    678. {
    679. for( t_uint8 tmp_i = 0; tmp_i < 12; ) {
    680. cx_OS0_time_list[tmp_i] = 0;
    681. cx_OS0_enable_list[tmp_i] = 0;
    682. tmp_i = tmp_i + (1);
    683. }
    684. }
    685. void cx_OS0_Delayer_Wait( t_int32 tmp_t )
    686. {
    687. cx_OS0_ID_list[cx_OS0_CurrentTaskIndex] = cx_OS0_Delayer_tempID;
    688. cx_OS0_time_list[cx_OS0_CurrentTaskIndex] = tmp_t;
    689. cx_OS0_enable_list[cx_OS0_CurrentTaskIndex] = 1;
    690. }
    691. t_int32 cx_OS0_GetSysTick(void)
    692. {
    693. return (t_int32)(cx_OS0_SysTick & 2147483647);
    694. }
    695. t_uint32 cx_OS0_GetSysTickU(void)
    696. {
    697. return cx_OS0_SysTick;
    698. }
    699. void cx_OS0_OS_init(void)
    700. {
    701. cx_OS0_CloseWatchdog();
    702. cx_OS0_TimerInit();
    703. cx_OS0_DriverInit();
    704. cx_OS0_Delayer_Init();
    705. cx_OS0_tick = 0;
    706. cx_OS0_CurrentTaskIndex = 0;
    707. }
    708. void cx_OS0_CloseWatchdog(void)
    709. {
    710. }
    711. void cx_OS0_MACRO_TIMER_ON(void)
    712. {
    713. }
    714. void cx_OS0_MACRO_TIMER_OFF(void)
    715. {
    716. }
    717. void cx_OS0_TimerInit(void)
    718. {
    719. }
    720. void cx_OS0_OS_run(void)
    721. {
    722. cx_OS0_MACRO_TIMER_OFF();
    723. cx_OS0_RunDriver100usList();
    724. cx_OS0_tick = cx_OS0_tick + (1);
    725. if( cx_OS0_tick >= 10 ) {
    726. cx_OS0_RunDriverList();
    727. cx_OS0_tick = 0;
    728. cx_OS0_DebugTick = cx_OS0_DebugTick + (1);
    729. cx_OS0_SysTick = cx_OS0_SysTick + (1);
    730. }
    731. cx_OS0_MACRO_TIMER_ON();
    732. }
    733. void cx_OS0_DriverInit(void)
    734. {
    735. cx_OS0_DriverNumber = 0;
    736. for( t_uint8 tmp_i = 0; tmp_i < 8; ) {
    737. cx_OS0_TickList[tmp_i] = 0;
    738. cx_OS0_MaxTickList[tmp_i] = 0;
    739. cx_OS0_DriverHandleList[tmp_i] = 0;
    740. tmp_i = tmp_i + (1);
    741. }
    742. cx_OS0_Driver100usNumber = 0;
    743. }
    744. void cx_OS0_CreateDriver( void (*tmp_Handle)(void), t_uint8 tmp_MaxTick )
    745. {
    746. cx_OS0_DriverHandleList[cx_OS0_DriverNumber] = tmp_Handle;
    747. cx_OS0_MaxTickList[cx_OS0_DriverNumber] = tmp_MaxTick;
    748. cx_OS0_DriverNumber = cx_OS0_DriverNumber + (1);
    749. }
    750. void cx_OS0_CreateDriver100us( void (*tmp_Handle)(void) )
    751. {
    752. cx_OS0_Driver100usHandleList[cx_OS0_Driver100usNumber] = tmp_Handle;
    753. cx_OS0_Driver100usNumber = cx_OS0_Driver100usNumber + (1);
    754. }
    755. void cx_OS0_RunDriverList(void)
    756. {
    757. for( t_uint8 tmp_i = 0; tmp_i < cx_OS0_DriverNumber; ) {
    758. cx_OS0_TickList[tmp_i] = cx_OS0_TickList[tmp_i] + (1);
    759. if( cx_OS0_TickList[tmp_i] == cx_OS0_MaxTickList[tmp_i] ) {
    760. cx_OS0_TickList[tmp_i] = 0;
    761. cx_OS0_D_CALL( cx_OS0_DriverHandleList[tmp_i] );
    762. }
    763. tmp_i = tmp_i + (1);
    764. }
    765. cx_OS0_Delayer_Run();
    766. }
    767. void cx_OS0_RunDriver100usList(void)
    768. {
    769. for( t_uint8 tmp_i = 0; tmp_i < cx_OS0_Driver100usNumber; ) {
    770. cx_OS0_D_CALL( cx_OS0_Driver100usHandleList[tmp_i] );
    771. tmp_i = tmp_i + (1);
    772. }
    773. }
    774. void cx_OS0_D_CALL( void (*tmp_Handle)(void) )
    775. {
    776. cx_OS0_s_Handle = tmp_Handle;
    777. (*cx_OS0_s_Handle)();
    778. }
    779. void cx_OS0_Start(void)
    780. {
    781. cx_OS0_MACRO_TIMER_ON();
    782. }
    783. void cx_sys_delayer_delay_n_10us( t_uint8 tmp_t )
    784. {
    785. t_uint16 _cx_lc_1 = tmp_t;
    786. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    787. cx_sys_delayer_delay_n_1us( 10 );
    788. }
    789. }
    790. void cx_sys_delayer_delay_n_1us( t_uint8 tmp_t )
    791. {
    792. delayMicroseconds( tmp_t );
    793. }
    794. void cx_sys_delayer_delay_ms( t_int32 tmp_t )
    795. {
    796. t_uint16 _cx_lc_1 = tmp_t;
    797. for( t_uint16 _cx_lc_0 = 0; _cx_lc_0 < _cx_lc_1; _cx_lc_0++ ) {
    798. cx_sys_delayer_delay_n_10us( 100 );
    799. }
    800. }
    801. void cx_Sim_onInitDefault(void)
    802. {
    803. }
    804. void cx_Sim_onDrawDefault(void)
    805. {
    806. }
    807. void cx_Sim_onKeyEventDefault( t_bool tmp_down, t_int32 tmp_key )
    808. {
    809. }
    810. t_int32 cx_Sim_crux_AddVar( t_int32 tmp_v )
    811. {
    812. return 0;
    813. }
    814. t_int32 cx_Sim_crux_Run( t_int32 tmp_v )
    815. {
    816. return 0;
    817. }
    818. void cx_Sim_OS_init(void)
    819. {
    820. cx_Sim_onInitDefault();
    821. }
    822. void cx_Sim_OS_thread(void)
    823. {
    824. t_int32 tmp_d = cx_Sim_crux_Run( 0 );
    825. if( tmp_d != 0 ) {
    826. t_int32 tmp_type = tmp_d / 1000;
    827. tmp_d = tmp_d % 1000;
    828. if( tmp_type == 1 ) {
    829. cx_Sim_onKeyEventDefault( 1, tmp_d );
    830. }
    831. if( tmp_type == 2 ) {
    832. cx_Sim_onKeyEventDefault( 0, tmp_d );
    833. }
    834. }
    835. cx_Sim_Clear();
    836. cx_Sim_onDrawDefault();
    837. }
    838. void cx_Sim_Clear(void)
    839. {
    840. t_int32 tmp_d = cx_Sim_crux_Run( 10 );
    841. }
    842. void cx_Sim_DrawCircle( t_int32 tmp_x, t_int32 tmp_y, t_int32 tmp_r )
    843. {
    844. t_int32 tmp_d;
    845. tmp_d = cx_Sim_crux_AddVar( tmp_x );
    846. tmp_d = cx_Sim_crux_AddVar( tmp_y );
    847. tmp_d = cx_Sim_crux_AddVar( tmp_r );
    848. tmp_d = cx_Sim_crux_Run( 11 );
    849. }
    850. void cx_Sim_FillCircle( t_int32 tmp_x, t_int32 tmp_y, t_int32 tmp_r )
    851. {
    852. t_int32 tmp_d;
    853. tmp_d = cx_Sim_crux_AddVar( tmp_x );
    854. tmp_d = cx_Sim_crux_AddVar( tmp_y );
    855. tmp_d = cx_Sim_crux_AddVar( tmp_r );
    856. tmp_d = cx_Sim_crux_Run( 12 );
    857. }
    858. void cx_main0(void)
    859. {
    860. cx_Setup();
    861. while( 1 ) {
    862. cx_Loop();
    863. }
    864. }
    865. void cx_Setup(void)
    866. {
    867. cx_OS_VarInit();
    868. cx_OS0_OS_init();
    869. cx_kongzhiqi1_driver_OS_init();
    870. cx_youqian_driver_OS_init();
    871. cx_youhou_driver_OS_init();
    872. cx_zuohou_driver_OS_init();
    873. cx_zuoqian_driver_OS_init();
    874. cx_madaqudongqi_driver_OS_init();
    875. cx_youludai_driver_OS_init();
    876. cx_zuoludai_driver_OS_init();
    877. cx_chaoshengbocejuqi_driver_OS_init();
    878. cx_huoyanchuanganqi_driver_OS_init();
    879. cx_wenshiduchuanganqi_driver_OS_init();
    880. cx_yanshiqi_driver_OS_init();
    881. cx_yanwuchuanganqi_driver_OS_init();
    882. cx_pingmu1_driver_OS_init();
    883. cx_chaoshengduoji_driver_OS_init();
    884. cx_xinxixianshiqi_driver_OS_init();
    885. cx_dianzhenzifuxianshiqi_driver_OS_init();
    886. cx_yuyinlangduqi_driver_OS_init();
    887. cx_OS0_CreateDriver( &cx_youqian_driver_OS_run, cx_youqian_driver_OS_time );
    888. cx_OS0_CreateDriver( &cx_kongzhiqi1_driver_OS_run, cx_kongzhiqi1_driver_OS_time );
    889. cx_OS0_CreateDriver( &cx_youhou_driver_OS_run, cx_youhou_driver_OS_time );
    890. cx_OS0_CreateDriver( &cx_zuohou_driver_OS_run, cx_zuohou_driver_OS_time );
    891. cx_OS0_CreateDriver( &cx_zuoqian_driver_OS_run, cx_zuoqian_driver_OS_time );
    892. cx_OS0_CreateDriver100us( &cx_madaqudongqi_driver_OS_run100us );
    893. cx_OS0_CreateDriver( &cx_huoyanchuanganqi_driver_OS_run, cx_huoyanchuanganqi_driver_OS_time );
    894. cx_OS0_CreateDriver( &cx_wenshiduchuanganqi_driver_OS_run,
    895. cx_wenshiduchuanganqi_driver_OS_time );
    896. cx_OS0_CreateDriver( &cx_chaoshengduoji_driver_OS_run, cx_chaoshengduoji_driver_OS_time );
    897. cx_SYS_Servo_OS_init();
    898. cx_OS0_Start();
    899. }
    900. void cx_Loop(void)
    901. {
    902. if( ((cx_kongzhiqi1_driver_OS_EventFlag >> 0) & 1) == 1 ) {
    903. cx_kongzhiqi1_driver_OS_EventFlag &= 254;
    904. if( cx_kongzhiqi1_chushihua_en_ && cx_kongzhiqi1_chushihua_flg_ == 0 ) {
    905. cx_kongzhiqi1_chushihua_flg_ = 1;
    906. cx_kongzhiqi1_chushihua();
    907. }
    908. }
    909. if( ((cx_kongzhiqi1_driver_OS_EventFlag >> 1) & 1) == 1 ) {
    910. cx_kongzhiqi1_driver_OS_EventFlag &= 253;
    911. if( cx_kongzhiqi1_fanfuzhixing_en_ && cx_kongzhiqi1_fanfuzhixing_flg_ == 0 ) {
    912. cx_kongzhiqi1_fanfuzhixing_flg_ = 1;
    913. cx_kongzhiqi1_fanfuzhixing();
    914. }
    915. }
    916. if( ((cx_huoyanchuanganqi_driver_OS_EventFlag >> 0) & 1) == 1 ) {
    917. cx_huoyanchuanganqi_driver_OS_EventFlag &= 254;
    918. if( cx_huoyanchuanganqi_tancedaohuoyanshi_en_ && cx_huoyanchuanganqi_tancedaohuoyanshi_flg_ == 0 ) {
    919. cx_huoyanchuanganqi_tancedaohuoyanshi_flg_ = 1;
    920. cx_huoyanchuanganqi_tancedaohuoyanshi();
    921. }
    922. }
    923. cx_kongzhiqi1_driver_OS_thread();
    924. cx_yanshiqi_driver_OS_thread();
    925. cx_pingmu1_driver_OS_thread();
    926. if( cx_xiaocheqianjin_flg_ != 0 ) {
    927. cx_xiaocheqianjin();
    928. }
    929. if( cx_xiaochetingzhi_flg_ != 0 ) {
    930. cx_xiaochetingzhi();
    931. }
    932. if( cx_xiaochezuozhuan_flg_ != 0 ) {
    933. cx_xiaochezuozhuan();
    934. }
    935. if( cx_xiaocheyouzhuan_flg_ != 0 ) {
    936. cx_xiaocheyouzhuan();
    937. }
    938. if( cx_xiaochedaoche_flg_ != 0 ) {
    939. cx_xiaochedaoche();
    940. }
    941. if( cx_xiaochexingtai_flg_ != 0 ) {
    942. cx_xiaochexingtai();
    943. }
    944. if( cx_kongzhiqi1_fanfuzhixing_flg_ != 0 ) {
    945. cx_kongzhiqi1_fanfuzhixing();
    946. }
    947. if( cx_sizuxingtai_flg_ != 0 ) {
    948. cx_sizuxingtai();
    949. }
    950. if( cx_xingzou_flg_ != 0 ) {
    951. cx_xingzou();
    952. }
    953. if( cx_huoyanchuanganqi_tancedaohuoyanshi_flg_ != 0 ) {
    954. cx_huoyanchuanganqi_tancedaohuoyanshi();
    955. }
    956. if( cx_kongzhiqi1_chushihua_flg_ != 0 ) {
    957. cx_kongzhiqi1_chushihua();
    958. }
    959. if( cx_pingmu_flg_ != 0 ) {
    960. cx_pingmu();
    961. }
    962. cx_SYS_Loop = 1;
    963. }
    964. void cx_xiaocheqianjin(void)
    965. {
    966. goto cx_xiaocheqianjin_end;
    967. cx_xiaocheqianjin_1:;
    968. cx_youludai_driver_run_right();
    969. cx_youludai_driver_set_power( (40) );
    970. cx_zuoludai_driver_run_right();
    971. cx_zuoludai_driver_set_power( (35) );
    972. cx_xiaocheqianjin_flg_ = 0;
    973. return;
    974. cx_xiaocheqianjin_end:;
    975. if( cx_xiaocheqianjin_flg_ == 1 ) {
    976. goto cx_xiaocheqianjin_1;
    977. }
    978. }
    979. void cx_xiaochetingzhi(void)
    980. {
    981. goto cx_xiaochetingzhi_end;
    982. cx_xiaochetingzhi_1:;
    983. cx_youludai_driver_stop();
    984. cx_zuoludai_driver_stop();
    985. cx_xiaochetingzhi_flg_ = 0;
    986. return;
    987. cx_xiaochetingzhi_end:;
    988. if( cx_xiaochetingzhi_flg_ == 1 ) {
    989. goto cx_xiaochetingzhi_1;
    990. }
    991. }
    992. void cx_xiaochezuozhuan(void)
    993. {
    994. goto cx_xiaochezuozhuan_end;
    995. cx_xiaochezuozhuan_1:;
    996. cx_youludai_driver_run_right();
    997. cx_youludai_driver_set_power( (40) );
    998. cx_zuoludai_driver_run_left();
    999. cx_zuoludai_driver_set_power( (35) );
    1000. cx_xiaochezuozhuan_flg_ = 0;
    1001. return;
    1002. cx_xiaochezuozhuan_end:;
    1003. if( cx_xiaochezuozhuan_flg_ == 1 ) {
    1004. goto cx_xiaochezuozhuan_1;
    1005. }
    1006. }
    1007. void cx_xiaocheyouzhuan(void)
    1008. {
    1009. goto cx_xiaocheyouzhuan_end;
    1010. cx_xiaocheyouzhuan_1:;
    1011. cx_youludai_driver_run_left();
    1012. cx_youludai_driver_set_power( (40) );
    1013. cx_zuoludai_driver_run_right();
    1014. cx_zuoludai_driver_set_power( (35) );
    1015. cx_xiaocheyouzhuan_flg_ = 0;
    1016. return;
    1017. cx_xiaocheyouzhuan_end:;
    1018. if( cx_xiaocheyouzhuan_flg_ == 1 ) {
    1019. goto cx_xiaocheyouzhuan_1;
    1020. }
    1021. }
    1022. void cx_xiaochedaoche(void)
    1023. {
    1024. goto cx_xiaochedaoche_end;
    1025. cx_xiaochedaoche_1:;
    1026. cx_youludai_driver_run_left();
    1027. cx_youludai_driver_set_power( (40) );
    1028. cx_zuoludai_driver_run_left();
    1029. cx_zuoludai_driver_set_power( (35) );
    1030. cx_xiaochedaoche_flg_ = 0;
    1031. return;
    1032. cx_xiaochedaoche_end:;
    1033. if( cx_xiaochedaoche_flg_ == 1 ) {
    1034. goto cx_xiaochedaoche_1;
    1035. }
    1036. }
    1037. void cx_xiaochexingtai(void)
    1038. {
    1039. goto cx_xiaochexingtai_end;
    1040. cx_xiaochexingtai_1:;
    1041. (cx_youqian_driver_Angle) = (-180);
    1042. (cx_youhou_driver_Angle) = (120);
    1043. (cx_zuohou_driver_Angle) = (-130);
    1044. (cx_zuoqian_driver_Angle) = (45);
    1045. cx_xiaochexingtai_flg_ = 0;
    1046. return;
    1047. cx_xiaochexingtai_end:;
    1048. if( cx_xiaochexingtai_flg_ == 1 ) {
    1049. goto cx_xiaochexingtai_1;
    1050. }
    1051. }
    1052. void cx_kongzhiqi1_fanfuzhixing(void)
    1053. {
    1054. goto cx_kongzhiqi1_fanfuzhixing_end;
    1055. cx_kongzhiqi1_fanfuzhixing_1:;
    1056. if( (cx_chaoshengbocejuqi_driver_get_value()) <= (10) ) {
    1057. cx_kongzhiqi1_fanfuzhixing_flg_ = 2;
    1058. cx_xiaochexingtai_flg_ = 1;
    1059. cx_xiaochexingtai();
    1060. cx_kongzhiqi1_fanfuzhixing_2:;
    1061. cx_xiaochexingtai();
    1062. if( cx_xiaochexingtai_flg_ != 0 ) {
    1063. return;
    1064. }
    1065. cx_chaoshengduoji_driver_SetSpeed( (180) );
    1066. if( (cx_chaoshengbocejuqi_driver_get_value()) <= (10) ) {
    1067. cx_kongzhiqi1_fanfuzhixing_flg_ = 3;
    1068. cx_xiaochezuozhuan_flg_ = 1;
    1069. cx_xiaochezuozhuan();
    1070. cx_kongzhiqi1_fanfuzhixing_3:;
    1071. cx_xiaochezuozhuan();
    1072. if( cx_xiaochezuozhuan_flg_ != 0 ) {
    1073. return;
    1074. }
    1075. cx_OS0_CurrentTaskIndex = 6;
    1076. cx_yanshiqi_driver_DelaySecond( ((t_int32)((5)) << 10) );
    1077. cx_kongzhiqi1_fanfuzhixing_flg_ = 4;
    1078. cx_kongzhiqi1_fanfuzhixing_4:;
    1079. if( cx_OS0_enable_list[6] ) {
    1080. return;
    1081. }
    1082. cx_kongzhiqi1_fanfuzhixing_flg_ = 5;
    1083. cx_xiaocheyouzhuan_flg_ = 1;
    1084. cx_xiaocheyouzhuan();
    1085. cx_kongzhiqi1_fanfuzhixing_5:;
    1086. cx_xiaocheyouzhuan();
    1087. if( cx_xiaocheyouzhuan_flg_ != 0 ) {
    1088. return;
    1089. }
    1090. cx_OS0_CurrentTaskIndex = 6;
    1091. cx_yanshiqi_driver_DelaySecond( ((t_int32)((5)) << 10) );
    1092. cx_kongzhiqi1_fanfuzhixing_flg_ = 6;
    1093. cx_kongzhiqi1_fanfuzhixing_6:;
    1094. if( cx_OS0_enable_list[6] ) {
    1095. return;
    1096. }
    1097. cx_kongzhiqi1_fanfuzhixing_flg_ = 7;
    1098. cx_xiaocheqianjin_flg_ = 1;
    1099. cx_xiaocheqianjin();
    1100. cx_kongzhiqi1_fanfuzhixing_7:;
    1101. cx_xiaocheqianjin();
    1102. if( cx_xiaocheqianjin_flg_ != 0 ) {
    1103. return;
    1104. }
    1105. cx_OS0_CurrentTaskIndex = 6;
    1106. cx_yanshiqi_driver_DelaySecond( ((t_int32)((10)) << 10) );
    1107. cx_kongzhiqi1_fanfuzhixing_flg_ = 8;
    1108. cx_kongzhiqi1_fanfuzhixing_8:;
    1109. if( cx_OS0_enable_list[6] ) {
    1110. return;
    1111. }
    1112. }
    1113. else {
    1114. cx_kongzhiqi1_fanfuzhixing_flg_ = 9;
    1115. cx_xiaocheyouzhuan_flg_ = 1;
    1116. cx_xiaocheyouzhuan();
    1117. cx_kongzhiqi1_fanfuzhixing_9:;
    1118. cx_xiaocheyouzhuan();
    1119. if( cx_xiaocheyouzhuan_flg_ != 0 ) {
    1120. return;
    1121. }
    1122. cx_OS0_CurrentTaskIndex = 6;
    1123. cx_yanshiqi_driver_DelaySecond( ((t_int32)((5)) << 10) );
    1124. cx_kongzhiqi1_fanfuzhixing_flg_ = 10;
    1125. cx_kongzhiqi1_fanfuzhixing_10:;
    1126. if( cx_OS0_enable_list[6] ) {
    1127. return;
    1128. }
    1129. cx_kongzhiqi1_fanfuzhixing_flg_ = 11;
    1130. cx_xiaochezuozhuan_flg_ = 1;
    1131. cx_xiaochezuozhuan();
    1132. cx_kongzhiqi1_fanfuzhixing_11:;
    1133. cx_xiaochezuozhuan();
    1134. if( cx_xiaochezuozhuan_flg_ != 0 ) {
    1135. return;
    1136. }
    1137. cx_OS0_CurrentTaskIndex = 6;
    1138. cx_yanshiqi_driver_DelaySecond( ((t_int32)((5)) << 10) );
    1139. cx_kongzhiqi1_fanfuzhixing_flg_ = 12;
    1140. cx_kongzhiqi1_fanfuzhixing_12:;
    1141. if( cx_OS0_enable_list[6] ) {
    1142. return;
    1143. }
    1144. cx_kongzhiqi1_fanfuzhixing_flg_ = 13;
    1145. cx_xiaocheqianjin_flg_ = 1;
    1146. cx_xiaocheqianjin();
    1147. cx_kongzhiqi1_fanfuzhixing_13:;
    1148. cx_xiaocheqianjin();
    1149. if( cx_xiaocheqianjin_flg_ != 0 ) {
    1150. return;
    1151. }
    1152. cx_OS0_CurrentTaskIndex = 6;
    1153. cx_yanshiqi_driver_DelaySecond( ((t_int32)((10)) << 10) );
    1154. cx_kongzhiqi1_fanfuzhixing_flg_ = 14;
    1155. cx_kongzhiqi1_fanfuzhixing_14:;
    1156. if( cx_OS0_enable_list[6] ) {
    1157. return;
    1158. }
    1159. }
    1160. }
    1161. else {
    1162. cx_kongzhiqi1_fanfuzhixing_flg_ = 15;
    1163. cx_xiaochetingzhi_flg_ = 1;
    1164. cx_xiaochetingzhi();
    1165. cx_kongzhiqi1_fanfuzhixing_15:;
    1166. cx_xiaochetingzhi();
    1167. if( cx_xiaochetingzhi_flg_ != 0 ) {
    1168. return;
    1169. }
    1170. cx_kongzhiqi1_fanfuzhixing_flg_ = 16;
    1171. cx_xingzou_flg_ = 1;
    1172. cx_xingzou();
    1173. cx_kongzhiqi1_fanfuzhixing_16:;
    1174. cx_xingzou();
    1175. if( cx_xingzou_flg_ != 0 ) {
    1176. return;
    1177. }
    1178. }
    1179. cx_kongzhiqi1_fanfuzhixing_flg_ = 0;
    1180. return;
    1181. cx_kongzhiqi1_fanfuzhixing_end:;
    1182. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 1 ) {
    1183. goto cx_kongzhiqi1_fanfuzhixing_1;
    1184. }
    1185. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 2 ) {
    1186. goto cx_kongzhiqi1_fanfuzhixing_2;
    1187. }
    1188. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 3 ) {
    1189. goto cx_kongzhiqi1_fanfuzhixing_3;
    1190. }
    1191. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 4 ) {
    1192. goto cx_kongzhiqi1_fanfuzhixing_4;
    1193. }
    1194. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 5 ) {
    1195. goto cx_kongzhiqi1_fanfuzhixing_5;
    1196. }
    1197. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 6 ) {
    1198. goto cx_kongzhiqi1_fanfuzhixing_6;
    1199. }
    1200. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 7 ) {
    1201. goto cx_kongzhiqi1_fanfuzhixing_7;
    1202. }
    1203. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 8 ) {
    1204. goto cx_kongzhiqi1_fanfuzhixing_8;
    1205. }
    1206. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 9 ) {
    1207. goto cx_kongzhiqi1_fanfuzhixing_9;
    1208. }
    1209. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 10 ) {
    1210. goto cx_kongzhiqi1_fanfuzhixing_10;
    1211. }
    1212. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 11 ) {
    1213. goto cx_kongzhiqi1_fanfuzhixing_11;
    1214. }
    1215. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 12 ) {
    1216. goto cx_kongzhiqi1_fanfuzhixing_12;
    1217. }
    1218. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 13 ) {
    1219. goto cx_kongzhiqi1_fanfuzhixing_13;
    1220. }
    1221. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 14 ) {
    1222. goto cx_kongzhiqi1_fanfuzhixing_14;
    1223. }
    1224. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 15 ) {
    1225. goto cx_kongzhiqi1_fanfuzhixing_15;
    1226. }
    1227. if( cx_kongzhiqi1_fanfuzhixing_flg_ == 16 ) {
    1228. goto cx_kongzhiqi1_fanfuzhixing_16;
    1229. }
    1230. }
    1231. void cx_sizuxingtai(void)
    1232. {
    1233. goto cx_sizuxingtai_end;
    1234. cx_sizuxingtai_1:;
    1235. (cx_youqian_driver_Angle) = (20);
    1236. (cx_youhou_driver_Angle) = (-100);
    1237. (cx_zuohou_driver_Angle) = (110);
    1238. (cx_zuoqian_driver_Angle) = (-103);
    1239. cx_sizuxingtai_flg_ = 0;
    1240. return;
    1241. cx_sizuxingtai_end:;
    1242. if( cx_sizuxingtai_flg_ == 1 ) {
    1243. goto cx_sizuxingtai_1;
    1244. }
    1245. }
    1246. void cx_xingzou(void)
    1247. {
    1248. goto cx_xingzou_end;
    1249. cx_xingzou_1:;
    1250. (cx_youqian_driver_Angle) = (10);
    1251. (cx_zuohou_driver_Angle) = (100);
    1252. cx_OS0_CurrentTaskIndex = 8;
    1253. cx_yanshiqi_driver_DelayMillisecond( (500) );
    1254. cx_xingzou_flg_ = 2;
    1255. cx_xingzou_2:;
    1256. if( cx_OS0_enable_list[8] ) {
    1257. return;
    1258. }
    1259. (cx_zuoqian_driver_Angle) = (-93);
    1260. (cx_youhou_driver_Angle) = (-90);
    1261. cx_OS0_CurrentTaskIndex = 8;
    1262. cx_yanshiqi_driver_DelayMillisecond( (500) );
    1263. cx_xingzou_flg_ = 3;
    1264. cx_xingzou_3:;
    1265. if( cx_OS0_enable_list[8] ) {
    1266. return;
    1267. }
    1268. (cx_youqian_driver_Angle) = (40);
    1269. (cx_zuohou_driver_Angle) = (130);
    1270. cx_OS0_CurrentTaskIndex = 8;
    1271. cx_yanshiqi_driver_DelayMillisecond( (500) );
    1272. cx_xingzou_flg_ = 4;
    1273. cx_xingzou_4:;
    1274. if( cx_OS0_enable_list[8] ) {
    1275. return;
    1276. }
    1277. (cx_zuoqian_driver_Angle) = (-123);
    1278. (cx_youhou_driver_Angle) = (-120);
    1279. cx_OS0_CurrentTaskIndex = 8;
    1280. cx_yanshiqi_driver_DelayMillisecond( (500) );
    1281. cx_xingzou_flg_ = 5;
    1282. cx_xingzou_5:;
    1283. if( cx_OS0_enable_list[8] ) {
    1284. return;
    1285. }
    1286. cx_xingzou_flg_ = 0;
    1287. return;
    1288. cx_xingzou_end:;
    1289. if( cx_xingzou_flg_ == 1 ) {
    1290. goto cx_xingzou_1;
    1291. }
    1292. if( cx_xingzou_flg_ == 2 ) {
    1293. goto cx_xingzou_2;
    1294. }
    1295. if( cx_xingzou_flg_ == 3 ) {
    1296. goto cx_xingzou_3;
    1297. }
    1298. if( cx_xingzou_flg_ == 4 ) {
    1299. goto cx_xingzou_4;
    1300. }
    1301. if( cx_xingzou_flg_ == 5 ) {
    1302. goto cx_xingzou_5;
    1303. }
    1304. }
    1305. void cx_huoyanchuanganqi_tancedaohuoyanshi(void)
    1306. {
    1307. goto cx_huoyanchuanganqi_tancedaohuoyanshi_end;
    1308. cx_huoyanchuanganqi_tancedaohuoyanshi_1:;
    1309. cx_yuyinlangduqi_driver_print_string( ((t_int8*)((t_uint32)""发现火情"" + 0x10000)) );
    1310. cx_huoyanchuanganqi_tancedaohuoyanshi_flg_ = 0;
    1311. return;
    1312. cx_huoyanchuanganqi_tancedaohuoyanshi_end:;
    1313. if( cx_huoyanchuanganqi_tancedaohuoyanshi_flg_ == 1 ) {
    1314. goto cx_huoyanchuanganqi_tancedaohuoyanshi_1;
    1315. }
    1316. }
    1317. void cx_kongzhiqi1_chushihua(void)
    1318. {
    1319. goto cx_kongzhiqi1_chushihua_end;
    1320. cx_kongzhiqi1_chushihua_1:;
    1321. cx_kongzhiqi1_chushihua_flg_ = 2;
    1322. cx_sizuxingtai_flg_ = 1;
    1323. cx_sizuxingtai();
    1324. cx_kongzhiqi1_chushihua_2:;
    1325. cx_sizuxingtai();
    1326. if( cx_sizuxingtai_flg_ != 0 ) {
    1327. return;
    1328. }
    1329. while( true ) {
    1330. cx_pingmu1_driver_Refresh();
    1331. cx_kongzhiqi1_chushihua_flg_ = 3;
    1332. cx_pingmu_flg_ = 1;
    1333. cx_pingmu();
    1334. cx_kongzhiqi1_chushihua_3:;
    1335. cx_pingmu();
    1336. if( cx_pingmu_flg_ != 0 ) {
    1337. return;
    1338. }
    1339. if( cx_huoyanchuanganqi_driver_key0_press ) {
    1340. }
    1341. if( (cx_yanwuchuanganqi_driver_get_data()) == (200) ) {
    1342. cx_yuyinlangduqi_driver_print_string( ((t_int8*)((t_uint32)"危害气体泄露" + 0x10000)) );
    1343. }
    1344. }
    1345. cx_kongzhiqi1_chushihua_flg_ = 0;
    1346. return;
    1347. cx_kongzhiqi1_chushihua_end:;
    1348. if( cx_kongzhiqi1_chushihua_flg_ == 1 ) {
    1349. goto cx_kongzhiqi1_chushihua_1;
    1350. }
    1351. if( cx_kongzhiqi1_chushihua_flg_ == 2 ) {
    1352. goto cx_kongzhiqi1_chushihua_2;
    1353. }
    1354. if( cx_kongzhiqi1_chushihua_flg_ == 3 ) {
    1355. goto cx_kongzhiqi1_chushihua_3;
    1356. }
    1357. }
    1358. void cx_pingmu(void)
    1359. {
    1360. goto cx_pingmu_end;
    1361. cx_pingmu_1:;
    1362. cx_xinxixianshiqi_driver_show_number_f( (1), (50), (cx_wenshiduchuanganqi_driver_wendu()) );
    1363. cx_xinxixianshiqi_driver_show_number_f( (30), (50), (cx_wenshiduchuanganqi_driver_shidu()) );
    1364. cx_xinxixianshiqi_driver_show_text_f( (1), (65), ((t_int8*)((t_uint32)"C" + 0x10000)) );
    1365. cx_xinxixianshiqi_driver_show_text_f( (30), (65), ((t_int8*)((t_uint32)"%" + 0x10000)) );
    1366. cx_pingmu_flg_ = 0;
    1367. return;
    1368. cx_pingmu_end:;
    1369. if( cx_pingmu_flg_ == 1 ) {
    1370. goto cx_pingmu_1;
    1371. }
    1372. }
    1373. void cx_OS_VarInit(void)
    1374. {
    1375. cx_xiaocheqianjin_flg_ = 0;
    1376. cx_xiaocheqianjin_en_ = 1;
    1377. cx_xiaochetingzhi_flg_ = 0;
    1378. cx_xiaochetingzhi_en_ = 1;
    1379. cx_xiaochezuozhuan_flg_ = 0;
    1380. cx_xiaochezuozhuan_en_ = 1;
    1381. cx_xiaocheyouzhuan_flg_ = 0;
    1382. cx_xiaocheyouzhuan_en_ = 1;
    1383. cx_xiaochedaoche_flg_ = 0;
    1384. cx_xiaochedaoche_en_ = 1;
    1385. cx_xiaochexingtai_flg_ = 0;
    1386. cx_xiaochexingtai_en_ = 1;
    1387. cx_kongzhiqi1_fanfuzhixing_flg_ = 0;
    1388. cx_kongzhiqi1_fanfuzhixing_en_ = 1;
    1389. cx_sizuxingtai_flg_ = 0;
    1390. cx_sizuxingtai_en_ = 1;
    1391. cx_xingzou_flg_ = 0;
    1392. cx_xingzou_en_ = 1;
    1393. cx_huoyanchuanganqi_tancedaohuoyanshi_flg_ = 0;
    1394. cx_huoyanchuanganqi_tancedaohuoyanshi_en_ = 1;
    1395. cx_kongzhiqi1_chushihua_flg_ = 0;
    1396. cx_kongzhiqi1_chushihua_en_ = 1;
    1397. cx_pingmu_flg_ = 0;
    1398. cx_pingmu_en_ = 1;
    1399. cx_SYS_Tick = 1;
    1400. cx_CInsIndex = 8192;
    1401. }
    1402. //=====================================================================
    1403. void setup(void) {
    1404. //这里添加用户的初始化, 如各个外设
    1405. //...
    1406. //初始化linkboy里的所有模块
    1407. cx_Setup();
    1408. }
    1409. void loop(void) {
    1410. //这里应保证调用频率为1000Hz
    1411. cx_OS0_RunDriverList();
    1412. cx_Loop();
    1413. delay( 1 );
    1414. }

  • 相关阅读:
    7/20 时事
    【Jfrog Artifactory】配置邮件服务器
    CSS超出两行隐藏
    关于==和equals的问题
    【华为机试真题 JAVA】寻找相同子串-100
    报考PMP怕上当,都会遇到哪些坑,我该如何避开这些坑?
    大学生个人博客网页设计模板 学生个人博客网页成品 简单个人网站作品下载 静态HTML CSS个人网页作业源代码
    UsernamePasswordAuthenticationFilter执行流程
    Bpmn在vue中不能使用require 进行导入图片,而是要使用new URL
    SOA面向服务的一些总结思考:服务、服务实例、ARXML、服务接口调用以及各参与方
  • 原文地址:https://blog.csdn.net/Robotway/article/details/134378533