Control of mbed using OSC. Based on code from the Make Controller. Right now you can turn the onboard LEDs on/off and toggle 8 digital out pins. More I/O will be done in the future.

Dependencies:   mbed

Committer:
pehrhovey
Date:
Wed Mar 17 03:17:38 2010 +0000
Revision:
0:439354122597

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pehrhovey 0:439354122597 1 /*
pehrhovey 0:439354122597 2 * Copyright (c) 2002 CITEL Technologies Ltd.
pehrhovey 0:439354122597 3 * All rights reserved.
pehrhovey 0:439354122597 4 *
pehrhovey 0:439354122597 5 * Redistribution and use in source and binary forms, with or without
pehrhovey 0:439354122597 6 * modification, are permitted provided that the following conditions
pehrhovey 0:439354122597 7 * are met:
pehrhovey 0:439354122597 8 * 1. Redistributions of source code must retain the above copyright
pehrhovey 0:439354122597 9 * notice, this list of conditions and the following disclaimer.
pehrhovey 0:439354122597 10 * 2. Redistributions in binary form must reproduce the above copyright
pehrhovey 0:439354122597 11 * notice, this list of conditions and the following disclaimer in the
pehrhovey 0:439354122597 12 * documentation and/or other materials provided with the distribution.
pehrhovey 0:439354122597 13 * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
pehrhovey 0:439354122597 14 * may be used to endorse or promote products derived from this software
pehrhovey 0:439354122597 15 * without specific prior written permission.
pehrhovey 0:439354122597 16 *
pehrhovey 0:439354122597 17 * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
pehrhovey 0:439354122597 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
pehrhovey 0:439354122597 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
pehrhovey 0:439354122597 20 * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
pehrhovey 0:439354122597 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
pehrhovey 0:439354122597 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
pehrhovey 0:439354122597 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
pehrhovey 0:439354122597 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
pehrhovey 0:439354122597 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
pehrhovey 0:439354122597 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
pehrhovey 0:439354122597 27 * SUCH DAMAGE.
pehrhovey 0:439354122597 28 *
pehrhovey 0:439354122597 29 * This file is a contribution to the lwIP TCP/IP stack.
pehrhovey 0:439354122597 30 * The Swedish Institute of Computer Science and Adam Dunkels
pehrhovey 0:439354122597 31 * are specifically granted permission to redistribute this
pehrhovey 0:439354122597 32 * source code.
pehrhovey 0:439354122597 33 */
pehrhovey 0:439354122597 34
pehrhovey 0:439354122597 35 #ifndef __LWIP_IGMP_H__
pehrhovey 0:439354122597 36 #define __LWIP_IGMP_H__
pehrhovey 0:439354122597 37
pehrhovey 0:439354122597 38 #include "lwip/opt.h"
pehrhovey 0:439354122597 39 #include "lwip/ip_addr.h"
pehrhovey 0:439354122597 40 #include "lwip/netif.h"
pehrhovey 0:439354122597 41 #include "lwip/pbuf.h"
pehrhovey 0:439354122597 42
pehrhovey 0:439354122597 43 #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
pehrhovey 0:439354122597 44
pehrhovey 0:439354122597 45 #ifdef __cplusplus
pehrhovey 0:439354122597 46 extern "C" {
pehrhovey 0:439354122597 47 #endif
pehrhovey 0:439354122597 48
pehrhovey 0:439354122597 49 /*
pehrhovey 0:439354122597 50 * IGMP constants
pehrhovey 0:439354122597 51 */
pehrhovey 0:439354122597 52 #define IP_PROTO_IGMP 2
pehrhovey 0:439354122597 53 #define IGMP_TTL 1
pehrhovey 0:439354122597 54 #define IGMP_MINLEN 8
pehrhovey 0:439354122597 55 #define ROUTER_ALERT 0x9404
pehrhovey 0:439354122597 56 #define ROUTER_ALERTLEN 4
pehrhovey 0:439354122597 57
pehrhovey 0:439354122597 58 /*
pehrhovey 0:439354122597 59 * IGMP message types, including version number.
pehrhovey 0:439354122597 60 */
pehrhovey 0:439354122597 61 #define IGMP_MEMB_QUERY 0x11 /* Membership query */
pehrhovey 0:439354122597 62 #define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */
pehrhovey 0:439354122597 63 #define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */
pehrhovey 0:439354122597 64 #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
pehrhovey 0:439354122597 65
pehrhovey 0:439354122597 66 /* IGMP timer */
pehrhovey 0:439354122597 67 #define IGMP_TMR_INTERVAL 100 /* Milliseconds */
pehrhovey 0:439354122597 68 #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL)
pehrhovey 0:439354122597 69 #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
pehrhovey 0:439354122597 70
pehrhovey 0:439354122597 71 /* MAC Filter Actions */
pehrhovey 0:439354122597 72 #define IGMP_DEL_MAC_FILTER 0
pehrhovey 0:439354122597 73 #define IGMP_ADD_MAC_FILTER 1
pehrhovey 0:439354122597 74
pehrhovey 0:439354122597 75 /* Group membership states */
pehrhovey 0:439354122597 76 #define IGMP_GROUP_NON_MEMBER 0
pehrhovey 0:439354122597 77 #define IGMP_GROUP_DELAYING_MEMBER 1
pehrhovey 0:439354122597 78 #define IGMP_GROUP_IDLE_MEMBER 2
pehrhovey 0:439354122597 79
pehrhovey 0:439354122597 80 /*
pehrhovey 0:439354122597 81 * IGMP packet format.
pehrhovey 0:439354122597 82 */
pehrhovey 0:439354122597 83 #ifdef PACK_STRUCT_USE_INCLUDES
pehrhovey 0:439354122597 84 # include "arch/bpstruct.h"
pehrhovey 0:439354122597 85 #endif
pehrhovey 0:439354122597 86 PACK_STRUCT_BEGIN
pehrhovey 0:439354122597 87 struct igmp_msg {
pehrhovey 0:439354122597 88 PACK_STRUCT_FIELD(u8_t igmp_msgtype);
pehrhovey 0:439354122597 89 PACK_STRUCT_FIELD(u8_t igmp_maxresp);
pehrhovey 0:439354122597 90 PACK_STRUCT_FIELD(u16_t igmp_checksum);
pehrhovey 0:439354122597 91 PACK_STRUCT_FIELD(struct ip_addr igmp_group_address);
pehrhovey 0:439354122597 92 } PACK_STRUCT_STRUCT;
pehrhovey 0:439354122597 93 PACK_STRUCT_END
pehrhovey 0:439354122597 94 #ifdef PACK_STRUCT_USE_INCLUDES
pehrhovey 0:439354122597 95 # include "arch/epstruct.h"
pehrhovey 0:439354122597 96 #endif
pehrhovey 0:439354122597 97
pehrhovey 0:439354122597 98 /*
pehrhovey 0:439354122597 99 * now a group structure - there is
pehrhovey 0:439354122597 100 * a list of groups for each interface
pehrhovey 0:439354122597 101 * these should really be linked from the interface, but
pehrhovey 0:439354122597 102 * if we keep them separate we will not affect the lwip original code
pehrhovey 0:439354122597 103 * too much
pehrhovey 0:439354122597 104 *
pehrhovey 0:439354122597 105 * There will be a group for the all systems group address but this
pehrhovey 0:439354122597 106 * will not run the state machine as it is used to kick off reports
pehrhovey 0:439354122597 107 * from all the other groups
pehrhovey 0:439354122597 108 */
pehrhovey 0:439354122597 109
pehrhovey 0:439354122597 110 struct igmp_group {
pehrhovey 0:439354122597 111 struct igmp_group *next;
pehrhovey 0:439354122597 112 struct netif *interface;
pehrhovey 0:439354122597 113 struct ip_addr group_address;
pehrhovey 0:439354122597 114 u8_t last_reporter_flag; /* signifies we were the last person to report */
pehrhovey 0:439354122597 115 u8_t group_state;
pehrhovey 0:439354122597 116 u16_t timer;
pehrhovey 0:439354122597 117 u8_t use; /* counter of simultaneous uses */
pehrhovey 0:439354122597 118 };
pehrhovey 0:439354122597 119
pehrhovey 0:439354122597 120
pehrhovey 0:439354122597 121 /* Prototypes */
pehrhovey 0:439354122597 122 void igmp_init(void);
pehrhovey 0:439354122597 123
pehrhovey 0:439354122597 124 err_t igmp_start( struct netif *netif);
pehrhovey 0:439354122597 125
pehrhovey 0:439354122597 126 err_t igmp_stop( struct netif *netif);
pehrhovey 0:439354122597 127
pehrhovey 0:439354122597 128 void igmp_report_groups( struct netif *netif);
pehrhovey 0:439354122597 129
pehrhovey 0:439354122597 130 struct igmp_group *igmp_lookfor_group( struct netif *ifp, struct ip_addr *addr);
pehrhovey 0:439354122597 131
pehrhovey 0:439354122597 132 struct igmp_group *igmp_lookup_group( struct netif *ifp, struct ip_addr *addr);
pehrhovey 0:439354122597 133
pehrhovey 0:439354122597 134 err_t igmp_remove_group( struct igmp_group *group);
pehrhovey 0:439354122597 135
pehrhovey 0:439354122597 136 void igmp_input( struct pbuf *p, struct netif *inp, struct ip_addr *dest);
pehrhovey 0:439354122597 137
pehrhovey 0:439354122597 138 err_t igmp_joingroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
pehrhovey 0:439354122597 139
pehrhovey 0:439354122597 140 err_t igmp_leavegroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
pehrhovey 0:439354122597 141
pehrhovey 0:439354122597 142 void igmp_tmr(void);
pehrhovey 0:439354122597 143
pehrhovey 0:439354122597 144 void igmp_timeout( struct igmp_group *group);
pehrhovey 0:439354122597 145
pehrhovey 0:439354122597 146 void igmp_start_timer( struct igmp_group *group, u8_t max_time);
pehrhovey 0:439354122597 147
pehrhovey 0:439354122597 148 void igmp_stop_timer( struct igmp_group *group);
pehrhovey 0:439354122597 149
pehrhovey 0:439354122597 150 void igmp_delaying_member( struct igmp_group *group, u8_t maxresp);
pehrhovey 0:439354122597 151
pehrhovey 0:439354122597 152 err_t igmp_ip_output_if( struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto, struct netif *netif);
pehrhovey 0:439354122597 153
pehrhovey 0:439354122597 154 void igmp_send( struct igmp_group *group, u8_t type);
pehrhovey 0:439354122597 155
pehrhovey 0:439354122597 156 #ifdef __cplusplus
pehrhovey 0:439354122597 157 }
pehrhovey 0:439354122597 158 #endif
pehrhovey 0:439354122597 159
pehrhovey 0:439354122597 160 #endif /* LWIP_IGMP */
pehrhovey 0:439354122597 161
pehrhovey 0:439354122597 162 #endif /* __LWIP_IGMP_H__ */