/** ******************************************************************************* * * @file ipmb_requester.c * @authors fatih.bellachia@lapp.in2p3.fr * @date 12/04/2013 * @version v0r1 * @bref Simple Intelligent Plateform Management Bus requester * *------------------------------------------------------------------------------ * * @copyright Copyright © 2013, LAPP/CNRS * * @section LICENSE * * This software is governed by the CeCILL-C license under French law and * abiding by the rules of distribution of free software. You can use, * modify and/or redistribute the software under the terms of the CeCILL-C * license as circulated by CEA, CNRS and INRIA at the following URL * "http://www.cecill.info". * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the * software by the user in light of its specific status of free software, * that may mean that it is complicated to manipulate, and that also * therefore means that it is reserved for developers and experienced * professionals having in-depth computer knowledge. Users are therefore * encouraged to load and test the software's suitability as regards their * requirements in conditions enabling the security of their systems and/or * data to be ensured and, more generally, to use and operate it in the * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-C license and that you accept its terms. * ******************************************************************************* */ /* Includes ------------------------------------------------------------------*/ #include "test/template/common.c" /** @addtogroup Middleware * @{ */ /** @defgroup IPMB * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define OWN_ADDRESS 0x49 #define SLAVE_ADDRESS 0x10 #define IPMB_CC_NORMALLY 0x00 #define IPMB_REQ_NETFN_SE (0x04 << 2) #define IPMB_CMD_EVENT_MESSAGE 0x02 #define IPMB_REQUEST_LENGTH 0x6 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static unsigned char s_aucRequest[] = { (SLAVE_ADDRESS << 1), IPMB_REQ_NETFN_SE, 0, (OWN_ADDRESS << 1), IPMB_SEQ(0), IPMB_CMD_EVENT_MESSAGE, }; /* Private function prototypes -----------------------------------------------*/ /* Public variables ----------------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /* Public functions ----------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ void ReceiveCallback(void *pvParameter, void *pvBuffer, uint32_t uiLength) /*----------------------------------------------------------------------------*/ { //printf("Receive packet:\n"); if (pvBuffer != NULL) { //DumpPacket(pvBuffer, uiLength); LED_Toggle(LED_1); } else { printf("ERROR> receive buffer is NULL.\n"); } } /*----------------------------------------------------------------------------*/ void SendRequest(void *pvArg) /*----------------------------------------------------------------------------*/ { static uint8_t ucSeq = 0; ucSeq = (ucSeq + 1) % 64; s_aucRequest[4] = IPMB_SEQ(ucSeq); IPMB_SendMessage(IPMB_BUS, s_aucRequest, IPMB_REQUEST_LENGTH); LED_Toggle(LED_2); } /*----------------------------------------------------------------------------*/ int main(void) /*----------------------------------------------------------------------------*/ { RCC_Open(); USART_Init(); TaskQueueInit(); PrintBanner("REQUESTER"); IPMB_SetDebugLevel(1); IPMB_Init(IPMB_BUS, OWN_ADDRESS); IPMB_RegisterMsgCallback(IPMB_BUS, IPMB_RECEIVE_CALLBACK, ReceiveCallback, NULL); IPMB_RegisterMsgCallback(IPMB_BUS, IPMB_TIMEOUT_CALLBACK, TimeoutCallback, NULL); IPMB_RegisterErrorCallback(IPMB_BUS, ErrorCallback, NULL); TimerTaskCreate(SendRequest, NULL, 2000); TaskCreate(Dump, (void *)IPMB_BUS); IPMB_Enable(IPMB_BUS, IPMB_CHANNEL); IPMB_BufferEnable(IPMB_BUS, IPMB_CHANNEL, 1); /* do forever */ for (;;) { TaskQueueProcess(); } return 0; } /** * @} */ /** * @} */