#include "bsp_mx_lin.h"
#include "bsp_lin.h"
#include "bsp_airsac.h"
static lin_msg_struct g_lin_msg = {0}; 


uint8_t lin_set_airsac_stop(lin_msg_struct * p_lin_msg)
{
		airsac_stop();
		return 1;
}	

uint8_t lin_set_airsac_discharge(lin_msg_struct * p_lin_msg)
{
		if(p_lin_msg->datalen >= 2)
		{
				airsac_num airsac = (airsac_num)p_lin_msg->data[1];
				airsac_discharge(airsac);
				return 1;
		}
		return 0;
}

uint8_t lin_set_airsac_charge(lin_msg_struct * p_lin_msg)
{
		if(p_lin_msg->datalen >= 2)
		{
				airsac_num airsac = (airsac_num)p_lin_msg->data[1];
				airsac_charge(airsac);
				return 1;
		}
		return 0;
}

uint8_t lin_set_all_airsac_discharge(lin_msg_struct * p_lin_msg)
{
		all_airsac_discharge();
		return 1;
}

uint8_t lin_set_all_airsac_charge(lin_msg_struct * p_lin_msg)
{
		all_airsac_charge();
		return 1;
}

void mx_lin_handle(void)
{
	lin_msg_struct * p_lin_msg = &g_lin_msg;
	
	
	
		if(rx_ring_buffer_get_lin_msg(p_lin_msg))
		{
				if(p_lin_msg->frameid == 0x03)
				{
						switch(p_lin_msg->data[0])
						{
							case 0x10:	lin_set_airsac_stop(p_lin_msg);
								break;
							case 0x11:	lin_set_airsac_discharge(p_lin_msg);
								break;
							case 0x12:	lin_set_airsac_charge(p_lin_msg);
								break;
							case 0x13:	lin_set_all_airsac_discharge(p_lin_msg);
								break;
							case 0x14:	lin_set_all_airsac_charge(p_lin_msg);
								break;
							default:
								break;
						}	
				}
		}
}


